Publishing SNS notifications for Zendesk ticket events
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.
This tutorial contains the following sections:
- A Zendesk Support account on a Zendesk Suite Professional plan or above
- An AWS account
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.
In this section, you will create a SNS topic to publish notifications for Zendesk events.
To create a SNS topic
- Log in to the AWS Management Console, and search for “Simple Notification Service”.
- In the left navigation menu, select Topics, then click Create topic.
- Enter a topic name
Zendesk_New_Ticket_to_Email. You can leave the other settings as-is.
- 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.
Next, you will subscribe to the SNS topic you previously created and configure the SNS settings.
To subscribe to the SNS topic
- In Simple Notification Service, select Subscriptions in the left navigation menu, then click Create subscription.
In the Details section:
- Click in the Topic ARN field, and select the
Zendesk_New_Ticket_to_Emailtopic 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
- Click Create subscription. You should see a confirmation message and details of your new SNS subscription.
- 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.
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
- 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.
- In the left navigation menu, select Rules.
- Under Event bus, select the event bus associated with your Zendesk account.
- Click Create rule.
- In Name and description, click in the Name field and enter a rule name
Under Define pattern:
- Select Event pattern
- Select Custom pattern
Click in the Event pattern field, and enter the following JSON text
"Support Ticket: Ticket Created"
- Click Save.
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:
"Ticket <ticket_id> has been created at <created_time> with a priority of <priority>."
- 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:
"detail-type": "Support Ticket: Ticket Created",
"resources": ["Support Ticket"],
"type": "Ticket Created",
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.
Next, test your setup by creating a Zendesk ticket and checking if you receive a SNS notification.
To test your setup
- In your Zendesk Support ticket editor, click Add, create a test ticket, and assign a priority to the ticket.
- 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