This guide explains how to set up and configure the Chatery Cloud API integration for WhatsApp messaging in Cloud Brain.
- A Chatery account with WhatsApp Business API access
- A verified WhatsApp Business phone number
- Cloud Brain application deployed and accessible via HTTPS
- Log in to your Chatery dashboard at https://chatery.com
- Navigate to Connections > Add New Connection
- Select WhatsApp as the connection type
- Choose Cloud API as the integration method
- Select your WhatsApp Business phone number from the list
- If not connected, follow Chatery's instructions to connect your phone number
- Wait for the connection status to show as Active
- Go to Settings > API in your Chatery dashboard
- Generate a new API key if you don't have one
- Copy the following credentials:
- API URL (e.g.,
https://api.chatery.com/v1) - API Key (your secret API key)
- Phone Number ID (your WhatsApp phone number ID)
- API URL (e.g.,
-
Copy the
.env.examplefile to.envin your Cloud Brain project:cp .env.example .env
-
Open
.envand fill in the Chatery configuration:# Chatery Configuration (WhatsApp Cloud API) CHATERY_API_URL=https://api.chatery.com/v1 CHATERY_API_KEY=your_chatery_api_key_here CHATERY_PHONE_NUMBER_ID=your_phone_number_id_here CHATERY_WEBHOOK_SECRET=your_webhook_secret_here
-
Important: Leave the WAHA configuration empty if you're only using Chatery:
# WAHA Configuration (leave empty if not using) WAHA_API_URL= WAHA_API_KEY= WAHA_SESSION_NAME=
Add the phone numbers that are allowed to interact with the bot:
WHITELISTED_NUMBERS=1234567890,0987654321Note: Use international format without the + sign.
- In your Chatery dashboard, go to Connections > Your WhatsApp Connection > Webhooks
- Click Add Webhook
- Enter your Cloud Brain webhook URL:
https://your-domain.com/chatery/webhook - Select the following events to subscribe to:
- Messages (incoming messages)
- Message Status (delivery receipts, read receipts)
- Generate a secure random string for your webhook secret (at least 32 characters)
- Add it to your
.envfile:CHATERY_WEBHOOK_SECRET=your_secure_random_string_here
- Enter the same secret in the Chatery dashboard webhook configuration
Chatery will send a verification request to your webhook URL. The application will automatically respond with the challenge token if the verify token matches.
-
Start your Cloud Brain application:
python main.py
or with uvicorn:
uvicorn main:app --host 0.0.0.0 --port 8000
-
Check the logs for:
ChateryService initialized with API URL: https://api.chatery.com/v1 and phone number ID: your_phone_number_id
- In the Chatery dashboard, check the webhook status
- It should show as Active or Connected
- Send a test message from your WhatsApp to trigger the webhook
- Send a message from a whitelisted number to your WhatsApp Business number
- Check the application logs for:
Message from <number>: <message_body> Identified message type: <type> - Verify that you receive a response on WhatsApp
- Sync Command: Send a message that triggers SYNC type identification to start database synchronization
- Query Command: Send a question to test the RAG (Retrieval-Augmented Generation) functionality
# Chatery Configuration (filled)
CHATERY_API_URL=https://api.chatery.com/v1
CHATERY_API_KEY=your_key
CHATERY_PHONE_NUMBER_ID=your_id
CHATERY_WEBHOOK_SECRET=your_secret
# WAHA Configuration (empty)
WAHA_API_URL=
WAHA_API_KEY=
WAHA_SESSION_NAME=# Chatery Configuration (empty)
CHATERY_API_URL=
CHATERY_API_KEY=
CHATERY_PHONE_NUMBER_ID=
CHATERY_WEBHOOK_SECRET=
# WAHA Configuration (filled)
WAHA_API_URL=http://localhost:3000
WAHA_API_KEY=your_waha_key
WAHA_SESSION_NAME=your_sessionBoth integrations can run simultaneously with different webhook URLs:
- WAHA:
https://your-domain.com/waha/webhook - Chatery:
https://your-domain.com/chatery/webhook
Configure different phone numbers for each integration.
- Verify your webhook URL is accessible from the internet (use HTTPS)
- Check that the webhook secret matches in both
.envand Chatery dashboard - Review application logs for any errors
- Test webhook endpoint manually:
curl -X GET "https://your-domain.com/chatery/webhook?hub.mode=subscribe&hub.verify_token=your_secret&hub.challenge=12345"
- Verify
CHATERY_API_URLandCHATERY_API_KEYare correct - Check that
CHATERY_PHONE_NUMBER_IDis valid - Review application logs for API error responses
- Test API connection manually:
curl -X POST "https://api.chatery.com/v1/messages" \ -H "Authorization: Bearer your_api_key" \ -H "Content-Type: application/json" \ -d '{"messaging_product":"whatsapp","to":"1234567890","type":"text","text":{"body":"test"}}'
- Ensure sender numbers are in the
WHITELISTED_NUMBERSenvironment variable - Check that numbers are in international format without
+ - Verify no extra spaces in the comma-separated list
| Endpoint | Method | Description |
|---|---|---|
/chatery/webhook |
GET | Webhook verification |
/chatery/webhook |
POST | Receive incoming messages |
Chatery sends messages in the following format:
{
"entry": [{
"changes": [{
"value": {
"messages": [{
"from": "1234567890",
"type": "text",
"text": {
"body": "Hello"
}
}]
}
}]
}]
}- Keep API keys secret: Never commit
.envto version control - Use HTTPS: Always use HTTPS for webhook URLs in production
- Verify webhooks: Always enable webhook signature verification
- Limit whitelisted numbers: Only allow trusted numbers to interact
- Rotate secrets: Periodically rotate API keys and webhook secrets
For Chatery-specific issues, refer to:
For Cloud Brain integration issues, check the application logs and README.md.