In this hands-on tutorial, you will learn how to set up an events streaming connection from Zendesk to Amazon EventBridge, and set up AWS SNS to publish email notifications when there are new ticket created events in Zendesk Support. It will take approximately 30 minutes to complete this tutorial.

The Zendesk Events Connector provides a connection to send Zendesk events to Amazon EventBridge. Amazon EventBridge consumes event data and can redirect it to AWS services including AWS Lambda, Amazon SNS, Amazon SQS, and Amazon Kinesis streams. This allows event-driven applications to be built which can subscribe and react to particular Zendesk events.

This tutorial demonstrates one of the many ways you can consume and redirect Zendesk events in Amazon EventBridge.

Related information:

Requirements

  • A Zendesk Support account on a Zendesk Suite Professional plan or above
  • An AWS account

Set up an events connection

First, you’ll need to establish an events connection between Zendesk and your AWS account by setting up the events connector in your Zendesk Admin Center, and configuring Amazon EventBridge. For more information, see Setting up the events connector for Amazon EventBridge.

For the purposes of this tutorial, select the Support tickets check box in Admin Center when you set up the events connector.

Create a SNS topic

In this section, you will create a SNS topic to publish notifications for Zendesk events.

To create a SNS topic

  1. Log in to the AWS Management Console, and search for “Simple Notification Service”.

  2. In the left navigation menu, select Topics, then click Create topic.

  3. Enter a topic name Zendesk_New_Ticket_to_Email. You can leave the other settings as-is.

  4. Click Create topic. You should see a confirmation message and the details of your new SNS topic.

The SNS topic you created is to send email notifications when new tickets are created in Support.

Subscribe to the SNS topic

Next, you will subscribe to the SNS topic you previously created and configure the SNS settings.

To subscribe to the SNS topic

  1. In Simple Notification Service, select Subscriptions in the left navigation menu, then click Create subscription.

  2. In the Details section:

    • Click in the Topic ARN field, and select the Zendesk_New_Ticket_to_Email topic you created in the previous section
    • Click in the Protocol field, and select “Email-JSON”
    • Click in the Endpoint field, and enter the email address where notifications will be sent
  3. Click Create subscription. You should see a confirmation message and details of your new SNS subscription.

  4. Confirm your subscription’s email address by opening the AWS notification email in your email application and click on the SubscribeURL link. Depending on your email application, you may need to paste the link into your web browser.

The link takes you to a subscription confirmation page. You can now close this page.

Create an EventBridge rule

Next, you will create an EventBridge rule to send Zendesk events to your SNS topic. A rule defines the criteria for sending events to the AWS service, which is SNS in this example.

To create an EventBridge rule

  1. In your AWS account, select the Services page in the top navigation, then enter “EventBridge” in the search field to select the Amazon EventBridge page.

  2. In the left navigation menu, select Rules.

  3. Under Event bus, select the event bus associated with your Zendesk account.

  4. Click Create rule.

  5. In Name and description, click in the Name field and enter a rule name EB_Rule_Forward_New_Tickets_to_Email.

  6. Under Define pattern:

    • Select Event pattern

    • Select Custom pattern

    • Click in the Event pattern field, and enter the following JSON text

      {"resources": [    "Support Ticket"],"detail-type": [    "Support Ticket: Ticket Created"]}
  7. Click Save.

  8. Under Select Targets:

    • Click in the Target dropdown field, and select “SNS topic”
    • Click in the Topic box, and select the name of the Topic which you previously created
    • Select the Input transformer chevron
    • Paste the following text into the Input Path and Input Template fields:

    Input path

    {"created_time":"$.detail.ticket_event.ticket.created_at","priority":"$.detail.ticket_event.ticket.priority","ticket_id":"$.detail.ticket_event.ticket.id"}

    Input template

    "Ticket <ticket_id> has been created at <created_time> with a priority of <priority>."

  9. Click Create. You should see a confirmation message.

When creating a rule, the custom event pattern filters the event type for the designated target. For the event pattern you configured when creating the rule, it is filtering Ticket Created events:

{  "version": "0",  "id": "31187aa5-67d2-4eea-a921-38535bf6ec3b",  "detail-type": "Support Ticket: Ticket Created",  "source": "aws.partner/zendesk.com/9242270/default",  "account": "123456789012",  "time": "2019-05-20T22:55:31Z",  "region": "us-east-1",  "resources": ["Support Ticket"],  "detail": {    "ticket_event": {      "meta": {        "version": "1.0",        "occurred_at": "2019-05-20T22:55:29Z",        "ref": "1-1234567890",        "sequence": {          "id": "35D52F7D44640033CCCE4A5F1ADDB2AA",          "position": 1,          "total": 9        }      },      "type": "Ticket Created",      "ticket": {        "id": 35436,        "created_at": "2019-05-20T22:55:29Z",        "updated_at": "2019-05-20T22:55:29Z",        "type": "question",        "priority": "low",        "status": "new",        "requester_id": 20978392,        "submitter_id": 76872,        "assignee_id": 235323,        "organization_id": 10002,        "group_id": 98738,        "brand_id": 123,        "tags": [          "enterprise"        ],        "via": {          "channel": "web"        }      }    }  }}

An event pattern is defined in a JSON format and follows the same structure as the event schema. For more information about event patterns, see Event Patterns.

A target configures where the events are being redirected. In the rule you created, you are sending Ticket Created events to SNS. The Input Transformer provides custom input to a target based on data extracted from the event.

The input path lists the event data to be extracted in JSON format as key value pairs. The input template is the custom message which includes the extracted data mentioned in the input path. So for the rule you created, the custom message contains the time the ticket was created, the ticket priority, and the Zendesk ticket ID.

Test your setup

Next, test your setup by creating a Zendesk ticket and checking if you receive a SNS notification.

To test your setup

  1. In your Zendesk Support ticket editor, click Add, create a test ticket, and assign a priority to the ticket.

  2. Check your email for a message from “AWS Notifications”. You should receive a new email from your SNS subscription which contains the target custom message and event information you configured when creating a rule.

Congratulations! You have now successfully created and set up a Zendesk events connection that sends ticket events to SNS via Amazon EventBridge.

You can use the concepts in this tutorial to further explore and build more sophisticated event-driven solutions such as:

  • Configuring a Slack webhook to post a message into a particular channel
  • Creating a Lambda function that passes the message text into a webhook
  • Changing your rule to point to the Lambda function instead of SNS