Slack is a popular team collaboration product. Zendesk doesn’t have a built-in Slack Target, and in the past this would make it difficult for a business to send messages into Slack. In this example we will show how to use an HTTP Target to send comments from newly rated tickets directly into Slack by integrating directly into a Slack channel using Slack's incoming webhooks.
Setting up the HTTP Target
Let’s assume you have already created an incoming webhook in Slack.
To create your target in Zendesk Support
- As a Zendesk admin, navigate to Settings > Extensions > add target.
- Click HTTP Target.
- Configure the target to integrate with Slack’s incoming webhook functionality.
When a webhook is configured in Slack, it will generate a webhook URL that receives new POST requests from your Target, as shown below. - Configure your webhook to use this URL. Since Slack does not require basic authentication, leave the username and password fields empty.
- Save the target.
You’re now ready to configure a trigger notification using this Target.
Configuring the HTTP target as a trigger action
Now you need to configure your HTTP target as a trigger action.
To set up your trigger in Zendesk Support
- As a Zendesk admin, navigate to Settings > Business Rules > Triggers.
In this example, we’ll configure a Trigger to send information about a customer satisfaction rating into Slack whenever a ticket is solved. - Configure your Trigger conditions to notify your new Slack Target whenever a ticket is solved and Satisfaction is rated with a comment.
The Trigger action should contain JSON formatted content according to Slack's documentation.
{ "text": "You received some feedback from {{ticket.requester.name}} on :\n{{satisfaction.current_comment}}" } - Save your trigger.
Now, newly rated tickets will send notifications into your Slack channel directly from Zendesk.
25 Comments
thanks for the great post Steven!
I was wondering...is there a way to notify a target with the latest comment in a zendesk ticket?
I don't see it in the available placeholders.
thx
Bart
Hey Bart -
You should be able to do so. You just set up the target, and then it's triggers that do the work. More info can be found here:
Notifying external targets
Great example, how do I add the following variables into the slack post. I set up a trigger to send all of this via email, but would prefer to have it go to Slack.... Any help on what the JSON code would be?
Thanks!
Requester: {{ticket.requester.name}}
Assignee: {{ticket.assignee.name}}
Ticket #: {{ticket.id}}
Rating: {{satisfaction.current_rating}}
Comment: {{satisfaction.current_comment}}
Hi Jay!
Rather than sending to email, you need to have it send to the HTTP target you create to send info to Slack. The very last image in the article shows what the JSON looks like. That should get you where you need to go!
@Jessie -
I know you need to send to HTTP target. I got that working, but I want to sen other fields from ZD to Slack, like I set up with my email trigger. See below. What does the JSON code look like if I want to add these fields?
Requester: {{ticket.requester.name}}
Assignee: {{ticket.assignee.name}}
Ticket #: {{ticket.id}}
Rating: {{satisfaction.current_rating}}
Comment: {{satisfaction.current_comment}}
Hey, Jay! Sorry I misunderstood your question.
I was able to find some documentation about formatting incoming webhooks in Slack's API resources, so that should help you get started.
Based on the screenshot example above, it looks like you can use regular ZD placeholders to send that information over, but I'll see about getting one of our Community Moderators in here to verify that for you!
@Jay or @Jessie
Did anybody ever figure out the answer to Jay's question? I'm trying to do the same thing - add additional fields to what Zendesk sends to Slack. I tried adding it right in the Zendesk JSON but Slack doesn't interpret it. I believe I probably have to dork with the JSON URL in the slack webhook as well as the JSON in the Zendesk trigger but there I'm not finding any information on how to manipulate the JSON URL in the slack webhook.
Thanks,
Lara
Never mind: https://thecoolway.net/2018/01/13/advanced-zendesk-notifications-in-slack-using-incoming-webhooks/
I also see that Zendesk and Slack have collaborated to do a new integration but you have to be a certain level customer with Zendesk and it still seems kind of locked down on what fields you can display.
Finally got escalated to T3 support, Garrick killed it and helped me customize JSON to get what i need. Here's what you need if you want to send CSAT/DSAT notifications to your team via a Slack Channel...Really speeds up the investigation/feedback cycles.
{ "text": "DSAT received on {{ticket.url}}, [Assigned to {{ticket.assignee.name}}] [Customer = {{ticket.requester.name}}] [Comment = :\n{{satisfaction.current_comment}}]" }
Glad to hear you got the help you needed, Jay! Thanks for sharing the answer.
For users playing with shaping JSON to send to Slack or other services, you may find https://jsonlint.com/ to be invaluable. You can enter and validate that the JSON is structurally correct, which is handy because if you send bad JSON to Slack, you don't get a ton of information about what broke.
Thanks for sharing that, Dan!
Hello. I'm trying to modify the JSON blob of a trigger that is sent to an extension which in turn fires a message to Slack.
The current JSON which successfully sends info to Slack is:
{"status": "{{ticket.status}}", "id": "{{ticket.id}}", "updated_at": "{{ticket.updated_at_with_timestamp}}"}
Oddly, what is generated in Slack does not reflect this information. The result looks like the following:
I would like to change the JSON to something like the following, but the extension fails to send anything to Slack:
{"ticket_id": "{{ticket.id}}","status": "{{ticket.status}}","updated_at": "{{ticket.updated_at_with_timestamp}}","subdomain": "{{ticket.account}}","ticket_latest_comment": "{{ticket.latest_comment}}","updated_by": "{{current_user.name}}"}
Hey Danny,
Do you see anything in your API->Target Failures tab in your settings that correspond to the time you did your test?
Do you have the Zendesk-built in slack integration installed as well? or just the setup described in the article?
Hi Dan. Yes, there are in fact target failures with status 500 (invalid_ticket_id).
We did install the Zenesk-built integration, but many of the triggers still rely on the legacy Slack-built integrations if I'm not mistaken.
Hey Danny,
My hunch is that your extension might be expecting a parameter name of "id" instead of ticket_id", given that your initial JSON worked and the new one doesn't. (one has "id":"{{ticket.id}}" and the other has "ticket_id":"{{ticket.id}}".
However, just sending the blob as is in a trigger, (once it works) will generate a pretty simple message.
If you're looking to mimic the styling you're seeing in the screenshot you included, you might want to look at using the Slack Attachments feature.
Assuming you're posting to an Incoming Webhook target for Slack, here's an example template:
Hope that helps!
Thanks, Dan! You got me going in the right direction. All is now working as expected.
Hey Steven,
Thank you for this! This is awesome and such a great tutorial Is there a way to compile a daily summary versus the previous 24 hours using this method of the rated tickets? I.e. just a simple count of Good vs. Bad ticket satisfaction comparing the last 48 hours into two timeframes?
We use delighted and they have a summary that counts the data (see ex below), and I was wondering if that would be possible:
Look forward to your thoughts. Even a ticket assignee summary would be awesome as well so each agent can see where they are at day-to-day.
Anyone got a template for what Zendesk's official integration with Slack looks like i.e. the JSON for that message?
I like its setup, and want to replicate - but with a trigger to a slack channel. And need that.
@conza
this is the "Slack Ticket Trigger" it makes automatically
{
"ticket_id": "{{ticket.id}}",
"status": "{{ticket.status}}",
"updated_at": "{{ticket.updated_at_with_timestamp}}",
"subdomain": "{{ticket.account}}",
"ticket_latest_comment": "{{ticket.latest_comment}}",
"updated_by": "{{current_user.name}}"
}
Is there anyway to only show certain text in the description? For instance could you do a regex to look for a certain word and only display that word?
Hey Arsenio,
Any chance you could provide some additional context on what information you'd like displayed? I assume you want specific text from the ticket description to show in Slack?
Hi Brett,
I would like to grab a link out of the description and be able to display it in the slack message.
Hey Arsenio Figueroa
This might be something you could accomplish using Liquid Templating in your Notify Target action to control what you send to Slack. It's not the most straightforward experience but that might be where I'd start looking.
https://support.zendesk.com/hc/en-us/articles/203662146-Understanding-Liquid-markup-and-Zendesk-Support
https://shopify.github.io/liquid/basics/introduction/
Hey - is there any way to send the content of an internal note that's just been posted in a ticket, to Slack? I am extremely new at JSON and script writing so any information about how to do this would be much appreciated - thank you!
Please sign in to leave a comment.