The webhook will process data per chatbot. It will post data of current chatbot’s chat log history per day. leads and appointments records will be posted instantly to your CRM in JSON format.
Setting up a Webhook
To set up a Webhook you must have been issued with a Hello Client logon (contact Hello Client Support if you do not already have this access: info@helloclient.com):
- Log on to Hello Client and click workspace.
- Input the webhook URL of the Endpoint you configured in the Webhook tab.
- click save.
Once the webhook URL is entered, the webhook Sign Key is automatically generated.
Receiving Endpoint
Gain confidence in the authenticity of your webhooks when you use a webhook signing key that mentioned above, a unique secret key shared between your application and Hello Client, to verify the events sent to your endpoints. The webhook signing key will produce theX-Webhook-Signature
, which you can use to compare against an expected webhook signature, to verify events from Hello Client.
X-Webhook-Signature
When Hello Client sends your app a webhook, it will include theX-Webhook-Signature
header in the following format:
X-Webhook-Signature: t=1492774577,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd
Compare the X-Webhook-Signature
, prefixed by v1=
, to the expected signature. If they match, then you can trust that the event payload was issued by Hello Client and has not been tampered with.
const crypto = require('crypto');
// Your application's webhook signing key
const webhookSigningKey = ({}).WEBHOOK_SIGNING_KEY;
// Extract the timestamp and signature from the header
const newoaksSignature = req.get('X-Webhook-Signature');
const { t, signature } = newoaksSignature.split(',').reduce((acc, currentValue) => {
const [key, value] = currentValue.split('=');
if (key === 't') {
// UNIX timestamp
acc.t = value;
}
if (key === 'v1') {
acc.signature = value
}
return acc;
}, {
t: '',
signature: ''
});
if (!t || !signature) throw new Error('Invalid Signature');
// Create the signed payload by concatenating the timestamp (t), the character '.' and the request body's JSON payload.
const data = t + '.' + JSON.stringify(req.body);
const expectedSignature = crypto.createHmac('sha256', webhookSigningKey).update(data, 'utf8').digest('hex');
// Determine the expected signature by computing an HMAC with the SHA256 hash function.
if (expectedSignature !== signature) {
// Signature is invalid!
throw new Error('Invalid Signature');
}
Listening for Chat Logs Events
When an event occurs, it is notified to your configured webhook URL. Push all chat logs of all chatbots owned by the previous day’s users at 2 o’clock every day (UTC time).
Notification Details – HTTP POST Request
Method | POST |
---|---|
Content-Type | application/json |
Extra Request Headers
Header Name | Header Value |
---|---|
X-Webhook-Signature | Signature of the request JSON body |
JSON Body
Example:
{
"Collection": [
{
"SerialNumber": "59001dd73709417321c58b11693183a2",
"Name": "test...",
"StartTime": "2023-11-21T00:00:00Z",
"EndTime": "2023-11-22T00:00:00Z",
"Conversations": [
{
"SessionID": 31302,
"CreateTime": "2023-11-21T16:22:42.264484Z",
"URI": "www.helloclient.com",
"Messages": [
{
"Type": "AI",
"Content": "Hi What can I help you with?"
},
{
"Type": "User",
"Content": "make an appointment"
},
{
"Type": "AI",
"Content": "Please select the date and time..."
}
]
}
]
}
]
}
JSON Body Description:
- SerialNumber string Chatbot ID
- Name string Chatbot Name
- StartTime string Start time (UTC time)
- EndTime string End time (UTC time)
- Conversations Object array
- SessionID int Session ID
- CreateTime string Creation time (UTC time)
- URI string Source uri
- Messages Object array
- Type string There are two types of messages, User and AI
- Content string Message content
Listening for Leads and Appointments Events
When an event occurs, it is notified to your configured webhook URL. Push any new leads and appointments immediately,
Notification Details – HTTP POST Request
MethodPOST
Content-Type | application/json |
---|
JSON Body
Example:
{
"SerialNumber": "59001dd73709417321c58b11693183a2",
"Type": "Lead",
"FirstName": "David",
"LastName": "Garcia",
"Email": "test@qq.com",
"PhoneNumber": "",
"CreateTime": "2023-11-23T18:36:21.512302Z",
"Content": "test",
"SessionID": 31305,
"URI": "www.helloclient.com"
}
JSON Body Description:
- SerialNumber string Chatbot ID
- Type string There are two types: Lead and Appointment
- FirstName string User First Name
- LastName string User Last Name
- Email string User’s Email
- PhoneNumber string User’s phone number
- CreateTime string Creation time (UTC time)
- Content string Remarks or appointment content
- SessionID int Session ID
- URI string Source uri
Error retry
Data response: {“status”:”success”} (case-sensitive,the return value required for a successful callback), returning other values is considered a failure. After failure, retry within 1 minute and 3 minutes.
Webhook-Triggering IPs
Hello Client AI Webhooks are triggered from the following IP addresses:
Production: | 138.91.187.181, 20.245.232.251, 51.116.103.131 |
---|