Create Zendesk Tickets from Call External API Action Type
Gainsight NXT
This article explains how to automate the process of creating Zendesk tickets, by using the Call External API Action Type.
Overview
This tutorial explains how to create a Zendesk Ticket from Rules Engine. It is assumed that all the Zendesk ticket data is stored in a CSV file, hosted on an S3 Dataset. An S3 Dataset would be created to fetch the CSV details. The CSV file has two columns Issue and Description of the issue. The API would create two fields Issue and Description. The values of the CSV column would be ingested into the fields created by the API. Values of this column would be ingested into the fields created by the API. The value in these fields would be configured from Rule dataset, and would vary for each ticket created.
This tutorial has three steps:
Configure Custom Connector
This section explains how to create a connection to Zendesk.
To use custom Connections:
- Navigate to Administration > Connectors 2.0.
- Click Custom Connector.
- Click Create Connection. The Create a Connection window is displayed.
- Enter a name for your Slack connection.
- Select the Authorization Type as Basic.
- Enter your Zendesk credentials.
- Enter the GET URL of your Zendesk account.
- Click TEST CONNECTION to test your connection.
- (Optional) Enter a description.
- Click CREATE.
Setup External Action
This section explains how to create an action for the Zendesk Connection created in the previous section. The action you create here can be used in Rules Engine under the Call External API action type. In this section, two fields called Issue and Description will be created. The value for these fields will be populated from the Call External API action when the Zendesk ticket is created.
To access the External Actions page:
- Navigate to Administration > External Actions.
- Click Create Action. The Action creation page has five sections.
Basic Information
In this section, you can configure the following fields:
- Select the Zendesk connection(?) created in the previous section from the Select a Connector drop-down menu.
- Enter a name for the action in the Action Name field.
- Enter the POST URL of the Zendesk account to which you wish to create new tickets. The URL shown below is for a test Zendesk account and would vary for you. To learn more about Zendesk POST API to create tickets, refer to the Create Tickets section of the Zendesk Developers article.
Payload
In this section, configure the fields in JSON format. These fields are displayed under the Setup Action page and you can load data from a Dataset into these fields. Payload can be entered either in the JSON format or x-www-form-urlencoded format.
In the following image, the Payload fields are added in JSON format.
The code
{"ticket": {"subject": "{{Issue}}", "comment": { "body": "{{Description}}" }}}
creates a Zendesk ticket. The title of the ticket can be configured from the Issue field and the description of the ticket from the Description field. The two fields are created from API and values can be ingested into these fields from Call External API action in Rules engine.
To learn more about Create Ticket API in Zendesk, refer to the Zendesk Tickets API document.
Headers Information
In this section, you can configure the Key-value pairs. By default, the Content-Type: application/JSON value is present. Do not alter this value. Click + to create additional Key-value pairs.
Fields
In this section, configure the data type for the fields created in the payload section. In this example, the default String Data type is retained.
Advanced Configuration Information
In this section, you can configure the maximum number of times the API should try to reconnect to Zendesk, in case a connection is not established. By default, this value is set to 3.
Click Create to create the action.
You can test the action by using the Test option.
The API response code 201 indicates that a new ticket was successfully created.
Configure Call External API Action
This section explains how to leverage the Call External API action, by using the connection and action created above.
To use the Call External API action Type:
- Create a rule. In this example, it is assumed that all the issues reside in a CSV file, stored in an S3 dataset. The CSV file has two columns; Issue and Issue description. The values of these columns would be ingested into the fields, populated from the API.
- Navigate to the Setup Action screen.
- Click + ACTION.
- Select the Call External API action type.
- From the External Action drop-down menu, select the action (Test ZendeskTicket Creation in this example) created in the previous section. This action is present under the Connection name (Zendesk Docs Team in this example).
- The Issue and Description are populated from the External Action screen.
- Choose values from your dataset to insert into these fields. You can also choose to insert custom values instead of mapping fields from the dataset.
Note: You can also choose to ingest custom values into the fields. - Click Save Actions.
When you execute the rule, a new ticket is created in Zendesk with Title Gainsight Issue and comment as A New issue created.
The ticket is assigned to the user whose credentials were used to establish a connection to Zendesk (refer to the Configure Custom connector section of this article). This user also receives an email that confirms the creation of the ticket.