Extending your first integration: Triggering a ZIS Flow from external events

In the previous tutorials, you have learnt how a ZIS Flow can be triggered by events originated from Zendesk such as "Run X flow when Y happens". This pattern works well for cases where a Zendesk event requires an update to a third-party system. However, if you want to react to events from a third-party system and update Zendesk, you can use ZIS Inbound Webhooks.

Understanding ZIS Inbound Webhooks

The Inbound Webhooks Service in ZIS is responsible for receiving incoming webhook requests from third party systems. If a third party system supports sending HTTP requests with basic authentication, you can use it to trigger a flow.

In this tutorial, you'll make use of ZIS Inbound Webhooks to trigger a flow that adds a user in Zendesk Support. You'll mimic the third party sending the request to the Inbound Webhook URL with a cURL command.

Note: Requests sent to Inbound Webhook URLs created by this service are authenticated using basic authentication. Support for other authentication types will be added in the future.


This tutorial uses a ZIS connection that is already stored in ZIS. Complete Creating a ZIS connection for Zendesk first.

Creating and uploading a ZIS Bundle

  1. In your text editor, create create_user_bundle.json file and paste the following code:

    {  "zis_template_version": "2019-10-14",  "name": "Add a user",  "description": "Add a user",  "resources": {    "AddTagJobSpec": {      "type": "ZIS::JobSpec",      "properties": {        "name": "AddUserJobSpec",        "event_source": "foo_system",        "event_type": "user_created",        "flow_name": "zis:{integration_name}:flow:AddUserFlow"      }    },    "AddUserFlow": {      "type": "ZIS::Flow",      "properties": {        "name": "AddUserFlow",        "definition": {          "StartAt": "AddUser",          "States": {            "AddUser": {              "Type": "Action",              "ActionName": "zis:{integration_name}:action:AddUser",              "Parameters": {                "access_token.$": "$.connections.zendesk.access_token",                "user_name.$": "$.input.user.name",                "email.$": "$.input.user.email",                "role": "agent"              },              "End": true            }          }        }      }    },    "AddUser": {      "type": "ZIS::Action::Http",      "properties": {        "name": "AddUser",        "definition": {          "method": "POST",          "path": "/api/v2/users",          "headers": [            {              "key": "Authorization",              "value.$": "Bearer {{$.access_token}}"            },            {              "key": "Content-Type",              "value": "application/json"            }          ],          "requestBody": {            "user": {              "name.$": "$.user_name",              "email.$": "$.email",              "role.$": "$.role"            }          }        }      }    }  }}

    Make sure to replace {integration_name} with your integration name.

  2. Save the file.

  3. With your command line tool, make a cURL request to upload the bundle to ZIS Registry:

    curl \--request POST \--url https://{subdomain}.zendesk.com/api/services/zis/registry/{integration_name}/bundles \--user '{email}:{password}' \--header 'content-type: application/json' \-d @create_user_bundle.json

    Replace {subdomain} with your Zendesk subdomain, {integration_name} with your integration name, and {email} and {password} with your basic authentication credentials.

  4. From the command line tool, make the following cURL request to enable the JobSpec in ZIS Registry:

    curl \--request POST \--url "https://{subdomain}.zendesk.com/api/services/zis/registry/job_specs/install?job_spec_name=zis:{integration_name}:job_spec:TicketStatusChangedJobSpec,zis:{integration_name}:job_spec:CommentAddedJobSpec" \--user '{email}:{password}'
  5. Make an API request to create an inbound webhook URL for receiving HTTP requests. The Create Inbound Webhook endpoint requires an OAuth token. You can use the one you generated earlier or set up a new one. To set up a new OAuth token, refer to Obtaining a ZIS OAuth token.

    curl -X POST \https://{subdomain}.zendesk.com/api/services/zis/inbound_webhooks/generic/{integration_name} \  -H 'Authorization: Bearer {oauth_token}' \  -H 'content-type: application/json' \  -d '{      "event_type": "user_created",      "source_system": "foo_system"  }'

    event_type and source_system in this API call must match the event_type and event_source properties defined in the AddUserJobSpec JobSpec above. Make a note of the path, username, and password from the response. You use it to make a request to trigger your flow.

    {  "id": "01FDXWD57X1X57NXEE8WQ2EAME",  "uuid": "1dea476d-51b8-4d54-b3e6-c7a7ec29378c",  "zendesk_account_id": 123,  "path": "{path}",  "integration": "{integration}",  "source_system": "foo_system",  "event_type": "user_created_event",  "username": "{username}",  "password": "{password}"}

Note: The generated URL is scoped to the account. The URL doesn't change when you change your subdomain. Make sure to generate a new inbound webhook URL after you change your subdomain. The URL scoped to the old subdomain will be removed from the system automatically.

Testing the integration

Test your setup by making a cURL request to the Incoming Webhook URL:

```curl -u '{username}:{password}' \https://{subdomain}.zendesk.com/{path} \  -d '{"user": {"name": "Pravin Raj", "email": "[email protected]"}}'```Use  {path}, {username}, and {password} obtained from the previous step.

The user Pravin Raj should be created in Zendesk.

Next: Building an integration: Incorporating a request to a self-hosted API