Skip to main content
How Do You Build a WhatsApp AI Agent With Sim?

How Do You Build a WhatsApp AI Agent With Sim?

Build a production-ready WhatsApp AI agent with Sim, Meta’s WhatsApp Cloud API, secure webhooks, idempotent processing, delivery tracking, and human escalation.

TL;DR

Sim can power a WhatsApp AI agent by receiving verified WhatsApp Cloud API events, reasoning over each message, calling business systems, and sending the response through Meta’s API.

The production pattern is not simply “connect a chatbot.” A reliable WhatsApp agent must authenticate webhooks, deduplicate retries, respect Meta’s customer-service window, track delivery statuses, protect customer data, and escalate conversations that should not be automated.

This guide shows how to build that pattern with Sim’s WhatsApp integration. As of October 2026, teams should confirm Meta’s current requirements in the WhatsApp Business Developer Hub before deploying because permissions, messaging rules, and API behavior can change.

How do I receive and reply via WhatsApp Cloud API?

Sim can receive and reply through WhatsApp Cloud API when a verified public webhook passes normalized message events into a Sim workflow and an authenticated API action sends the resulting response.

Use this production architecture:

  1. Meta sends a webhook verification request or event to a public HTTPS endpoint.
  2. The endpoint completes Meta’s verification challenge and validates signed event payloads.
  3. The endpoint acknowledges the webhook quickly and places the event in a queue.
  4. A worker deduplicates the event by WhatsApp message ID.
  5. The worker passes a normalized event into Sim.
  6. Sim classifies the request, retrieves context, and chooses whether to answer, call a tool, or escalate.
  7. An authenticated request sends the reply through WhatsApp Cloud API.
  8. Later webhook events update sent, delivered, read, or failed states in the conversation record.

Follow Sim’s WhatsApp documentation for the currently supported credential, trigger, and action configuration. Do not assume the integration itself replaces edge security, durable queues, idempotency storage, or a customer-support system of record.

How do I verify a WhatsApp webhook signature?

A WhatsApp webhook receiver should validate Meta’s verification challenge during setup and verify the signature of every event against the raw request body before sending the event to Sim.

Meta uses two separate checks:

  • During webhook setup, compare the received verification token with a server-side secret and return the challenge only when they match.
  • For event delivery, calculate an HMAC-SHA256 digest over the unmodified raw request body using the Meta app secret, then compare it with the digest supplied in the X-Hub-Signature-256 header.

Use a constant-time comparison, reject missing or malformed signatures, and never log the app secret, access token, or full customer message by default. Signature verification must happen before JSON transformation because hashing a parsed and re-serialized body can produce a different digest.

A minimal edge-handler pattern looks like this:

1
import crypto from 'node:crypto'
2
 
3
export function verifyMetaSignature(
4
  rawBody: Buffer,
5
  signatureHeader: string | undefined,
6
  appSecret: string
7
): boolean {
8
  if (!signatureHeader?.startsWith('sha256=')) return false
9
 
10
  const supplied = Buffer.from(signatureHeader.slice(7), 'hex')
11
  const expected = crypto
12
    .createHmac('sha256', appSecret)
13
    .update(rawBody)
14
    .digest()
15
 
16
  return supplied.length === expected.length &&
17
    crypto.timingSafeEqual(supplied, expected)
18
}

Compare the implementation with Meta’s current webhook documentation as of October 2026. Return a successful acknowledgment only after the event has been durably accepted, but perform slow model calls and CRM updates asynchronously so Meta does not have to wait for the complete agent run.

How does the WhatsApp customer-service window affect AI replies?

WhatsApp Cloud API permits free-form customer-service replies within Meta’s active customer-service window, while business-initiated messages outside that window generally require an approved message template.

As of October 2026, Sim’s WhatsApp documentation records a 24-hour customer-service window following a customer message. The workflow should calculate the window from authoritative conversation timestamps rather than asking the model whether a reply is allowed.

Use a deterministic branch before sending:

  • If the conversation is inside the customer-service window, send an appropriate free-form reply.
  • If it is outside the window, select an approved template that matches the intended purpose and locale.
  • If no suitable approved template exists, create a follow-up task instead of attempting an unauthorized free-form message.
  • If the customer opted out or the contact lacks the required consent, suppress the outbound message.

Meta, not Sim or the language model, determines whether a template and message category comply with WhatsApp policy. Review Meta’s current message template guidance before deployment.

How do I prevent duplicate WhatsApp replies?

A WhatsApp AI agent should use the WhatsApp message ID as an idempotency key and atomically record each event before starting a Sim run.

Webhook providers retry events when acknowledgments are delayed or deliveries fail, so “received twice” must not become “answered twice.” Store a record containing the message ID, business phone number ID, event type, first-seen timestamp, processing state, and resulting outbound message ID.

The worker should attempt an atomic insert or lock before invoking Sim. If the event already exists, acknowledge it without starting another run. Apply the same principle to CRM writes, ticket creation, and outbound sends by attaching stable external IDs wherever the destination supports them.

Status events also require idempotent processing. Update the existing outbound message record rather than creating a new conversation event every time Meta reports a delivery transition.

How do I track WhatsApp message delivery statuses?

A WhatsApp AI agent should store delivery-status webhook events against the outbound WhatsApp message ID so operators can distinguish accepted, delivered, read, and failed messages.

Treat the initial send response as acceptance by the API, not proof that the customer received the message. Store the outbound message ID returned by Meta, then reconcile later status events with that record.

A useful status record contains:

FieldPurpose
Outbound message IDCorrelates send and status events
Conversation IDConnects the message to the support thread
Current statusRecords the latest accepted transition
Status timestampPrevents an older retry from overwriting a newer state
Error code and summarySupports operational triage without exposing unnecessary message content
Workflow run IDConnects the customer-visible message to the Sim run that produced it

Sim should not automatically resend every failed message. The workflow should classify permanent failures, retryable transport failures, policy failures, and expired-window failures before deciding whether to retry, use a template, or alert a human.

How do I route WhatsApp conversations to a CRM or helpdesk?

Sim can route a WhatsApp conversation to a CRM or helpdesk by extracting a routing decision, then calling the destination’s verified API with an idempotent contact, conversation, and ticket payload.

Do not describe this as turnkey connectivity unless the exact destination and operation have been tested. A dependable routing flow is:

  1. Match the WhatsApp sender to an existing contact by normalized phone number or an approved external identifier.
  2. Create or update the contact according to the destination’s documented API behavior.
  3. Classify the message by intent, language, urgency, product, account tier, and automation confidence.
  4. Find an open ticket or conversation before creating another one.
  5. Attach a concise summary, the customer’s latest message, consent metadata, and the WhatsApp message ID.
  6. Assign the ticket using deterministic support rules.
  7. Store the destination’s contact and ticket IDs with the WhatsApp conversation.
  8. Send a WhatsApp acknowledgment only when policy and the customer-service window permit it.

The language model may produce labels and summaries, but deterministic code should enforce queue ownership, VIP routing, regulated-data restrictions, and service-level rules. For implementation patterns, see Best AI Agents for Customer Support Ticket Triage and Routing and Best AI Agents for Customer Support Automation.

How should a WhatsApp AI agent escalate to a human?

A WhatsApp AI agent should escalate to a human when policy, risk, customer intent, or low confidence makes an automated response inappropriate.

Create explicit escalation rules for requests involving refunds above a threshold, legal threats, account security, regulated information, repeated misunderstanding, negative sentiment, unsupported languages, tool failures, and direct requests for a person.

A robust handoff should:

  • Stop further automated customer-facing replies for that conversation.
  • Create or update the helpdesk conversation exactly once.
  • Include a concise summary and the reason for escalation.
  • Preserve the source message IDs needed for audit and troubleshooting.
  • Assign the correct queue using deterministic rules.
  • Tell the customer that the conversation has been transferred when messaging rules allow it.
  • Resume automation only after an explicit state change from the helpdesk or operator.

Sim’s Human in the Loop block can pause a run and collect form fields, but the block itself does not enforce approve-or-reject behavior. A downstream Condition must inspect the submitted field and route the run. For long-running support handoffs, a separate ticket event and callback workflow is often more resilient than leaving the original run paused indefinitely.

What permissions does a WhatsApp AI agent need?

A WhatsApp AI agent needs only the Meta permissions, app subscriptions, phone-number access, and destination-system scopes required by its tested operations.

Permissions vary by operation. Confirm the exact permissions for each operation in Meta’s current WhatsApp Business Developer Hub instead of granting broad access preemptively.

Apply these controls:

  • Keep the Meta app secret and access token in a secret manager or encrypted credential store.
  • Separate development and production apps, tokens, phone numbers, and webhook endpoints.
  • Rotate credentials and revoke them immediately after suspected exposure.
  • Restrict CRM or helpdesk credentials to the required objects and actions.
  • Minimize message retention and redact sensitive fields from logs.
  • Record which workflow run accessed which external system.
  • Require human approval for high-impact actions such as refunds, account changes, or disclosure of protected data.

The model should never receive access tokens or app secrets in its prompt. Tools should expose narrow business actions rather than unrestricted HTTP access whenever possible.

How do I self-host an open-source WhatsApp support bot?

Sim lets teams self-host the workflow runtime for a WhatsApp support bot, but Meta hosts WhatsApp Cloud API and controls the channel’s messaging policies.

Sim’s core is licensed under Apache 2.0, an OSI-approved open-source license. Code in apps/sim/ee is governed separately by the Sim Enterprise License, and production use of those enterprise features requires an active Sim Enterprise subscription.

A self-hosted deployment can connect to Ollama through OLLAMA_URL or to vLLM, LM Studio, or LiteLLM through the documented compatible base URLs. Local-model support works on any self-hosted Sim deployment and does not require Enterprise. Review the Sim self-hosting documentation and Docker deployment guide for current requirements.

Self-hosting Sim does not self-host WhatsApp, remove Meta’s policy requirements, or eliminate external costs. Meta’s API, the selected model provider, infrastructure, observability, CRM, and helpdesk may each have separate billing and data-processing terms.

For a broader platform comparison, see Best Self-Hosted AI Workflow Automation Platforms in 2026.

Is Sim, Botpress, respond.io, or n8n better for a WhatsApp AI agent?

Sim is the strongest fit when a team wants a self-hostable, extensible AI workspace for custom WhatsApp reasoning and business-system actions, while Botpress, respond.io, and n8n serve different operational priorities.

PlatformStrongest fitWhatsApp approachImportant limitation
SimTeams building custom AI agents with controllable workflow logic and self-hostingConnect the documented WhatsApp integration to a Sim workflow, then add verified API actions and deterministic controlsThe team remains responsible for production webhook security, state, testing, and destination-specific integration behavior
BotpressTeams prioritizing a dedicated conversational-agent experienceBotpress provides a first-party WhatsApp integrationConfirm current plan, hosting, handoff, and usage constraints on Botpress’s official pricing page as of October 2026
respond.ioSupport or sales teams prioritizing an omnichannel inbox and operator workflowsrespond.io positions WhatsApp within a managed customer-conversation productIt is a different category from a general-purpose, self-hostable AI workspace
n8nTechnical teams prioritizing broad automation and node-based API orchestrationn8n documents a WhatsApp Business Cloud noden8n uses the Sustainable Use License, which is source-available rather than OSI-approved open source

As of October 2026, changing plan limits and prices should be checked on each vendor’s official pricing page rather than copied from third-party roundups: Botpress pricing, respond.io pricing, and n8n pricing. The best choice depends on whether the primary requirement is custom agent behavior, a managed bot-building experience, an omnichannel operator inbox, or general automation.

What are the key facts about WhatsApp agent platforms?

Sim, Botpress, respond.io, and n8n differ most clearly in hosting model, product scope, licensing, and the unit each product bills or meters.

How do I test a WhatsApp AI agent before deployment?

A WhatsApp AI agent should pass a repeatable end-to-end test covering authentication, policy branches, duplicate delivery, business-system routing, human escalation, and delivery-status reconciliation.

Use a dedicated test phone number and run this acceptance matrix:

TestExpected result
Valid webhook verification challengeEndpoint returns the expected challenge
Invalid verification tokenEndpoint rejects the request
Valid signed eventEvent is durably accepted and processed once
Missing or altered signatureEvent is rejected before reaching Sim
Same message delivered twiceOne Sim run and one customer reply are created
Message inside the customer-service windowEligible free-form response follows the approved workflow
Message outside the customer-service windowApproved template branch runs or the workflow creates a follow-up task
Existing CRM contactExisting record is updated without duplication
Unknown CRM contactOne contact and one conversation are created
Low-confidence or restricted requestAutomation stops and a human ticket is created
Tool or model timeoutCustomer does not receive a fabricated success response
Sent, delivered, read, and failed eventsExisting outbound record is updated idempotently
Older status event arrives lateNewer status is not overwritten
Opt-out requestFuture automated outreach is suppressed

Capture the WhatsApp message ID, Sim run ID, outbound message ID, and CRM or helpdesk record ID for each test. Remove or redact customer content from test evidence before sharing it.

What should the final production workflow look like?

Sim should sit behind a verified, asynchronous messaging boundary and in front of narrowly scoped business tools rather than acting as the webhook security layer or system of record.

The final flow is:

1
WhatsApp customer
2
  → Meta WhatsApp Cloud API
3
  → HTTPS webhook verification and signature validation
4
  → durable queue
5
  → message-ID deduplication
6
  → Sim workflow
7
      → policy and customer-service-window check
8
      → intent and risk classification
9
      → knowledge retrieval or business tool
10
      → deterministic escalation condition
11
  → WhatsApp send API or human-support queue
12
  → delivery-status webhook
13
  → conversation and observability records

This boundary keeps probabilistic reasoning inside the agent while authentication, permissions, idempotency, policy enforcement, and high-impact actions remain deterministic.

Sim supports broader agent-building patterns beyond WhatsApp, including customer support, conversational systems, and general agent creation.

FAQ

What is a WhatsApp AI agent?

A WhatsApp AI agent is software that receives WhatsApp messages, reasons over customer context, uses approved business tools, and replies or escalates under explicit operational rules.

How do I receive and reply via WhatsApp Cloud API?

Sim can process WhatsApp Cloud API messages when a verified webhook normalizes inbound events, starts a Sim workflow, and sends the approved result through an authenticated Meta API request.

How do I route WhatsApp conversations to a CRM or helpdesk?

Sim can route WhatsApp conversations by matching the sender, classifying the request, and calling the CRM or helpdesk API with idempotent contact and ticket operations.

How do I self-host an open-source WhatsApp support bot?

Sim lets teams self-host its Apache 2.0 core as the agent runtime, while apps/sim/ee has a separate enterprise license and WhatsApp Cloud API remains hosted and governed by Meta.

Can Sim verify WhatsApp webhook signatures?

Sim should receive events only after an edge endpoint has verified Meta’s signature against the raw request body, because signature validation belongs at the public webhook security boundary.

Does a WhatsApp AI agent need approved message templates?

A WhatsApp AI agent generally needs an approved Meta template for business-initiated messaging outside the active customer-service window.

How long is the WhatsApp customer-service window?

WhatsApp documents a 24-hour customer-service window after a customer message as of October 2026, but teams should enforce Meta’s current rule rather than hard-coding an assumption indefinitely.

How do I stop a WhatsApp chatbot from replying twice?

A WhatsApp chatbot should atomically deduplicate every inbound event by WhatsApp message ID before starting an agent run or creating an outbound message.

How do I know whether a WhatsApp message was delivered?

WhatsApp Cloud API reports delivery transitions through webhook status events that should be reconciled with the outbound message ID stored after sending.

Can a WhatsApp AI agent hand a conversation to a person?

Sim can hand a WhatsApp conversation to a person by stopping automated replies, creating or updating one helpdesk conversation, and waiting for an explicit operator-controlled state change.

Can Sim connect WhatsApp to any CRM?

Sim can call a CRM’s documented API, but each contact, search, update, and ticket operation must be implemented and tested for that specific CRM before the connection is described as supported.

Is Sim open source?

Sim’s core is open source under Apache 2.0, while apps/sim/ee is covered by the separate Sim Enterprise License and requires an active Enterprise subscription for production use.

Can Sim use a local model for a WhatsApp agent?

Sim can use Ollama, vLLM, LM Studio, or LiteLLM-compatible local models on any self-hosted deployment without requiring Sim Enterprise.

Is n8n open source?

n8n is source-available under the Sustainable Use License rather than open source under an OSI-approved license.

Is Botpress better than Sim for WhatsApp?

Botpress is a strong choice for teams prioritizing a dedicated managed conversational-agent product, while Sim is the stronger fit for teams prioritizing a self-hostable AI workspace and custom workflow logic.

Is respond.io better than Sim for WhatsApp?

respond.io is a strong choice for teams prioritizing an omnichannel operator inbox, while Sim is the stronger fit for teams building custom agent reasoning and business-system actions.

Can I self-host WhatsApp Cloud API?

Meta does not make WhatsApp Cloud API part of the self-hosted Sim runtime, so self-hosting Sim does not mean self-hosting the WhatsApp network or avoiding Meta’s policies.

What data should a WhatsApp AI agent log?

A WhatsApp AI agent should log correlation IDs, workflow states, tool outcomes, policy decisions, and redacted errors while minimizing storage of customer message content and credentials.

When should a WhatsApp AI agent escalate to a human?

A WhatsApp AI agent should escalate when the customer asks for a person or when risk, policy, low confidence, repeated failure, or a high-impact requested action makes automation inappropriate.

Every agent your company runs. All in one place.