In recent years, the software development industry has seen a surge in adopting new technologies, architectures, and methodologies. One of the most prominent among them is event sourcing, serverless products, and microservices. While these buzzwords are commonly used by salespeople and marketing teams to show their technical savvy and highlight their product’s cutting-edge features, they also represent technological innovations that offer real benefits to developers.
Amazon EventBridge is an event bus service that consumes event data streaming from Zendesk. Events received in Amazon EventBridge can be redirected to AWS services such as AWS Lambda, Amazon SNS, Amazon SQS, and Amazon Kinesis streams. This allows event-driven applications to be built which can subscribe and react to Zendesk events. In this article, I will demonstrate how we can integrate Zendesk with EventBridge and AWS Lambda to update customer event data in Database.
This architecture reduces dependencies and overhead from API-based integrations and API management. The Zendesk Events Connector provides a connection to Amazon EventBridge to stream Zendesk event data.
To set up a connection between the events connector and Amazon EventBridge, you will need an AWS account. Then you configure your Zendesk event source in the Zendesk Admin Center and associate a new event bus with the Zendesk event source in Amazon EventBridge.
Configuring the Zendesk event source:
The process requires performing some tasks in Amazon EventBridge and Admin Center.
To configure your Zendesk event source please follow the below steps to configure Zendesk (Ref: https://support.zendesk.com/hc/en-us/articles/4408824521114-Setting-up-the-Zendesk-Events-Connector-for-Amazon-EventBridge#topic_jb5_32z_skb)
- In Amazon EventBridge, go to Events > Partner event sources, and click Set up under the Zendesk partner listing. It opens the Set up event source page.
- In Step 1: Copy your AWS account information, click Copy to copy your AWS account number to your clipboard.
- In Admin Center, click Apps and integrations in the sidebar, then select Integrations > Integrations.
- Click Connect in Events Connector for Amazon EventBridge to open the page to configure your Zendesk event source.
- Paste the AWS account ID that you copied in Step 2 in the Amazon Web Services account ID field.
- In the Amazon Web Services region drop-down field, select the AWS region to receive events.
- In Event types, select the event types you want to send to Amazon EventBridge.
- Note: Currently, only Zendesk Support and Chat-type events are available with more event types being added in the future. For more information about what events are available, see Events for Amazon EventBridge.
- Click Connect. The event source name can take a few minutes to appear in Amazon EventBridge.
Associating the Zendesk event source to the event bus
To connect Zendesk to Amazon EventBridge, you need to associate the Zendesk event source to an event bus in Amazon EventBridge. This will allow the events from Zendesk to be displayed in Amazon EventBridge under “Partner event sources”. To do this, you first need to create a Zendesk event source and then select the event source name in Amazon EventBridge and associate it with an event bus.
To associate an event source with the event bus
- Sign in to the AWS Management Console as an IAM user with admin permissions.
- In Amazon EventBridge > Events > Partner event sources, select the partner event source name, and in the upper-right of the page, click Associate with event bus.
- Leave the permissions settings as-is, then click Associate. It may take a minute or two for this process to be completed.
Once a connection is established, Zendesk events will begin streaming from Zendesk to Amazon EventBridge. Now you have to set rules and targets in Amazon EventBridge to determine which Zendesk events are redirected to an AWS service.
Create EventBridge rule with SQS as Target:
To create a rule that forwards events from an Event Bus to an SQS target, follow these steps:
- Open the Amazon EventBridge service in the AWS console.
- From the left-hand menu, select “Rules”, and click the “Create rule” button.
- Set a name and description for the rule.
- Under “Define pattern”, select “Event pattern”.
- In the “Event matching pattern” section, define the event pattern you want to capture. As mentioned below:
6. Under “Select event bus”, choose the event bus you want to capture events from.
7. Under “Select targets”, click “Add target”, and choose “Amazon Lambda” from the dropdown menu.
8. Choose the Lambda function you want to send events to, and configure any additional settings as needed.
9. Click “Create rule” to save the rule.
10. Make sure you have the proper permissions to create the rule and send events to Amazon Lambda.
We will require that we build a new Lambda function that gets routed requests from the Event Bus of EventBridge and ingest the event detail in the database. To create a new Lambda function, follow these steps:
- Go to the AWS Management Console and navigate to the Lambda service.
- Click on the ‘Create Function’ button to create a new function.
- Choose the ‘Author from scratch’ option and enter a name for your function.
- Select a runtime environment for your function. (ex. python)
- Choose the execution role for your function. You can either create a new role or use an existing one.
- Click on the ‘Create Function’ button to create your function.
- Once your function is created, you can add your custom code. For this example, we want to ingest the ticket event details into the Database.
- Finally, you can test your function by creating a custom event from Zendesk which will trigger the lambda function and ingest the data in the Database
By following these steps, you can easily create a new Lambda function and get started with serverless computing in AWS.
EventBridge provides a streamlined way to route events directly to AWS Lambda, eliminating the need for extraneous communication layers. This efficient approach to event routing promotes optimal usage of serverless resources. With the ability to easily add a range of Zendesk events, including “Comment Created” and “Priority Changed,” by utilizing rules, the potential for EventBridge to drive a new generation of serverless applications is significant. By harnessing the strengths of top SaaS solutions and combining them with the power of AWS, EventBridge offers a powerful tool for triggering and managing events.