Linking Zendesk and Renesas IoT Sandbox

This tutorial will show you how to link your Zendesk account to your Renesas IoT Sandbox.  You will need a Zendesk Team Plan or higher.  This tutorial assumes you already have a Zendesk account.

Part 1: Create a trigger on Zendesk to send events to Renesas IoT Sandbox

Step 1: Create a Basic User and an API Key

On Renesas IoT Sandbox, navigate to “Manage Users” under “Setup.” The following menu will appear:

Click on Add User and choose a username and password for the user your Zendesk Information will come from.

Next, create an API key. Navigate to Manage API keys under Setup on the sidebar. Click add a new API key, and choose a name for it.

Once you hit save, you’ll see your API key.  It will have the same length as above.

 

Step 2: Create a Target on Zendesk

Log into your Zendesk admin account. Under the setup tab on the sidebar, click on Extensions at the very bottom.

Click Add Target, then click on HTTP Target.

Enter the information shown below, and click save. The link to post to is https://zendesk.mediumone.com/zendesk/log.php. Make sure to select “Create Target” instead of “Test Target” before hitting submit.

Step 3: Create a Trigger on Zendesk

Under the Setup tab on the sidebar, click on Triggers under Business Rules.

In JSON Data, copy and paste the following, replacing the keys:

“medium_one_basic_user” with the basic user you created in Step 1,

“medium_one_basic_user_password” with the password of the user created in step 1,

“medium_one_api_key” with the API key you created.

 

{"medium_one_basic_user":"<YOUR USER>",
"medium_one_basic_user_password":"<YOUR PASSWORD>",
"medium_one_api_key":"<YOUR API KEY>",
"medium_one_env":"renesas",
"ticket_subject": "{{ticket.title}}",
"ticket_description":"{{ticket.description}}",
"ticket_link":"{{ticket.url}}",
"ticket_id" : "{{ticket.id}}",
"ticket_external_id":"{{ticket.external_id}}",
"ticket_source":"{{ticket.via}}",
"ticket_status":"{{ticket.status}}",
"ticket_priority":"{{ticket.priority}}",
"ticket_type":"{{ticket.ticket_type}}",
"ticket_score":"{{ticket.score}}",
"ticket_group_name":"{{ticket.group.name}}",
"ticket_due_date":"{{ticket.due_date}}",
"ticket_latest_comment" :"{{ticket.latest_comment_formatted}}",
"ticket_all_comments":"{{ticket.comments_formatted}}",
"ticket_public_comments":"{{ticket.public_comments_formatted}}",
"account":"{{ticket.account}}",
"assignee_name": "{{ticket.assignee.name}}",
"requester_name":"{{ticket.requester.name}}",
"requester_language":"{{ticket.requester.language}}",
"requester_phone":"{{ticket.requester.phone}}",
"requester_external_id":"{{ticket.requester.external_id}}",
"organization_name":"{{ticket.organization.name}}",
"organization_external_id":"{{ticket.organization.external_id}}",
"ticket_cc":"{{ticket.cc_names}}",
"ticket_tags":"{{ticket.tags}}",
"in_business_hours":"{{ticket.in_business_hours}}",
"ticket_field_id":"{{ticket.ticket_field_ID}}",
"field_option_title_id":"{{ticket.ticket_field_option_title_ID}}",
"incoming_phone_number_id":"{{account.incoming_phone_number_ID}}",
"current_user_name":"{{current_user.name}}",
"current_user_organization_name":"{{current_user.organization.name}}",
"current_user_organization_notes":"{{current_user.organization.notes}}",
"current_user_organization_details":"{{current_user.organization.details}}",
"current_user_external_id":"{{current_user.external_id}}",
"current_user_phone":"{{current_user.phone}}",
"current_user_details":"{{current_user.details}}",
"current_user_notes":"{{current_user.notes}}",
"current_user_language":"{{current_user.language}}",
"current_user_tags":"{{current_user.tags}}",
"requester_email":"{{ticket.requester.email}}",
"current_user_email":"{{current_user.email}}"
}

Save by clicking “CreateTrigger”. Now, an event will be sent to your Renesas IoT Sandbox account every time a ticket is created.

 

Step 4: Create a ticket on Zendesk

Go to your Zendesk account and create a ticket. Include as much or as little information as you want; this is just a test ticket to make sure everything has been correctly configured. The add ticket button can be found on the top lefthand side.

Save by clicking “Submit as New.” Then go back to your Renesas IoT Sandbox account. Under Config, click on Data Streams.

Select raw data stream and click “Edit.” You should see a list of new tags, all sent from Zendesk. Enable all new tags by clicking on Active box; you will use them in workflows later. Click “Save Data Stream”.

Note: If there are no tags, there was a problem in the configuration. Go back through the previous steps to make sure nothing was missed.

 

Part 2: Link Zendesk API Credentials on Renesas IoT Sandbox

Step 1: Create an API key on Zendesk

Log into your Zendesk Administrative account. Under the Setup tab in the sidebar, click on “API” under Channels.

Make sure Token Access is enabled. Then click on the plus sign to create a new API key.

Enter a description and then copy the key shown below. Save this key for the next step. Click Save to finalize the creation of the key.

 

Step 2: Enter your Zendesk Credentials on Renesas IoT Sandbox

Log into your Renesas IoT Sandbox account. Click on the External APIs tab under Setup (You have to be logged in as a web administrator).

 

Click “Add a new service key.” Select Zendesk from the list, and enter:

  • Your Zendesk account’s URL.  i.e https://renesasiotsandbox.zendesk.com   Note: Make sure you use your URL, for more details, view Appendix A. Make sure to include https:// in the url.
  • Your Zendesk admin email address.
  • The API key created in Step 1.

Click Save.

On the next page, you will see a new box for your new Zendesk Credential plus an ID. This is your credential ID.  Make sure to hold onto it because you’ll need it in the next part.

 

Part 3: Create a Workflow to respond to ticket creation

Go to your Workflow Studio and create a new workflow. Under the “Tags and Triggers” tab on the righthand side, go under raw and select ‘ticket_id.’ Drag and drop this box onto the Workflow Studio. Your workflow should look like this:

Next, click on the tab Modules from the righthand sidebar.  Under “Foundation,” drag and drop the box Base Python. Then drag the output node from the green raw.ticket_id box to the blue Python foundation node. Your workflow should look like this:

Double click on the Base Python box. Copy and paste the following into the box. Replace “Your Credential ID” with the credential ID you got from the previous part.

import Credentials
import Zendesk
creds = Credentials.use("<YOUR CREDENTIAL ID>")
log(creds)
auth = Zendesk.authenticate(creds['URL'],creds['username'],creds['API Key'])
ticket_id = IONode.get_input('in1')['event_data']['value']
Zendesk.update_ticket(int(ticket_id), "Processed by Renesas IoT Sandbox")

Click Save and Activate. What this workflow does is write a comment onto any new ticket created on Zendesk saying “Processed by Renesas IoT Sandbox.” Instead of this line, you can put in any information you want to automatically send back to Zendesk. To check if this was successful, create a test ticket in Zendesk the same way as in Part 2. Refresh the page, and see the message sent from the workflow to your Zendesk account.

Congratulations! You just successfully linked your Zendesk account to your Renesas IoT Sandbox account.

Appendix A: Correct URL while Linking Zendesk account with your Sandbox account

Incorrect URL is one of the common errors when linking your Zendesk account to your Renesas IoT Sandbox account. When creating your external API credentials, make sure you use the same URL for which your Zendesk account was created.

In below example, a user received an email notification after he created a Zendesk account; the email specify the new URL.

This URL has to be linked in Renesas IoT Sandbox, when creating an external API key, as shown below.