Webhook API Guide
The Webhook API guide allows you to set-up webhooks to receive aPOST request on when an event or more is triggered.
Create a webhook
Webhooks are configured on the action that produces the event. For lead submissions, use the Collect Leads action:- Go to Build > Actions and open your Collect Leads action.
- Click the Webhooks tab in the action settings.
- Enter the URL that should receive the
POSTrequest, then click Create Webhook.
Payload
Event types
These are the list of events supported in webhooks:leads.submit: When a customer submits their info (Name, Email, Phone, and any custom fields configured on the Collect Leads action) to your agent.
Event payload
The payload of each event:leads.submit:
customFields is keyed by the field names configured on the Collect Leads action, e.g. { "Company name": "Acme", "Team size": 12 }. It is only sent when the action collects custom fields (conversational mode).
Receiving the request
You can receive the payload by accessing the body same as any request. But it is recommended to to check the request headerx-chatbase-signature for securing your endpoint from spam from anyone knows your endpoint.
You can achieve this by using SHA-1 (Secure Hash Algorithm 1) function to generate a signature for the request and compare it with x-chatbase-signature found in the request headers. If the are identical then the request is from Chatbase.
Next.js
Node.js
