Webhooks are available as an addon ($59/mo or $468/yr) or included in the Scale plan by default. Visit your billing page to add this feature.
Accessing webhook settings
Navigate to your chatbot dashboard and select Settings → Webhooks to configure your webhook endpoint.How webhooks work
Each chatbot has exactly one webhook configuration. When an event fires, ContextGPT sends a signed HTTP POST request to your URL. The same endpoint receives all event types — use theevent field in the payload to distinguish them.
Available events
NEW_MESSAGE
Triggered for every message sent or received in a thread (both user and AI/agent messages).
Use cases:
- Log all conversations to your database
- Trigger follow-up actions based on content
- Sync conversations to your CRM
- Monitor chatbot performance in real-time
CONVERSATION_ESCALATED
Triggered when a visitor requests human support.
Use cases:
- Alert your support team immediately
- Create tickets in your helpdesk system
- Route escalations to specific team members
- Track escalation patterns
NEW_LEAD
Triggered when a visitor’s contact information is captured as a lead.
Use cases:
- Add leads to your CRM automatically
- Trigger email marketing campaigns
- Notify your sales team of new prospects
- Sync lead data across platforms
Configuring webhooks
- Navigate to Settings → Webhooks
- Enter your Webhook URL — must be a valid HTTPS endpoint
- Enter a Webhook Secret — minimum 16 characters, used for token verification and payload signing
- Select the Events you want to receive (
NEW_MESSAGE,CONVERSATION_ESCALATED,NEW_LEAD). Defaults to all three. - Click Save Changes
Webhook payload structure
NEW_MESSAGE payload
answer is null and question contains the user’s text. For AI/agent messages, question is null and answer contains the response.
CONVERSATION_ESCALATED payload
user and leadInfo can be null if the visitor had not provided contact information before escalating.
NEW_LEAD payload
Webhook headers
All webhook requests include these headers:Verifying webhooks
Always verify that webhook requests are coming from ContextGPT before processing them.Token verification
Check that theX-WEBHOOK-TOKEN header matches your configured secret:
Signature verification (recommended)
For stronger security, verify theX-SIGNATURE header. The signature is an HMAC-SHA256 of the raw JSON body using your webhook secret:
Handling webhook requests
Your webhook endpoint should:- Respond quickly: Return a
200status code within 10 seconds - Process asynchronously: Queue long-running tasks for background processing
- Handle retries: Use
messageId,leadDetails.id, orthreadIdas idempotency keys to skip duplicate deliveries - Log events: Track received webhooks for debugging and audit purposes
Example endpoint (Node.js/Express)
Webhook retry policy
If your endpoint fails to respond or returns a non-2xx status:| Attempt | Delay |
|---|---|
| 1st retry | 1 second |
| 2nd retry | 5 seconds |
| 3rd retry | 25 seconds |
Delivery logs
ContextGPT records every webhook delivery attempt. From the Webhooks page you can:- View delivery history with status, HTTP response code, and response time
- Filter deliveries by event type or status (
PENDING,RETRYING,SUCCESS,FAILED) - Manually retry any failed delivery
Testing webhooks
Using the built-in test
From Settings → Webhooks, click Send Test and choose an event type. A sample payload is dispatched immediately and appears in your delivery log.Using webhook testing tools
- Webhook.site: Generate a temporary URL to inspect payloads without a server
- ngrok: Expose your local development server to the internet
- Postman: Simulate webhook requests manually
Test payload example
Best practices
Use HTTPS endpoints only
Use HTTPS endpoints only
Webhooks must be delivered over HTTPS to ensure data security. HTTP endpoints are not supported.
Implement idempotency
Implement idempotency
Store
messageId, leadDetails.id, or threadId values and skip processing if already seen. Network issues can cause the same webhook to be delivered multiple times.Process asynchronously
Process asynchronously
Respond to webhooks immediately (within 10 seconds) and process data in the background to avoid timeouts.
Monitor webhook health
Monitor webhook health
Check the delivery log regularly and set up alerts for
FAILED deliveries.Secure your secret
Secure your secret
Store the webhook secret as an environment variable, never in code. If compromised, update it in Settings → Webhooks immediately.
Log all webhook events
Log all webhook events
Keep logs of received webhooks for debugging and audit purposes.
Common use cases
CRM integration
Support ticket creation
Analytics tracking
Troubleshooting
Webhooks not being received
Webhooks not being received
- Verify your endpoint URL is correct and accessible over HTTPS
- Ensure your server accepts POST requests
- Check that your endpoint is not behind a firewall blocking ContextGPT requests
- Test your endpoint with curl or Postman
Receiving 401 Unauthorized errors
Receiving 401 Unauthorized errors
Webhook deliveries timing out
Webhook deliveries timing out
- Respond with a 200 status immediately upon receiving the request
- Move all processing to background jobs
- Your endpoint must respond within 10 seconds
Receiving duplicate webhooks
Receiving duplicate webhooks
- Use
messageId,leadDetails.id, orthreadIdas idempotency keys - Store processed IDs in your database and skip if already seen
Related features
- API Reference - Programmatic access to ContextGPT
- Zapier integration - No-code webhook alternative
- Human support - Configure escalation behavior
- Lead collection - Advanced lead capture settings