Webhook Overview

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.

Read More About Webhooks↗

 

Simple Tutorial

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.

Webhook Name

Enter a name for your webhook: ArtiBot Webhook Test

Payload URL:

Setup a webhook in Zapier:

  • Create a Zap
  • Select the Webhooks Type
  • Choose Catch Hook
  • Click the Save and Continue Button
  • Copy the URL that appears

This URL is what you paste into the Payload URL in ArtiBot. ( See also this link )

Secret:

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.

Webhook Events:

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

Webhook Payload:

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 Description
resource string This is the name of the resource tied to the webhook event. Right now it will always be "lead".
action string This field indicates the type of action that occurred in ArtiBot on the resource object. Currently supported values are: “created”, “updated”, and “completed”.
resource_id string The unique identifier of the resource.
time_stamp Date The time that the event took place.
resource_version number The version number of the resource. This number should increase each time that the resource is updated.

Headers

 
{
    "User-Agent": [
        "artibot-api"
    ],
    "x-artibot-signature": [
        "8EB9F138CFA113EEFD37BCFCD0793A1F49A8E713"
    
}
              

User-Agent:

The User-Agent that ArtiBot will send on webhook requests. The type is string

x-artibot-signature:

This value is created as a hash of the payload using your Secret. This can be used to authenticate the request. See the Authentication section below. The type is String.

Authorization

The authorization scheme was ripped off from GitKraken. See this support document.

The section: Setting up the server could be used here somehow.

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:

const createSignature = (buf) => {
  const hmac = crypto.createHmac('sha1', YOUR_WEBHOOK_SECRET);
  hmac.update(buf, 'utf-8');
  return 'sha1=' + hmac.digest('hex');
};

const verifyWebhookSignature = (req, res, next) => {
  const signature = createSignature(req.buf);
  if (signature !== req.headers['x-artibot-signature']) {
    return res.status(403).send('invalid signature');
  

  next();
};