npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@8monkey/aikit-respond-io

v0.1.1

Published

A type-safe toolkit for Respond.io integration, featuring a secure webhook handler.

Readme

@8monkey/aikit-respond-io

A library to help setup webhook for respond.io integration using a clean, event-based API.

Motivation

Integrating with third-party webhooks often requires repetitive boilerplate: verifying signatures to ensure security, handling strict timeouts, and parsing untyped payloads. This library abstracts those complexities, providing a secure, type-safe, and resilient toolkit.

Features

Note: This package is designed to complement the official @respond-io/typescript-sdk. While the official SDK provides a comprehensive API client, this package focuses on robust webhook handling and integration utilities.

Installation

bun add @8monkey/aikit-respond-io

Compatibility

This package is published as an ESM-only module. It is optimized for use with modern frameworks and bundlers (e.g., Next.js, Vite, Bun) that handle module resolution. If you are using it in a pure Node.js environment, ensure your runtime configuration supports ESM and the appropriate module resolution strategy.

Webhook Handler

The webhook factory creates secure handlers that verify signatures and process events in the background.

Basic Usage

Create a handler and define your logic.

import {
  webhook,
  MessageReceivedPayload,
} from "@8monkey/aikit-respond-io/webhook";

// 1. Create the handler
const onMessage = webhook<MessageReceivedPayload>({
  signingKey: process.env.RESPOND_IO_SIGNING_KEY!,
  handle: async (payload) => {
    console.log("New message from contact", payload.contact.id);
    // Your logic here...
  },
  onError: (err) => console.error("Webhook failed:", err),
});

// 2. Use it in your server (e.g., Hono, Next.js, Workers)
// It exposes a standard Fetch API compatible method
app.mount("/webhook/message-received", onMessage.fetch);

Supported Events

The webhook handler supports various event types from Respond.io. Here are some of the most common ones:

  • MessageReceivedPayload: When a new message is received from a contact.
  • ConversationClosedPayload: When a conversation is closed.
  • MessageSentPayload: When a message is successfully sent to a contact.
  • ContactAssigneeUpdatedPayload: When a contact's assignee changes.

To handle a specific event, specify its payload type, example for new incoming message event:

const onMessage = webhook<MessageReceivedPayload>({
  signingKey: process.env.RESPOND_IO_SIGNING_KEY!,
  handle: async (payload) => {
    console.log("New message from contact", payload.contact.id);
  },
});

Integrations

Vercel AI SDK

Note: With ai as a dependency.

Easily convert Respond.io payloads into AI SDK messages.

import { toModelMessage } from "@8monkey/aikit-respond-io/vercel-ai";
import { generateText } from "ai";

// Inside your webhook handle function:
handle: async (payload) => {
  const userMessage = toModelMessage(payload.message.message, "user");

  const { text } = await generateText({
    model: yourModel,
    messages: [userMessage],
  });
};

Express

Integrate with an Express.js application.

import {
  webhook,
  MessageReceivedPayload,
} from "@8monkey/aikit-respond-io/webhook";

import { createMiddleware } from "@hattip/adapter-node";
import express from "express";

const onMessage = webhook<MessageReceivedPayload>({
  signingKey: process.env.RESPOND_IO_SIGNING_KEY!,
  handle: async ({ contact }) => console.log(`Message from ${contact.id}`),
});

const app = express();
app.use("/webhook/message-received", createMiddleware(onMessage.fetch));

app.listen(3000);

Hono

Integrate with a Hono application.

import {
  webhook,
  MessageReceivedPayload,
} from "@8monkey/aikit-respond-io/webhook";
import { Hono } from "hono";

const onMessage = webhook<MessageReceivedPayload>({
  signingKey: process.env.RESPOND_IO_SIGNING_KEY!,
  handle: async ({ contact }) => console.log(`Message from ${contact.id}`),
});

const app = new Hono();
app.mount("/webhook/message-received", onMessage.fetch);

export default app;

ElysiaJS

Integrate with an ElysiaJS application.

import {
  webhook,
  MessageReceivedPayload,
} from "@8monkey/aikit-respond-io/webhook";
import { Elysia } from "elysia";

const onMessage = webhook<MessageReceivedPayload>({
  signingKey: process.env.RESPOND_IO_SIGNING_KEY!,
  handle: async ({ contact }) => console.log(`Message from ${contact.id}`),
});

new Elysia().mount("/webhook/message-received", onMessage.fetch).listen(3000);

AWS Lambda Function URL

Deploy your webhook handler as a standalone AWS Lambda function.

import {
  webhook,
  MessageReceivedPayload,
} from "@8monkey/aikit-respond-io/webhook";

import awsLambdaAdapter from "@hattip/adapter-aws-lambda";

const onMessage = webhook<MessageReceivedPayload>({
  signingKey: process.env.RESPOND_IO_SIGNING_KEY!,
  handle: async ({ contact }) => console.log(`Message from ${contact.id}`),
  // In serverless, we should wait for the handler to finish before returning the response
  waitForCompletion: true,
});

export const handler = awsLambdaAdapter(onMessage.fetch);

Contributing

We welcome contributions!

  • Bug Reports & Feature Requests: Please use the issue tracker to report bugs or suggest features.
  • Pull Requests: Specific fixes and improvements are welcome. Please open a PR.