Resources »

Guides »

Webhooks »

Configure webhooks

Introduction

With Cerb, you can create bot behaviors to automatically react to events taking place within the system – a new assignment, a new incoming message, a task being completed, any record changing, etc.

Webhooks1 provide a way to trigger bot behaviors when external events occur in other applications and services.

For instance:

  • Freshbooks can trigger a webhook when you receive a new payment on an invoice.
  • GitHub can trigger a webhook when an issue is updated on one of your projects.
  • Twilio can trigger a webhook when a new call or text message is received.
  • Zapier can trigger a webhook based on hundreds of different events.

A webhook is simply a special URL that accepts an HTTP POST2 with some data when an event occurs.

You can create webhook URLs in Cerb and associate them with specific bot behaviors.

Enable the webhooks plugin

If you haven’t already, you need to install the webhooks plugin.

Import a bot behavior to handle the webhook

Navigate to Setup » Configure » Import Package.

Paste the following into the textbox:



{
  "package": {
    "name": "Webhook Bot",
    "revision": 1,
    "requires": {
      "cerb_version": "8.1.4",
      "plugins": [
        "cerb.webhooks"
      ]
    },
    "configure": {
      "prompts": [],
      "placeholders": []
    }
  },
  "bots": [
    {
      "uid": "bot_webhook",
      "name": "Webhook Bot",
      "owner": {
        "context": "cerberusweb.contexts.app",
        "id": 0
      },
      "is_disabled": false,
      "params": {
        "config": null,
        "events": {
          "mode": "allow",
          "items": [
            "event.webhook.received"
          ]
        },
        "actions": {
          "mode": "all",
          "items": []
        }
      },
      "image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAMAAABHPGVmAAADAFBMVEUvtPz////8/f38/v8ztfsys/lBREY6PkL4/v8+QURWNToxMjNTUU9aVE02tPhDSExNTUs4Oj49P0I9PD729/c9NzttcXNDRUdOMjdDMjdTMTZihqrw/P/5+vp0eHpMUVRRc5NaOT0/NTmCpMdthJxJRUPi9v3V7vvr7/BzfYVOVVpITVJKSklJMDUrLC30/P4+sO2UuuCiutBohJ9hgZxobG5bVlJePkLr9Pjw9PVOqdu1trhylbhpcXlfZmtJOj7r+v/b8vyt0O1EruicvuFzj6pof5V9Y2VqTVFDQD7N7Pzx9/o9tvdGrOKKrtPIysp+n8KC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kNgyanP4g9ZGdkhar7o+0fhZgRShHKfESezseTvqSAZziszZmRHsZAAaih4UVwjC1FP+5wuNyJVBFI4oXZDJ1pOHZtSMS+AOsIRVA73NGQnwJDS96p4py1rBesVTP65+J+ZuxYVwvFin0ghbEK7yguMxhImOhurrPPMDQ2v0ZYJiC1m8cIkm4nBIYDaqdsx+YBj+yprKri6EmBsJE51yyo1NKQyXH+RZWQhVZaUEYTUCpGnD6IHKnqav7R2lgIDA89yLNz3gZb+cp9o4GQInyC8rjlhv8nUhmGLsG9UeC5M7w3bcC6ROTJMYtV4REMtuqARRhx35r9fyk+BmWx46lL4x1zY/1i9KEwERhtX/uZRxJ5meJCciuVD2yCPGLlGdUv3WQa14SkDz1Tl6zJ4hcuDXHzY6aalq2S2JC8gpHJF8saGOAiqQZ6ezD81vkB55dVzpIvVXjizlyeApo4ib6SLlUnojjMANbAEZKX8NB01PTwV4fA7SI3rH39VMqMBUJvARMmELTo5G12YFtWgwY+kvAgqU14N5GEh2fSioL9ZKYuGDv4PQiCGSObXDgzbaW6Ojolrabt4OZ4RQaHkcpI52RmBxJ1yYSqQQcWVhsy2Sz2aKiFI4ODo+nyVPqHqIUTbGU0dEjRlBpOJw8DgjyqIun0vl8ygKJyZS0MySiHpFIjIigUqkR4A9UD48LlpISkyyrF/xcLB+hB0hA6JTQnU3jQaD/vwysQcbiO0uXvto1zUlW4pN8kk/yv8ufA9gPBZZMh58AAAAASUVORK5CYII=",
      "behaviors": [
        {
          "uid": "behavior_respond_webhook",
          "title": "Respond to webhook",
          "is_disabled": false,
          "is_private": false,
          "priority": 50,
          "event": {
            "key": "event.webhook.received",
            "label": "Webhook received"
          },
          "nodes": [
            {
              "type": "action",
              "title": "Send response",
              "status": "live",
              "params": {
                "actions": [
                  {
                    "action": "set_http_status",
                    "value": "200"
                  },
                  {
                    "action": "set_http_header",
                    "name": "X-Bot",
                    "value": "{{va_name}}"
                  },
                  {
                    "action": "set_http_header",
                    "name": "Content-Type",
                    "value": "application/json; charset=utf-8"
                  },
                  {
                    "action": "set_http_body",
                    "value": "{% set json = {} %}\r\n{% set json = dict_set(json, 'http.verb', http_verb) %}\r\n{% set json = dict_set(json, 'http.path', http_path) %}\r\n{% set json = dict_set(json, 'http.headers', http_headers) %}\r\n{% set json = dict_set(json, 'http.params', http_params) %}\r\n{% set json = dict_set(json, 'client.ip', http_client_ip) %}\r\n{% set json = dict_set(json, 'bot.name', va_name) %}\r\n{{json|json_encode|json_pretty}}"
                  }
                ]
              }
            }
          ]
        }
      ]
    }
  ]
}


Click the Import button.

Create the webhook

  1. Navigate to Setup » Services » Webhooks. In Cerb 8.2 or later you can also use Search » Webhooks.

  2. Click the (+) icon above the worklist.

    Name: Webhook Example Bot Behavior: Webhook Bot » Respond to webhook

  3. Click the Save Changes button.

  4. Copy the webhook URL from the worklist.

Test the webhook

Testing in a web browser

Paste the URL into the location bar of your browser. You’ll see a JSON response.

You can append query parameters to the URL. Try something like: ?name=Joe+Customer&age=37

You’ll see those keys and values show up in the http.params section.

Testing with cURL

If you have access to the curl command at the console, you can send a POST request with a custom header and some query parameters:


curl -i -X POST -H "X-CustomHeader: true" \
"https://cerb.example/webhooks/b5d89ded60c1e4da7b7b2750182e026a5b975cf3?key=value"

You’ll see these options reflected in the JSON response.

Next steps

At this point you can do nearly anything with your webhook.

You can add new conditions and actions based on your needs.

You can register the URL with an external app or service so that it automatically triggers based on an external event.

References