Overview

Answer customer-initiated WhatsApp messages with a Voiceflow agent through Meta’s Cloud API. You host the relay; Meta delivers incoming events and sends its text replies from your business number.

Before you begin

Collect the agent, account and host access.

The example provides public-policy text support. Keep private Voiceflow and platform credentials on the host; a customer’s messaging identity does not authorize access to orders or account records. Have the agent return text only and provide a support route in its instructions. Buttons, audio and Handoff traces need additional adapters; see Adapt agent replies.

Prepare the platform account

Create the exact app or account this relay will use.

1

Create the WhatsApp app

In Meta for Developers, create a business app with the Connect with customers through WhatsApp use case. In its WhatsApp setup, select your business portfolio and obtain the test phone number ID, WhatsApp Business Account ID and test access token. Add and verify your own test recipient. A business phone number ID is an API identifier, distinct from the displayed telephone number.

2

Prepare production credentials

For production, add your business number, verify ownership, complete its registration and display-name review, and configure billing where required. Assign the WhatsApp assets to a business system user and generate its token with messaging permission. Put this token in META_ACCESS_TOKEN; short-lived dashboard tokens are suitable only for the initial test. Record its expiry and rotation owner.

Businesses integrating their own assets and partners onboarding other businesses have different review requirements. Partners need Advanced Access through App Review; follow Meta’s webhook access requirements, including any business verification requested for your account.

Run the relay

Configure and host the supplied executable example.

Use the configuration file for this platform. Every name below is read by the supplied artifact; IDs identify the resources prepared above. VF_ENVIRONMENT is the Environment alias, not a version label pasted from another project.

1

Download and configure the relay

On a Linux host you administer, create /opt/voiceflow-messaging and extract the relay archive there. Use Node.js 22.12 or later. Run node --test fixtures.test.mjs first: it generates signed synthetic events and mocks all remote calls, without credentials or live messages. Save the configuration above as .env, replacing every YOUR_ value; restrict it to the service account with chmod 600 .env. Set DATA_DIR to a private persistent directory that this account can write.

The archive includes core.mjs, platform adapters, HTTP/Teams entry points, local fixture tests and a package manifest. Run node --env-file=.env relay.mjs serve. The HTTP relay uses only Node built-ins; it does not need npm install.

2

Expose the HTTPS endpoint

Point your own DNS hostname to the host. Terminate HTTPS with a valid public certificate and proxy to 127.0.0.1:8080. For example, with Caddy installed:

Replace the example hostname, allow inbound 80/443 for certificate provisioning and keep the relay port private. Use a separate hostname and credentials for testing. Confirm https://YOUR_HOST/health returns ok before registering /webhook.

3

Keep one process running

After the foreground check, stop it and create a service using the unit below. Keep one process and one writable data directory per installation. Do not run this file store on ephemeral serverless storage or start multiple replicas.

Create the non-login relay service user, give it read access to the application and .env, and ownership of /var/lib/voiceflow-messaging. Confirm /usr/bin/node --version is 22.12 or later, or substitute your actual Node path. Then run sudo systemctl daemon-reload and sudo systemctl enable --now voiceflow-messaging. Expect the service to stay active; keep the HTTPS proxy running through its own service.

The file store is a small single-process starting point. Back it up privately and monitor disk space, queue age and failures. Higher traffic needs a transactional inbox/outbox and per-conversation workers before adding replicas. Session keys and customer text are stored in the data directory; apply your retention and access policy there as well as in Voiceflow.

Register incoming events

Connect the platform to your hosted endpoint.

In the app’s WhatsApp → Configuration, or Use cases → Customize → Configuration, enter your relay’s https://YOUR_HOST/webhook and the exact META_VERIFY_TOKEN. Choose Verify and save, then subscribe to the messages webhook field. The GET challenge proves endpoint ownership; POST events are separately checked with X-Hub-Signature-256 and the app secret.

Subscribe the app to your WhatsApp Business Account as well. Save this as subscribe.mjs beside the relay and run it with node --env-file=.env subscribe.mjs, after setting WHATSAPP_WABA_ID in .env:

Expect success: true and a verified callback. A dashboard sample event alone does not prove that the selected business number is subscribed. See Meta’s webhook setup.

Route conversations and replies

Keep the customer, agent session and reply destination aligned.

The relay hashes platform, destination account, customer/thread, project and Environment into a bounded Voiceflow userID. It creates a session with the private project key, stores the returned sessionKey, launches once, then sends { action: { type: "text", payload: text } } to /v4/interact. Text traces become platform replies. Follow-ups reuse the key; starting a session every message would reset the conversation.

Free-form service replies must remain within the 24-hour customer service window. The relay computes its deadline from the inbound message timestamp. It does not send approved templates or reopen expired windows.

Meta’s current BSUID contract allows phone fields to be absent. The example preserves the full BSUID and uses the separate recipient field when replying. Changing from a historical phone-based mapping can start fresh memory; reconcile any existing mappings before migration. It does not merge people by display name.

Webhook failures can be retried for up to seven days. A message accepted by the send API can still fail later; inspect statuses[].status and error codes in the private receipt log. Text messages support 4096 characters; this relay sends smaller 1000-character chunks.

Test a customer conversation

Verify the reply in the destination you installed.

1

Send a real platform message

From the registered test recipient, message the business test number with your prepared support question. Expect an answer from that number in WhatsApp.

2

Check continuity and isolation

Ask a related follow-up, then test with a second authorized customer. Confirm the intended Voiceflow project and exchange in Transcripts. Run node --env-file=.env relay.mjs inspect while the service is stopped to compare event IDs, conversation keys and completion states without printing session tokens.

3

Check this platform’s delivery behavior

Test a signed fixture with from_user_id and no from: it must produce a recipient reply. With an authorized username-enabled test customer, repeat that check through Meta before launch.

A saved callback, accepted API request or successful Voiceflow Run does not prove this platform conversation. Keep local signed-fixture tests separate from this authenticated customer test.

The callback saves but no reply arrives

Check platform access as well as endpoint connectivity.

Check the number’s registration, the system user’s asset assignment, token expiry, business account subscription and the open service window. Inspect failed status codes after an accepted send.

A conversation is paused or a reply is duplicated

Reconcile remote effects before resuming the saved job.

Inspect the event’s phase, failedDuring, saved traces and accepted chunks in the private data file. A runtime timeout can occur after a tool action; a send timeout can occur after the platform accepted the message. The sample pauses that conversation and does not retry either effect automatically. Follow Recover failed messages, then repeat the platform test.

Release and maintain the connection

Promote the tested route and keep recovery available.

1

Approve the production destination

Complete the production number’s registration, account checks and billing. Use the production phone number ID and system token; repeat the customer test with an authorized recipient after any required app review. Publishing a Voiceflow agent does not register a WhatsApp sender.

2

Release the reviewed agent

Have the Voiceflow owner publish the tested agent to the intended Environment. Deploy that alias and production credentials to the relay, restart its service and repeat the customer test with a fresh customer/session. Existing session keys are not an automatic migration to a new release. Keep the previous deployment and state backup available for rollback.

Rotate, update or disconnect

Maintain both the provider registration and the relay state.

Stop the service before changing .env or running maintenance commands. Rotate the platform credentials using its administrator controls, update the secret file and restart. If a webhook secret changes, update both sides and check a real event. For a release change, drain or reconcile pending jobs first; do not erase the state file to resolve a delivery problem.

To disconnect, disable/remove this callback or uninstall this app in the provider, stop the relay and revoke its unused credentials. Confirm no new events arrive and retain/delete customer state according to your policy. Keep the registration details needed to reconnect. See Pause automated replies for a temporary conversation-specific pause.

Use the up and down arrow keys to select a result, Enter to open it, and Escape to close the search.