Enable Zendesk two-way sync

Want to enable Zendesk two-way sync? Here is how to do that.

Enable “sync comments from zendesk” setting

Navigate to your Discourse Admin settings page (/admin/site_settings) and enable sync comments from zendesk setting.

Provide a random secure string in zendesk incoming webhook token setting. This will be used later for configuring Zendesk webhook.

Setting up a Zendesk Webhook

Go to the Webhooks page in Zendesk, which should be under Apps and integrations/Webhooks. The URL should look like this: https://<instance_name>.zendesk.com/admin/apps-integrations/webhooks/webhooks. Click the Actions link in the upper right corner and select Create Webhook from the dropdown menu:

Add Webhook details as follows:

:information_source: Remember to replace <discourse.example.com> with the URL of your Discourse site.

Click the Test Webhook button. On the right hand side where it says ‘Test Webhook’, select ‘Custom test’ from the dropdown menu. Replace the code in the JSON field with this:

{
  "ticket_id": "{{ticket.id}}",
  "topic_id": "{{ticket.external_id}}",
  "email": "{{current_user.email}}",
  "token": "INSERT TOKEN HERE"
}

Replace “INSERT TOKEN HERE” with the secret token you provided in zendesk incoming webhook token setting.

Click the Send Test button to be sure it’s setup properly. In the Response body field you’ll see a’ 400 Bad Request’ tag, but you won’t see an error. You should see something like an html page:

<!DOCTYPE html>
<html lang="en" class="desktop-view not-mobile-device text-size-normal anon">
  <head>
    <meta charset="utf-8">
    <title>Your Discourse community - A place for your users to connect, share ideas, and be inspired.</title>
    <meta name="description" content="Join our community! Learn from others, ask questions, share your tips and tricks.">
    <meta name="discourse_theme_id" content="9">
    <meta name="discourse_current_homepage" content="categories">
...

If you see this, you’re ready to move on.

Setting Up a Zendesk Trigger

Go to the Triggers page in Zendesk, which should be under Admin/Objects and Rules/Business Rules/Triggers . The URL should look like this: https://<instance_name>.zendesk.com/admin/objects-rules/rules/triggers.

Click on Add trigger

Add “Discourse Sync” as Trigger name & Description, and Select “Notifications” from the Category dropdown menu. Then add Conditions for the trigger as shown below:

Add Actions for the trigger as below:

Note that in the JSON body, you’ll paste the following block, replacing “INSERT TOKEN HERE” with the secret token you provided in zendesk incoming webhook token setting:

{
  "ticket_id": "{{ticket.id}}",
  "topic_id": "{{ticket.external_id}}",
  "email": "{{current_user.email}}",
  "token": "INSERT TOKEN HERE"
}

Click the Save button to create the trigger.

Voilà :tada:

That’s it! Now when a new topic is created in a Zendesk enabled category, and a reply is made on Zendesk for that ticket, the comment will be auto-posted on relevant Discourse topic as well.

9 Likes

Hey @techAPJ this is really awesome! Is there a way to set up a triggered sync as opposed to a live sync? i.e. an agent would add a tag in ZD or hit a button or something and only then would the ticket sync to the community?
We are trying to figure out the best way to share common FAQ tickets we get to ZD in the community with the Q&A so that users can find the answers there instead of writing in a ticket.
Thanks!

2 Likes

The only triggered sync we have currently is from Discourse → Zendesk.

Triggering a manual sync from Zendesk → Discourse is tricky since we do not have complete control on Zendesk. That said, I’ll investigate if there is a way to trigger webhook from Zendesk by adding a tag, etc.

3 Likes

@techAPJ did you ever look into ZD to Discourse sync? We are looking at ways to push FAQs from tickets on Zendesk to Discourse!