Skip to main content

Connect WhatsApp

This guide connects a WhatsApp business number, or Meta's test number, to a CatalEx agent with your own Meta credentials. People message the business number from WhatsApp and the agent replies through it. To let an agent answer on your personal number instead, see WhatsApp Personal.

Before you begin​

  • An agent with a verified native reply, and CatalEx signed in to your CatalEx account on this computer. WhatsApp runs through CatalEx Cloud, so you need no server or public address.
  • A Meta developer app with the WhatsApp product, and a business number in it or Meta's test number (Meta test numbers).
  • A system-user access token with the whatsapp_business_management and whatsapp_business_messaging permissions for that business account.

Enter secrets only in CatalEx's fields or private files. Keep them out of screenshots, chat messages and command arguments.

In the app​

1. Open WhatsApp setup​

Open the agent's Add channel: the + on its tile, or Add channel on the Channels tab of its settings. Choose WhatsApp, then the New card. The setup names the agent: NAME answers WhatsApp messages.

CatalEx first waits for CatalEx Cloud to register the agent. If that fails, it says "CatalEx Cloud hasn't registered this agent yet. Try again." Choose Try again.

2. Enter your Meta details​

Where to find these details (or How to get these from Meta during agent onboarding) lists the Meta steps, and Open Meta apps opens Meta's app list.

CatalEx fieldWhere to find it
Meta app secretMeta app › App settings › Basic › App secret › Show
WhatsApp access tokenYour system-user token with both WhatsApp permissions
WhatsApp business account IDThe Messaging account ID beside the sender in Try it out (WhatsApp › API Setup)
Phone number IDThe Phone number ID beside the same sender. It is a numeric ID, not the phone number

Meta needs both IDs: messages are sent through the phone number ID, and webhooks are subscribed on the business account. CatalEx reads the Meta app ID from the token, so you don't enter it. The form doesn't ask for your personal number. Anyone who messages the business number reaches the agent in a chat of their own, unless the channel's access rules refuse them.

3. Connect and finish Meta's checks​

  1. Choose Connect WhatsApp. Fields with a problem are marked and nothing is sent.
  2. CatalEx shows its progress: Find business number, Set up message delivery and Verify connection. With several numbers, choose one.
  3. If Meta asks, enter the verification code it sends (by SMS or voice call) and the number's six-digit two-step verification PIN.
  4. When CatalEx says WhatsApp connected, the agent has the WhatsApp channel.

CatalEx creates the webhook address Meta calls and its verification token; you don't copy either into Meta.

warning

Each connect points the Meta app's webhook and verification token at the number just connected, replacing whatever was there, including another tool's webhook. Use a separate Meta app for CatalEx if another tool needs that app's messages.

Numbers from the same Meta app share its webhook, and CatalEx sends each message to the number it was for. If you remove the most recently connected number, the webhook stays pointed at it; reconnect one of the other numbers to move it. A webhook left at a removed number fails verification, and catalex accounts health reports CALLBACK_UNREACHABLE.

If you close the dialog midway, the card shows Setup not finished. Its Connect WhatsApp resumes the setup.

With the CLI​

Replace AGENT_ID and ACCOUNT_ID with IDs from catalex agents list and catalex accounts list. Every step of the app has an equivalent. The full steps, with the setup actions and files for each Meta detail, are in Connect channels with an AI agent. In short:

catalex channels add --agent AGENT_ID --type whatsapp --new
catalex destinations setup ACCOUNT_ID --whatsapp --action prepare
catalex destinations setup ACCOUNT_ID --whatsapp --action discover --input-file app_secret=/private/meta-app.secret --input-file access_token=/private/whatsapp.token --value business_account_id=BUSINESS_ACCOUNT_ID --value phone_number_id=PHONE_NUMBER_ID
catalex destinations setup ACCOUNT_ID --whatsapp

Read the checkpoint with the last command and take each allowed action until its first line ends (verified). To verify a reply, message the business number from your phone and read the chat with catalex accounts chats list ACCOUNT_ID.

Verify an actual reply​

Choose Start a test conversation, or message the business number from your phone. Ask something the agent can answer from its instructions, files or tools, and confirm all three:

  1. Your message arrives in the business number's chat.
  2. The agent's reply arrives on your phone, ending with a View conversation link.
  3. The same conversation appears under the agent's WhatsApp channel in CatalEx.

"WhatsApp connected" confirms Meta's and CatalEx's checks. Only a reply on your phone confirms that messages reach the agent.

Who can message the number​

Until you set rules, everyone who messages the number is admitted. To change that in the app, open the agent's settings, choose its Channels tab and open the WhatsApp card. Under Who can message, choose Everyone or Only people I choose. With Only people I choose, add people under Allowed. Add anyone you want refused under Blocked, and open Limits to set how many messages a person or the number as a whole can send per hour or day. Use phone numbers with their country code, such as +15551234567; a prefix such as +44* matches every number starting with those digits. Save applies the changes and Cancel drops them.

From the terminal:

catalex accounts access set ACCOUNT_ID --allow +15551234567
catalex accounts access set ACCOUNT_ID --block +15557654321

A blocked number is refused even when an allow entry covers it. People who are refused, or over a limit, get no reply, reaction or read receipt, and the refused message never reaches the agent. In the conversation you see it as Not sent, with the limit that stopped it.

Meta test numbers​

  1. In your Meta app, open Use cases › WhatsApp › Customize › Step 1. Try it out and choose Generate token. When Meta asks which accounts the app may access, choose the test account.
  2. Add your personal number as a verified recipient.
  3. In Business Settings › System users, give your system user access to the Meta app and the test WhatsApp account. If Meta also lists a linked Test Messaging Account, assign it too, with the permission that includes sending messages. Generate the system user's token and use it as the WhatsApp access token.
  4. Send Meta's sample message to your verified number and reply to it from your phone.
  5. In CatalEx, enter the Messaging account ID shown beside the test number as the WhatsApp business account ID.

An Account not registered reply or a permission refusal means a Meta step is unfinished; waiting for app review doesn't fix it.

Delete a WhatsApp chat​

To start a conversation over with fresh context, for example after updating the agent's skills, delete the chat. In CatalEx, select the agent's WhatsApp channel and choose Delete chat (the bin) on the chat's row. Confirm Delete chat with NAME?. Its messages and the agent's session are deleted from CatalEx and this computer, and any work in progress stops. The messages stay in WhatsApp. The person's next message starts a new chat.

From the terminal, list the chats, then delete one using its current session:

catalex accounts chats list ACCOUNT_ID --json
catalex accounts chats delete ACCOUNT_ID CHAT --expected-session SESSION_ID

Use the chat reference and session ID from the list. The command asks first; --yes confirms without a prompt. If the session changed since you listed it, list the chats again. If the outcome is uncertain, rerun with the original --operation-id OPERATION_ID. You can also name the chat by its conversation key: catalex accounts chats delete ACCOUNT_ID --conversation KEY --yes.

Chat commands, bursts and notices​

  • Chat commands. Each agent has a Chat commands switch for each channel, in the channel's card on the agent's Channels tab. It is off by default on WhatsApp. While it is off, a message that starts with / is ordinary text that reaches the agent. When it is on, everyone can use /help, /status and /cancel, and only the account's owner can use /new and /settings. From the terminal: catalex accounts agents switches show ACCOUNT_ID --agent AGENT_ID, and set with --chat-commands on|off or --system-messages on|off.
  • System messages. The Send system messages to people switch, in the same card, decides whether CatalEx's own notices reach the people in the chat. It is off by default on WhatsApp. While it is off, the notices still show in the CatalEx app, and WhatsApp chats get no offline, waiting or failure notices.
  • Messages sent one after another reach the agent as one turn, so it answers once. A voice note ends the wait and is passed on at once with the messages just before it.

Messages outside WhatsApp's 24-hour window​

WhatsApp lets a business send free-form messages only within 24 hours of the person's last message. When that window is closed, CatalEx holds the agent's message and sends it when the person next writes.

To reach people outside the window, approve a template in Meta with exactly one body parameter, which carries the agent's text, and register it:

catalex accounts template set ACCOUNT_ID --name agent_message --language en
catalex accounts template show ACCOUNT_ID
catalex accounts template clear ACCOUNT_ID

A template of another shape is refused with TEMPLATE_PARAMETERS_INVALID. Without a template, the message stays held until the person writes.

Replace credentials or reconnect a number​

To replace an expired or revoked access token for a connected number, keeping its conversations and channel:

catalex credentials set ACCOUNT_ID --token-stdin < /private/whatsapp.token

A rejected token exits with CREDENTIAL_REJECTED and leaves the saved one in use.

To bring back a number you set up before, for example after removing its account, add WhatsApp again and enter the same Meta credentials and IDs. CatalEx recognises the number by its phone number ID and reconnects it with its conversations. If setup says another WhatsApp account here already uses the number, keep using that account, or remove it with catalex accounts remove ACCOUNT_ID and set the number up again.

Troubleshooting​

What you seeWhat to do
"CatalEx Cloud hasn't registered this agent yet. Try again."Choose Try again. Check that CatalEx is running and signed in.
Setup says the number belongs to another CatalEx accountNothing was set up. Sign in with the account that owns the number. You may see INSTALLATION_OWNER_CONFLICT.
Meta can't list an eligible numberEnter the current Messaging account ID from Try it out, and check the system user's access to that account.
Account not registered or a permission refusal from MetaFinish the Meta step it names (Meta test numbers).
Setup stays unfinished after a valid tokenMeta still reports the number's registration as pending. Enter the code and PIN when asked, then retry.
Health reports CALLBACK_UNREACHABLEThe Meta app's webhook points at a removed number. Reconnect one of the app's numbers.
An agent's message is held (DELIVERY_WINDOW_CLOSED)Ask the person to send any message, or register a template.
Someone gets no reply at allCheck the channel's access rules and limits in the channel card (Who can message and Limits).
People get "not connected to an agent yet"Add the number to an agent with Add channel › WhatsApp and the number's card.

For Meta test numbers, first confirm that Meta's sample message reaches your verified number, then reply from that phone. That separates a Meta test-account problem from CatalEx routing.

Reply formats​

See WhatsApp reply formats for how text, questions, cards, charts and files appear.