Webhooks are available as an addon ($59/mo or $468/yr) or included in the Scale plan by default. Visit your billing page to enable this feature.
Available webhooks
- New Message
- Escalation
- New Lead
Triggered when your chatbot sends or receives a message in a thread.Use cases:
- Log conversations to your database
- Analyze chatbot performance
- Trigger custom workflows
- Monitor chatbot activity
Setting up webhooks
Set a webhook secret
Create a secure secret (minimum 16 characters) used to sign and verify payloads.
Select events
Choose which events to subscribe to:
NEW_MESSAGE, CONVERSATION_ESCALATED, and/or NEW_LEAD. Defaults to all three.Save configuration
Click Save to activate your webhook. The full secret is shown only once on creation — save it securely.
Webhook configuration
Each chatbot supports one webhook configuration. You can subscribe to one or more of the available event types.Webhook URL
Webhook URL
The HTTPS endpoint where all event notifications will be sent.Example:
https://your-server.com/webhooks/contextgptWebhook Secret
Webhook Secret
A secret (minimum 16 characters) sent in the
X-WEBHOOK-TOKEN header and used to sign each payload via HMAC-SHA256. Shown in full only at creation time.Example: my-very-secret-token-abc123Events
Events
An array of event types to subscribe to. Defaults to all events if omitted.Valid values:
NEW_MESSAGE, CONVERSATION_ESCALATED, NEW_LEADWebhook payloads
New Message payload
Fired for every message sent or received in a thread. For user messages,answer is null. For AI/agent messages, question is null.
question is populated and answer is null for user messages. answer is populated and question is null for AI/agent messages.Escalation payload
Fired when a visitor requests to speak with a human.user and leadInfo can be null if the visitor had not provided their contact information before escalating.New Lead payload
Fired when a visitor’s contact information is captured as a lead.Webhook headers
Every request from ContextGPT includes these headers:X-SIGNATURE is an HMAC-SHA256 signature of the raw JSON body, computed using your webhook secret.
Implementing webhook endpoints
Basic endpoint structure
Your webhook endpoint should:- Accept POST requests
- Verify the webhook token and/or signature
- Return a
200status code immediately - Process the payload asynchronously
Example implementation (Node.js)
Example implementation (Python)
Security best practices
Verify the webhook token
Always check that theX-WEBHOOK-TOKEN header matches your configured secret:
Verify the signature (recommended)
For stronger security, verify theX-SIGNATURE header using HMAC-SHA256:
Use HTTPS
Webhook endpoints must use HTTPS. HTTP endpoints are rejected.Respond quickly
Return a200 status code within 10 seconds. Process time-consuming tasks asynchronously to avoid timeouts.
Testing webhooks
Send a test event
From the webhook settings page, click Send Test and choose an event type (NEW_MESSAGE, CONVERSATION_ESCALATED, or NEW_LEAD). A sample payload is dispatched and logged in the delivery history.
Test with curl
Use webhook testing tools
- Webhook.site — Inspect payloads without a server
- ngrok — Expose a local development server publicly
- Postman — Send and inspect test requests
Delivery logs
Every webhook dispatch is recorded. From the Webhooks page you can:- View the full delivery history with status, response code, and response time
- Filter by event type or status (
PENDING,RETRYING,SUCCESS,FAILED) - Manually retry any failed delivery
Webhook retries
ContextGPT automatically retries failed deliveries:| Attempt | Delay |
|---|---|
| 1st retry | 1 second |
| 2nd retry | 5 seconds |
| 3rd retry | 25 seconds |
FAILED. You can manually retry it from the delivery log.
- Failure conditions: Non-2xx response or no response within 10 seconds
- Idempotency: Each source event is dispatched at most once per webhook configuration
Troubleshooting
Webhooks not being received
Webhooks not being received
Verify endpoint URL
Ensure the URL is correct and publicly accessible.Check HTTPS
Webhooks only work with HTTPS endpoints.Test connectivity
Use curl or Postman to verify your endpoint responds to POST requests.Review firewall rules
Ensure your server allows incoming connections from ContextGPT.
Ensure the URL is correct and publicly accessible.Check HTTPS
Webhooks only work with HTTPS endpoints.Test connectivity
Use curl or Postman to verify your endpoint responds to POST requests.Review firewall rules
Ensure your server allows incoming connections from ContextGPT.
Authentication failures
Authentication failures
Verify secret
Ensure the secret in your code matches the one configured in ContextGPT exactly (case-sensitive, no extra whitespace).Check header name
The token is sent as
Check your server logs for the received token value.
Ensure the secret in your code matches the one configured in ContextGPT exactly (case-sensitive, no extra whitespace).Check header name
The token is sent as
X-WEBHOOK-TOKEN.Review logsCheck your server logs for the received token value.
Timeout errors
Timeout errors
Respond quickly
Return a 200 status within 10 seconds.Process asynchronously
Move time-consuming tasks to background jobs.Optimize code
Profile your webhook handler for performance bottlenecks.
Return a 200 status within 10 seconds.Process asynchronously
Move time-consuming tasks to background jobs.Optimize code
Profile your webhook handler for performance bottlenecks.
Receiving duplicate webhooks
Receiving duplicate webhooks
Use the
data.messageId / data.leadDetails.id / data.threadId fields as idempotency keys. Store processed IDs and skip duplicates on your end.Next steps
API reference
Explore the ContextGPT API
Zapier integration
Use Zapier for no-code automation
SDK documentation
Integrate with the JavaScript SDK
Human support
Set up escalation webhooks