Example: Integrating the HTTP Target with Slack Follow

Comments

17 comments

  • Avatar
    Bart Brosens

    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

     

  • Avatar
    Nicole - Community Manager

    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

  • Avatar
    Jay Kershner

    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}}

  • Avatar
    Jessie - Community Manager

    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!

  • Avatar
    Jay Kershner

    @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}}

  • Avatar
    Jessie - Community Manager

    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!

  • Avatar
    Lara Palmer

    @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

  • Avatar
    Lara Palmer

    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.

  • Avatar
    Jay Kershner

    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}}]" }

  • Avatar
    Nicole - Community Manager

    Glad to hear you got the help you needed, Jay! Thanks for sharing the answer. 

  • Avatar
    Dan Ross

    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. 

  • Avatar
    Jessie - Community Manager

    Thanks for sharing that, Dan!

  • Avatar
    Danny Koss

    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}}"}

  • Avatar
    Dan Ross

    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?

     

     

  • Avatar
    Danny Koss

    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.

  • Avatar
    Dan Ross (Edited )

    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:

    {  
       "channel":"ENTER DESTINATION CHANNEL NAME OR USER ID HERE (eg:escalation_channel)",
       "icon_emoji":":FAVOURITE EMOJI:",
       "username":"WHAT YOU WANT TO NAME YOUR BOT",
       "attachments":[  
          {  
             "fallback":"You have a reply on ticket #{{ticket.id}}({{ticket.title}}!",
             "pretext":"You have a reply on ticket #{{ticket.id}}({{ticket.title}}!",
             "title":"Click To Open Ticket",
             "title_link":"{{ticket.link}}",
             "color":"(green, yellow, warning, see slack docs for options. )",
             "fields":[  
                {  
                   "title":"Status",
                   "value":"{{ticket.status}}",
                   "short":true
                },
                {  
                   "title":"Ticket Subject",
                   "value":"{{ticket.title}}",
                   "short":true
                },
                {  
                   "title":"Assignee",
                   "value":"{{ticket.assignee.name}}",
                   "short":true
                },
                {  
                   "title":"SOME OTHER FIELD",
                   "value":"{{SOME OTHER PLACEHOLDER}}",
                   "short":true
                }
             ]
          }
       ]
    }

    here's a sample of what that looks like. This screenshot isn't a 1:1 for the fields I've put in the demo above, but it should illustrate the point. 

     

    Hope that helps!

  • Avatar
    Danny Koss

    Thanks, Dan!  You got me going in the right direction.  All is now working as expected.

Please sign in to leave a comment.

Powered by Zendesk