@voiceflow/channels-whatsapp 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Voiceflow, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,96 @@
1
- # Temporary Holding Version
1
+ # @voiceflow/channels-whatsapp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A Voiceflow agent in WhatsApp Business Cloud, with one command to set it up.
4
+
5
+ > **Status:** an early release. Expect changes between versions before 1.0.
6
+ > Built on Chat SDK's WhatsApp Business Cloud adapter.
7
+
8
+ ## Connect
9
+
10
+ ```bash
11
+ npx voiceflow-channels connect whatsapp --env-file .env.local
12
+ ```
13
+
14
+ WhatsApp Business Cloud's side is made on WhatsApp Business Cloud's own pages: its app or bot, and the
15
+ settings below. [Chat SDK's guide to the WhatsApp Business Cloud adapter](https://github.com/vercel/chat/tree/main/packages/adapter-whatsapp)
16
+ has each step. Put the settings in your server's env file, and connect does
17
+ the rest. It shows its whole plan and asks before it changes anything.
18
+
19
+ - **It checks the settings are there**, and says what each missing one is.
20
+ - **It makes `WHATSAPP_VERIFY_TOKEN`**, a secret of your own that WhatsApp Business Cloud sends back with each message, and saves it to the env file.
21
+ - **It creates the `whatsapp_*` variables** on your agent, for its prompts.
22
+ - **It writes the Voiceflow values** it had to ask for to the env file. A
23
+ value already there is never changed.
24
+ - **It says what address to give WhatsApp Business Cloud**: your server's public address, then `/api/whatsapp`. It goes in the Meta app's dashboard → WhatsApp → Configuration → Callback URL, with WHATSAPP_VERIFY_TOKEN as the Verify token, subscribed to messages. `voiceflow-channels dev` prints the tunnel's each time it starts.
25
+ - **With nobody at the terminal** (a script, a coding agent) connect asks
26
+ nothing. It stops with exit code 3 and says, in the one stop, everything a
27
+ person has to do. Exit 0 is done, 1 a failure, 2 a mistake in the command.
28
+ - **`voiceflow-channels dev` runs connect for you** the first time, when a
29
+ person is there. So in an app the starter made, `npm run dev` is the one
30
+ command.
31
+ - **Nothing is published.** The variables are live once you publish the
32
+ environment. `--publish` does that here: the whole draft goes live.
33
+ - **`--dry-run`** shows the plan and changes nothing.
34
+
35
+ ## In your server
36
+
37
+ ```ts
38
+ import { whatsapp } from '@voiceflow/channels-whatsapp';
39
+
40
+ const channels = await createChannels({
41
+ voiceflow: { apiKey: process.env.VOICEFLOW_API_KEY!, projectID: process.env.VOICEFLOW_PROJECT_ID! },
42
+ channels: [whatsapp()],
43
+ state,
44
+ });
45
+ // One route takes everything: channels.webhook('whatsapp', request, { waitUntil })
46
+ ```
47
+
48
+ Install it with Chat SDK's adapter:
49
+
50
+ ```bash
51
+ npm install @voiceflow/channels-sdk @voiceflow/channels-whatsapp chat @chat-adapter/catalog @chat-adapter/whatsapp
52
+ ```
53
+
54
+ ### What happens in WhatsApp Business Cloud
55
+
56
+ - **Choices** from the agent are buttons. A click sends the button's own request, as the person who clicked. WhatsApp Business Cloud shows 3 on a message: a longer list is numbered, and a person answers with the number, or the words.
57
+ - **Cards and carousels** are shown as text, with their choices numbered.
58
+ - **Each reply is posted whole**, with WhatsApp Business Cloud's typing indicator while the agent works.
59
+ - **A long answer** goes as several messages, cut where the text breaks, at 4,000 characters.
60
+ - **After a mention, the bot goes on answering** in that conversation without being mentioned again. `whatsapp({ follow: false })` has it answer only where it is mentioned.
61
+ - **A button's label** longer than 20 characters is cut short by the adapter, with an ellipsis. The click still sends the whole choice.
62
+
63
+ ### Settings
64
+
65
+ The adapter reads these from the environment. `whatsapp({ adapter: { … } })`
66
+ passes its config directly instead.
67
+
68
+ | Setting | Needed | What it is |
69
+ |---|---|---|
70
+ | `WHATSAPP_ACCESS_TOKEN` | Yes | Meta access token. |
71
+ | `WHATSAPP_APP_SECRET` | Yes | App secret for webhook verification. |
72
+ | `WHATSAPP_PHONE_NUMBER_ID` | Yes | Bot phone number ID. |
73
+ | `WHATSAPP_VERIFY_TOKEN` | Yes | Webhook verification token. |
74
+ | `WHATSAPP_VERIFY_TOKEN` | Yes: connect makes it | The token Meta sends back when it checks your server's address: any text of your own, entered as the webhook's Verify token. |
75
+ | `WHATSAPP_BOT_USERNAME` | No | Bot display name. |
76
+ | `WHATSAPP_API_URL` | No | Override the WhatsApp Graph API URL. |
77
+
78
+ ### Options
79
+
80
+ | Option | Default | What it does |
81
+ |---|---|---|
82
+ | `adapter` | the environment | The WhatsApp Business Cloud adapter's own config. |
83
+ | `context` | `true` | Set who and where as `whatsapp_*` variables on every turn. |
84
+ | `follow` | `true` | Go on answering a conversation the bot was mentioned in, without another mention. |
85
+
86
+ ### Variables
87
+
88
+ Set on every turn, empty when unknown. The agent sees one only where its
89
+ instructions or global prompt reference it (`{whatsapp_user_name}`).
90
+
91
+ | Variable | What it holds |
92
+ |---|---|
93
+ | `whatsapp_user_id` | The WhatsApp Business Cloud ID of the person in this conversation. |
94
+ | `whatsapp_user_name` | The person's name in WhatsApp Business Cloud. Empty when WhatsApp Business Cloud doesn't say. |
95
+ | `whatsapp_thread_id` | The WhatsApp Business Cloud conversation this turn is in, as Chat SDK names it. |
96
+ | `whatsapp_message_id` | The ID of the person's latest message. Empty when the turn came from a button. |
@@ -0,0 +1,7 @@
1
+ export declare const cli: (argv: string[], io?: import("@voiceflow/channels-sdk/connect").ChannelCliIO) => Promise<number>, connected: (options?: {
2
+ envFile?: string;
3
+ env?: Record<string, string | undefined>;
4
+ }) => Promise<boolean>, settings: {
5
+ needed: string[];
6
+ made: string[];
7
+ };
@@ -0,0 +1,15 @@
1
+ // Written by scripts/channels.mjs: change the template there, not this file.
2
+ // `connect whatsapp`, `point whatsapp` and `disconnect whatsapp`. Node only: import it
3
+ // from `@voiceflow/channels-whatsapp/connect`.
4
+ import { channelCommands } from '@voiceflow/channels-sdk/connect';
5
+ export const { cli, connected, settings } = channelCommands('whatsapp', {
6
+ settings: [
7
+ {
8
+ key: 'WHATSAPP_VERIFY_TOKEN',
9
+ description: "The token Meta sends back when it checks your server's address: any text of your own, entered as the webhook's Verify token.",
10
+ make: true,
11
+ },
12
+ ],
13
+ addressGoes: "the Meta app's dashboard → WhatsApp → Configuration → Callback URL, with WHATSAPP_VERIFY_TOKEN as the Verify token, subscribed to messages",
14
+ });
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/connect/index.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,uFAAuF;AACvF,+CAA+C;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,eAAe,CAAC,UAAU,EAAE;IACtE,QAAQ,EAAE;QACR;YACE,GAAG,EAAE,uBAAuB;YAC5B,WAAW,EAAE,8HAA8H;YAC3I,IAAI,EAAE,IAAI;SACX;KACF;IACD,WAAW,EAAE,4IAA4I;CAC1J,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type ChannelOptions, type ChannelSpec } from '@voiceflow/channels-sdk';
2
+ export type { ChannelOptions as WhatsappOptions } from '@voiceflow/channels-sdk';
3
+ /** Every variable this channel sets, with what it holds. `connect whatsapp` creates them on the agent. */
4
+ export declare const CONTEXT_VARIABLES: Record<string, string>;
5
+ /**
6
+ * WhatsApp Business Cloud as a channel for `createChannels`. It carries the WhatsApp Business Cloud adapter's
7
+ * module, imported here, so a bundled server (Next.js, say) needs no adapter
8
+ * loaded by name. The adapter reads WHATSAPP_ACCESS_TOKEN, WHATSAPP_APP_SECRET, WHATSAPP_PHONE_NUMBER_ID and WHATSAPP_VERIFY_TOKEN unless you pass `adapter`.
9
+ */
10
+ export declare function whatsapp(options?: ChannelOptions): ChannelSpec;
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ // Written by scripts/channels.mjs: change the template there, not this file.
2
+ // A Voiceflow agent in WhatsApp Business Cloud. Everything channel-neutral comes from
3
+ // @voiceflow/channels-sdk; this package brings Chat SDK's WhatsApp Business Cloud adapter.
4
+ import * as adapter from '@chat-adapter/whatsapp';
5
+ import { channel, contextVariables } from '@voiceflow/channels-sdk';
6
+ /** Every variable this channel sets, with what it holds. `connect whatsapp` creates them on the agent. */
7
+ export const CONTEXT_VARIABLES = contextVariables('whatsapp');
8
+ /**
9
+ * WhatsApp Business Cloud as a channel for `createChannels`. It carries the WhatsApp Business Cloud adapter's
10
+ * module, imported here, so a bundled server (Next.js, say) needs no adapter
11
+ * loaded by name. The adapter reads WHATSAPP_ACCESS_TOKEN, WHATSAPP_APP_SECRET, WHATSAPP_PHONE_NUMBER_ID and WHATSAPP_VERIFY_TOKEN unless you pass `adapter`.
12
+ */
13
+ export function whatsapp(options = {}) {
14
+ return channel('whatsapp', adapter, options, { maxTextLength: 4000, capabilities: { maxButtons: 3 } });
15
+ }
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,sFAAsF;AACtF,2FAA2F;AAC3F,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAyC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAI3G,0GAA0G;AAC1G,MAAM,CAAC,MAAM,iBAAiB,GAA2B,gBAAgB,CAAC,UAAU,CAAC,CAAC;AAEtF;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,UAA0B,EAAE;IACnD,OAAO,OAAO,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AACzG,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,69 @@
1
1
  {
2
2
  "name": "@voiceflow/channels-whatsapp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "A Voiceflow agent in WhatsApp Business Cloud, with one command to set it up.",
5
+ "keywords": [
6
+ "voiceflow",
7
+ "channels-sdk",
8
+ "whatsapp",
9
+ "chat-sdk",
10
+ "vercel-chat",
11
+ "chatbot",
12
+ "bot",
13
+ "ai-agent",
14
+ "conversational-ai"
15
+ ],
16
+ "author": "Braden Ream",
17
+ "license": "MIT",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/voiceflow/channels-sdk.git",
21
+ "directory": "packages/whatsapp"
22
+ },
23
+ "homepage": "https://github.com/voiceflow/channels-sdk/tree/main/packages/whatsapp#readme",
24
+ "bugs": {
25
+ "url": "https://github.com/voiceflow/channels-sdk/issues"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "type": "module",
31
+ "engines": {
32
+ "node": ">=22"
33
+ },
34
+ "exports": {
35
+ ".": {
36
+ "types": "./dist/index.d.ts",
37
+ "import": "./dist/index.js"
38
+ },
39
+ "./connect": {
40
+ "types": "./dist/connect/index.d.ts",
41
+ "import": "./dist/connect/index.js"
42
+ }
43
+ },
44
+ "files": [
45
+ "dist",
46
+ "src",
47
+ "README.md",
48
+ "LICENSE"
49
+ ],
50
+ "scripts": {
51
+ "build": "node ../../scripts/clean.mjs && tsc -p tsconfig.json",
52
+ "test": "npm run build && node --test test/*.test.mjs",
53
+ "typecheck": "tsc -p tsconfig.json --noEmit"
54
+ },
55
+ "dependencies": {
56
+ "@voiceflow/channels-sdk": "0.1.1"
57
+ },
58
+ "peerDependencies": {
59
+ "chat": ">=4.44.0 <5",
60
+ "@chat-adapter/catalog": ">=4.44.0 <5",
61
+ "@chat-adapter/whatsapp": ">=4.44.0 <5",
62
+ "@chat-adapter/state-memory": ">=4.44.0 <5"
63
+ },
64
+ "peerDependenciesMeta": {
65
+ "@chat-adapter/state-memory": {
66
+ "optional": true
67
+ }
68
+ }
69
+ }
@@ -0,0 +1,15 @@
1
+ // Written by scripts/channels.mjs: change the template there, not this file.
2
+ // `connect whatsapp`, `point whatsapp` and `disconnect whatsapp`. Node only: import it
3
+ // from `@voiceflow/channels-whatsapp/connect`.
4
+ import { channelCommands } from '@voiceflow/channels-sdk/connect';
5
+
6
+ export const { cli, connected, settings } = channelCommands('whatsapp', {
7
+ settings: [
8
+ {
9
+ key: 'WHATSAPP_VERIFY_TOKEN',
10
+ description: "The token Meta sends back when it checks your server's address: any text of your own, entered as the webhook's Verify token.",
11
+ make: true,
12
+ },
13
+ ],
14
+ addressGoes: "the Meta app's dashboard → WhatsApp → Configuration → Callback URL, with WHATSAPP_VERIFY_TOKEN as the Verify token, subscribed to messages",
15
+ });
package/src/index.ts ADDED
@@ -0,0 +1,19 @@
1
+ // Written by scripts/channels.mjs: change the template there, not this file.
2
+ // A Voiceflow agent in WhatsApp Business Cloud. Everything channel-neutral comes from
3
+ // @voiceflow/channels-sdk; this package brings Chat SDK's WhatsApp Business Cloud adapter.
4
+ import * as adapter from '@chat-adapter/whatsapp';
5
+ import { type ChannelOptions, type ChannelSpec, channel, contextVariables } from '@voiceflow/channels-sdk';
6
+
7
+ export type { ChannelOptions as WhatsappOptions } from '@voiceflow/channels-sdk';
8
+
9
+ /** Every variable this channel sets, with what it holds. `connect whatsapp` creates them on the agent. */
10
+ export const CONTEXT_VARIABLES: Record<string, string> = contextVariables('whatsapp');
11
+
12
+ /**
13
+ * WhatsApp Business Cloud as a channel for `createChannels`. It carries the WhatsApp Business Cloud adapter's
14
+ * module, imported here, so a bundled server (Next.js, say) needs no adapter
15
+ * loaded by name. The adapter reads WHATSAPP_ACCESS_TOKEN, WHATSAPP_APP_SECRET, WHATSAPP_PHONE_NUMBER_ID and WHATSAPP_VERIFY_TOKEN unless you pass `adapter`.
16
+ */
17
+ export function whatsapp(options: ChannelOptions = {}): ChannelSpec {
18
+ return channel('whatsapp', adapter, options, { maxTextLength: 4000, capabilities: { maxButtons: 3 } });
19
+ }