ArtiBot allows webhooks to export your lead data in real time.
Whenever a lead is created, updated, or completed, ArtiBot can send a payload representing information about the lead and the conversation to a URL that you specify. You could use this information to export lead data to your CRM of choice for example.
Let’s dive in and see how this is all done.
This powerful feature is available to you by setting up Webhooks in ArtiBot. Navigate to the Settings area of your ArtiBot. Click on Webhooks in the Send New Leads To section. Next click on Add Webhook.
Enter a name for your webhook: ArtiBot Webhook Test
Setup a webhook in Zapier:
This URL is what you paste into the Payload URL in ArtiBot. ( See also this link )
For secret you provide some shared secret that can be used to authenticate that webhook requests came from ArtiBot. It doesn't matter to much right now, so just put in: test.
This section is where we indicate which events we would like to receive webhooks for. Let's select LeadUpdated.
Now click Save and the webhook is ready to go!
Navigate to the hosted page of your bot and go through a conversation.
Back in ArtiBot in the Webhooks area click on the Delivery History link of your webhook. Here you should be able to see one or more lead:updated events listed. Here you can see what was sent out from ArtiBot as well as the response from the receiver of the webhook.
This simple example demonstrates setting up and testing a webhook to Zapier from ArtiBot
The webhook payload holds all kinds of useful pieces of information. It gives you access to the data that is stored on the lead so far in the conversation (via lead), metadata associated with the conversation (via meta), data available in the conversation that has not been stored on the lead, and information event itself (via resource, action, resource_id, time_stamp, and resource_version.)
Here is an example of what a webhook payload looks like:
{
"lead": {
"id": "c19377db-bdab-4f6d-b8f8-a327c693295e",
"create_date": "2019-06-07T23:05:17.034243",
"modify_date": "2019-06-07T23:09:40.4457217Z",
"bot_id": "9da97045-bb52-40a5-9414-45140a0285aa",
"bot_version_id": "7d8c94d0-3f01-47b1-a795-7e45459f59de",
"account_id": "cd0015d4-63b7-42b7-bd19-fecbe1f781ba",
"contact_id": "1d7e570c-2f76-496c-9a33-d97e3eb1be76",
"status": 0,
"version": 2,
"data": {
"Your First Field Name": {
"input": "test",
"type": "text",
"display_value": "test",
"value": "test"
},
"Your Second Field Name": {
"input": "asdf",
"type": "text",
"display_value": "asdf",
"value": "asdf"
},
"meta": {
"chat_start_page": "https://app.artibot.ai/h/your-hosted-url",
"ip_address": "1.2.3.4",
"location": {
"country_abbreviation": "US",
"country": "United States",
"state": "California",
"city": "Bakersfield",
"latitude": "35.3275",
"longitude": "-118.9839"
},
"browser": {
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
"name": "Chrome",
"version": "74",
"major": null,
"is_mobile": false
},
"last_answered_field_name": "Your Second Field Name"
},
"resource": "lead",
"action": "updated",
"resource_id": "c19377db-bdab-4f6d-b8f8-a327c693295e",
"time_stamp": "2019-06-07T23:09:40.8186038Z",
"resource_version": 2
}
Most of this data is exactly the same as in the ArtiBot API Documentation. Below are fields that are different:
Name | Type |
---|---|
resource | string |
action | string |
resource_id | string |
time_stamp | Date |
resource_version | number |
{
"User-Agent": [
"artibot-api"
],
"x-artibot-signature": [
"8EB9F138CFA113EEFD37BCFCD0793A1F49A8E713"
}
The User-Agent that ArtiBot will send on webhook requests. The type is string
This value is created as a hash of the {method}&{url}&{requestBody}
using your Secret. This can be used to authenticate the request. See the Authentication section below. The type is String.
The x-artibot-signature header can be used to authenticate that the request came from ArtiBot
The source code provided also demonstrates how you can utilize the x-artibot-signature header to verify the received payload is from ArtiBot. Some samples can be found in our GitHub repo.
const createSignature = (req) => {
const url = req.protocol + '://' + req.get('host') + req.originalUrl;
const payload = req.method.toUpperCase() + '&' + url + '&' + req.buf;
const hmac = crypto.createHmac('sha1', WEBHOOK_SECRET);
hmac.update(Buffer.from(payload), 'utf-8');
return hmac.digest('hex');
};
const verifyWebhookSignature = (req, res, next) => {
const signature = createSignature(req);
if (signature !== req.headers[ARTIBOT_SIGNATURE_HEADER].toLowerCase()) {
return res.status(403).send('invalid signature');
}
next();
};