{"_id":"@8monkey/aikit-respond-io","_rev":"4-11db4ea33b5f4f0b94ccf3d3de7bf2e4","name":"@8monkey/aikit-respond-io","dist-tags":{"latest":"0.1.1"},"versions":{"0.0.1":{"name":"@8monkey/aikit-respond-io","version":"0.0.1","keywords":["respond.io","webhook","ai","sdk","integration","bot"],"author":{"name":"Hebo"},"license":"MIT","_id":"@8monkey/aikit-respond-io@0.0.1","maintainers":[{"name":"turisanapo","email":"selvaggiodavide@hotmail.it"}],"homepage":"https://github.com/heboai/hebo/tree/main/packages/aikit-respond-io#readme","bugs":{"url":"https://github.com/heboai/hebo/issues"},"dist":{"shasum":"024e3cab47219f2448dea15ccddc577271f943f2","tarball":"https://registry.npmjs.org/@8monkey/aikit-respond-io/-/aikit-respond-io-0.0.1.tgz","fileCount":12,"integrity":"sha512-HPKi9ZWWkUoVRCuIWZzBGKlp5m4ViFCTsQIBGF5781sdroG6dGBlotnKRRkBhHFJd5Vy55uefsoWXul0Qtx3IQ==","signatures":[{"sig":"MEUCIQDFcIV05AbutW9e7AJ9++REeHeuuIEZWL5QcoMrzZGxuwIgJ8f5PhC5rAcqpLHOOAS/1tUav4eM69TmvyPtF98Ynsk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":17448},"type":"module","exports":{"./webhook":{"types":"./dist/webhook/index.d.ts","import":"./dist/webhook/index.js"},"./vercel-ai":{"types":"./dist/vercel-ai/index.d.ts","import":"./dist/vercel-ai/index.js"}},"gitHead":"ba84bc02248e31681878696daa9ef16d88cefe3a","scripts":{"lint":"eslint .","test":"bun test","build":"tsc","clean":"git clean -fdx -e '.env*' ."},"_npmUser":{"name":"turisanapo","email":"selvaggiodavide@hotmail.it"},"repository":{"url":"git+https://github.com/heboai/hebo.git","type":"git","directory":"packages/aikit-respond-io"},"_npmVersion":"11.6.0","description":"A type-safe toolkit for Respond.io integration, featuring a secure webhook handler.","directories":{},"_nodeVersion":"24.9.0","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"bun-types":"^1.3.1","typescript":"^5.9.2"},"peerDependencies":{"ai":"^5.0.60"},"_npmOperationalInternal":{"tmp":"tmp/aikit-respond-io_0.0.1_1764840685833_0.46143563863785886","host":"s3://npm-registry-packages-npm-production"}},"0.1.0":{"name":"@8monkey/aikit-respond-io","version":"0.1.0","keywords":["respond.io","webhook","ai","sdk","integration","bot"],"author":{"name":"8monkey"},"license":"MIT","_id":"@8monkey/aikit-respond-io@0.1.0","maintainers":[{"name":"turisanapo","email":"selvaggiodavide@hotmail.it"}],"homepage":"https://github.com/8monkey-ai/aikit-respond-io#readme","bugs":{"url":"https://github.com/8monkey-ai/aikit-respond-io/issues"},"dist":{"shasum":"0ef39bcfa1d95e1bf7a1e308c1c485b4faed19ea","tarball":"https://registry.npmjs.org/@8monkey/aikit-respond-io/-/aikit-respond-io-0.1.0.tgz","fileCount":12,"integrity":"sha512-vE36WigsEsqZUsDHuDXaujo4fxHELr1+4mfPZpiowK9R2IKTFvr203Oo1lrXBADVyiaSsYcYuUMC/7Q+BoyNwQ==","signatures":[{"sig":"MEQCICyizs5lNEBTcUHfCpbotny1Hd+bC8AB+jeWFbV/vNhYAiAl8K7RJLvQEa5e7COasGPwqPwxrmVMorYwBXpQFqMxSA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@8monkey%2faikit-respond-io@0.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":17418},"type":"module","exports":{"./webhook":{"types":"./dist/webhook/index.d.ts","import":"./dist/webhook/index.js"},"./vercel-ai":{"types":"./dist/vercel-ai/index.d.ts","import":"./dist/vercel-ai/index.js"}},"gitHead":"99198e4275cb92584d578f7aca6a56cee90b6723","scripts":{"lint":"eslint .","test":"bun test","build":"tsc","clean":"git clean -fdx -e '.env*' ."},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:c036d35a-4e8e-4974-ae79-48a1a5723c57"}},"repository":{"url":"git+https://github.com/8monkey-ai/aikit-respond-io.git","type":"git"},"_npmVersion":"11.6.4","description":"A type-safe toolkit for Respond.io integration, featuring a secure webhook handler.","directories":{},"_nodeVersion":"20.19.6","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"bun-types":"^1.3.3","typescript":"^5.9.3"},"peerDependencies":{"ai":"^5.0.106"},"_npmOperationalInternal":{"tmp":"tmp/aikit-respond-io_0.1.0_1764907126068_0.9436244786053882","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@8monkey/aikit-respond-io","version":"0.1.1","keywords":["respond.io","webhook","ai","sdk","integration","bot"],"author":{"name":"8monkey"},"license":"MIT","_id":"@8monkey/aikit-respond-io@0.1.1","maintainers":[{"name":"turisanapo","email":"selvaggiodavide@hotmail.it"}],"homepage":"https://github.com/8monkey-ai/aikit-respond-io#readme","bugs":{"url":"https://github.com/8monkey-ai/aikit-respond-io/issues"},"dist":{"shasum":"7b3d76524508843decdb706561e96bb3a2d74730","tarball":"https://registry.npmjs.org/@8monkey/aikit-respond-io/-/aikit-respond-io-0.1.1.tgz","fileCount":13,"integrity":"sha512-yx1BORCxa8Znbt+LdapwaJ/iXw8ZIpqOzmwj/dRgshhr4cOaOf5/9yeIoXGNET2ro6Pan2i2DnEKVIZtNmIUjw==","signatures":[{"sig":"MEUCIQCRAADvbKSJlsLqxUxtcRkU34h3IFOBVdlESxRenrBxAgIgfhh2EX+0UG5RnTVp+pxw0kPQ4HVTOcbzwfMVyXC9xqQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@8monkey%2faikit-respond-io@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":18607},"type":"module","exports":{"./webhook":{"types":"./dist/webhook/index.d.ts","import":"./dist/webhook/index.js"},"./vercel-ai":{"types":"./dist/vercel-ai/index.d.ts","import":"./dist/vercel-ai/index.js"}},"gitHead":"2bb0b0168fe9385bdaa8d526333beda82ab8c4a7","scripts":{"lint":"eslint .","test":"bun test","build":"tsc","clean":"git clean -fdx -e '.env*' ."},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:c036d35a-4e8e-4974-ae79-48a1a5723c57"}},"repository":{"url":"git+https://github.com/8monkey-ai/aikit-respond-io.git","type":"git"},"_npmVersion":"11.7.0","description":"A type-safe toolkit for Respond.io integration, featuring a secure webhook handler.","directories":{},"_nodeVersion":"20.19.6","_hasShrinkwrap":false,"devDependencies":{"ai":"^5.0.109","bun-types":"^1.3.3","typescript":"^5.9.3"},"peerDependencies":{"ai":"^5.0.106"},"peerDependenciesMeta":{"ai":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/aikit-respond-io_0.1.1_1765442414746_0.08856850453612175","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2025-12-04T09:31:25.713Z","modified":"2026-04-07T06:49:42.145Z","0.0.1":"2025-12-04T09:31:25.982Z","0.1.0":"2025-12-05T03:58:46.195Z","0.1.1":"2025-12-11T08:40:14.942Z"},"bugs":{"url":"https://github.com/8monkey-ai/aikit-respond-io/issues"},"author":{"name":"8monkey"},"license":"MIT","homepage":"https://github.com/8monkey-ai/aikit-respond-io#readme","keywords":["respond.io","webhook","ai","sdk","integration","bot"],"repository":{"url":"git+https://github.com/8monkey-ai/aikit-respond-io.git","type":"git"},"description":"A type-safe toolkit for Respond.io integration, featuring a secure webhook handler.","maintainers":[{"email":"h@8monkey.ai","name":"heiwen"},{"email":"selvaggiodavide@hotmail.it","name":"turisanapo"}],"readme":"# @8monkey/aikit-respond-io\n\nA library to help setup webhook for respond.io integration using a clean, event-based API.\n\n## Motivation\n\nIntegrating 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.\n\n## Features\n\n- **[Webhook Handler](#webhook-handler)**: Securely process incoming webhooks with signature verification, automatic background processing, and type-safe payloads.\n- **[Integrations](#integrations)**: Ready-to-use examples for popular platforms, including [Vercel AI SDK](#vercel-ai-sdk), [Express](#express), [Hono](#hono), [ElysiaJS](#elysiajs) and [AWS Lambda Function URL](#aws-lambda-function-url).\n\n> **Note:** This package is designed to complement the official [`@respond-io/typescript-sdk`](https://www.npmjs.com/package/@respond-io/typescript-sdk). While the official SDK provides a comprehensive API client, this package focuses on robust webhook handling and integration utilities.\n\n## Installation\n\n```bash\nbun add @8monkey/aikit-respond-io\n```\n\n## Compatibility\n\nThis 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.\n\n## Webhook Handler\n\nThe `webhook` factory creates secure handlers that verify signatures and process events in the background.\n\n### Basic Usage\n\nCreate a handler and define your logic.\n\n```ts\nimport {\n  webhook,\n  MessageReceivedPayload,\n} from \"@8monkey/aikit-respond-io/webhook\";\n\n// 1. Create the handler\nconst onMessage = webhook<MessageReceivedPayload>({\n  signingKey: process.env.RESPOND_IO_SIGNING_KEY!,\n  handle: async (payload) => {\n    console.log(\"New message from contact\", payload.contact.id);\n    // Your logic here...\n  },\n  onError: (err) => console.error(\"Webhook failed:\", err),\n});\n\n// 2. Use it in your server (e.g., Hono, Next.js, Workers)\n// It exposes a standard Fetch API compatible method\napp.mount(\"/webhook/message-received\", onMessage.fetch);\n```\n\n### Supported Events\n\nThe `webhook` handler supports various event types from Respond.io. Here are some of the most common ones:\n\n- `MessageReceivedPayload`: When a new message is received from a contact.\n- `ConversationClosedPayload`: When a conversation is closed.\n- `MessageSentPayload`: When a message is successfully sent to a contact.\n- `ContactAssigneeUpdatedPayload`: When a contact's assignee changes.\n\nTo handle a specific event, specify its payload type, example for new incoming message event:\n\n```ts\nconst onMessage = webhook<MessageReceivedPayload>({\n  signingKey: process.env.RESPOND_IO_SIGNING_KEY!,\n  handle: async (payload) => {\n    console.log(\"New message from contact\", payload.contact.id);\n  },\n});\n```\n\n## Integrations\n\n### Vercel AI SDK\n\n> **Note**: With `ai` as a dependency.\n\nEasily convert Respond.io payloads into AI SDK messages.\n\n```ts\nimport { toModelMessage } from \"@8monkey/aikit-respond-io/vercel-ai\";\nimport { generateText } from \"ai\";\n\n// Inside your webhook handle function:\nhandle: async (payload) => {\n  const userMessage = toModelMessage(payload.message.message, \"user\");\n\n  const { text } = await generateText({\n    model: yourModel,\n    messages: [userMessage],\n  });\n};\n```\n\n### Express\n\nIntegrate with an Express.js application.\n\n```ts\nimport {\n  webhook,\n  MessageReceivedPayload,\n} from \"@8monkey/aikit-respond-io/webhook\";\n\nimport { createMiddleware } from \"@hattip/adapter-node\";\nimport express from \"express\";\n\nconst onMessage = webhook<MessageReceivedPayload>({\n  signingKey: process.env.RESPOND_IO_SIGNING_KEY!,\n  handle: async ({ contact }) => console.log(`Message from ${contact.id}`),\n});\n\nconst app = express();\napp.use(\"/webhook/message-received\", createMiddleware(onMessage.fetch));\n\napp.listen(3000);\n```\n\n### Hono\n\nIntegrate with a Hono application.\n\n```ts\nimport {\n  webhook,\n  MessageReceivedPayload,\n} from \"@8monkey/aikit-respond-io/webhook\";\nimport { Hono } from \"hono\";\n\nconst onMessage = webhook<MessageReceivedPayload>({\n  signingKey: process.env.RESPOND_IO_SIGNING_KEY!,\n  handle: async ({ contact }) => console.log(`Message from ${contact.id}`),\n});\n\nconst app = new Hono();\napp.mount(\"/webhook/message-received\", onMessage.fetch);\n\nexport default app;\n```\n\n### ElysiaJS\n\nIntegrate with an ElysiaJS application.\n\n```ts\nimport {\n  webhook,\n  MessageReceivedPayload,\n} from \"@8monkey/aikit-respond-io/webhook\";\nimport { Elysia } from \"elysia\";\n\nconst onMessage = webhook<MessageReceivedPayload>({\n  signingKey: process.env.RESPOND_IO_SIGNING_KEY!,\n  handle: async ({ contact }) => console.log(`Message from ${contact.id}`),\n});\n\nnew Elysia().mount(\"/webhook/message-received\", onMessage.fetch).listen(3000);\n```\n\n### AWS Lambda Function URL\n\nDeploy your webhook handler as a standalone AWS Lambda function.\n\n```ts\nimport {\n  webhook,\n  MessageReceivedPayload,\n} from \"@8monkey/aikit-respond-io/webhook\";\n\nimport awsLambdaAdapter from \"@hattip/adapter-aws-lambda\";\n\nconst onMessage = webhook<MessageReceivedPayload>({\n  signingKey: process.env.RESPOND_IO_SIGNING_KEY!,\n  handle: async ({ contact }) => console.log(`Message from ${contact.id}`),\n  // In serverless, we should wait for the handler to finish before returning the response\n  waitForCompletion: true,\n});\n\nexport const handler = awsLambdaAdapter(onMessage.fetch);\n```\n\n## Contributing\n\nWe welcome contributions!\n\n- **Bug Reports & Feature Requests**: Please use the [issue tracker](https://github.com/8monkey-ai/aikit-respond-io/issues) to report bugs or suggest features.\n- **Pull Requests**: Specific fixes and improvements are welcome. Please open a PR.\n","readmeFilename":"README.md"}