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:
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à
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.