Example: Integrating the HTTP Target with Slack

Return to top

7 Comments

  • Lea Jane Hug

    I spent all day working on getting this to work, I style it to look quite similar to the native Zendesk/Slack integration and if anybody needs it I'm adding the code below, all you need to do is paste it into  Trigger - JSON Body in Zendesk trigger:

     

    { "attachments": [
    {"text": "{{ticket.status}} Ticket from {{ticket.requester.name}} : <https://chainbytes.zendesk.com/agent/tickets/{{ticket.id}}|Ticket#{{ticket.id}}>\n <https://chainbytes.zendesk.com/agent/tickets/{{ticket.id}}|*{{ticket.title}}*>.\n {{ticket.latest_public_comment}}\n Status : <https://chainbytes.zendesk.com/agent/tickets/{{ticket.id}}|{{ticket.status}}>\n Assigned to agent : {{ticket.assignee.name}} "
    } ]
    }

     


    And here is how it will look like:



    What I want to do is to change the color of the attachment line (which is currently grey) as per ticket status to match the Zendesk colors for New, Open, Hold, Pending. But I have no idea how to do that. 

    Can someone help me with how to change the above grey line from Gray to Yellow for New ticket and Red for Open. I guess I need to create separate triggers for every Staus and add code that will display the color as I need it, and that's ok.
    But can anyone help me with what code I would need to add to the one I already have above to assign the color to that attachment line to be for example Yellow? 

    1
  • Dan Ross
    Community Moderator

    Hey @...

    You can do that in two ways, you can either have a trigger for each status and have a different message setup for each trigger, or you can do it in one trigger using Liquid Markup that tests for the status and then if it meets a condition, send a different message. The latter is more complex to setup but reduces the total number of triggers required. 

    In either case, the attribute you need to set on the Slack message is the attribute for  `color` and then set a hex code color. Some Zendesk colours and the hex codes for them are found here. Some words also work in place of hex codes, like 'good' (for green), 'warning' (yellow), and 'danger' (red), but a hex code offers most control.

    You can also break up the layout a bit without needing to format a /n linebreak if you use the Attachments message structure. Sample of the Attachments layout can be found in Slack's docs here

    Here's an example below!

    {  
    "channel": "#YOURCHANNEL or @USERID",
    "icon_emoji": ":EMOJI:",
    "username": "Zendesk Operators",

    "attachments":
    [
    {
    "fallback":"Ticket from {{ticket.requester.name}}",
    "pretext": "Ticket from {{ticket.requester.name}}",
    "title": "Click To Open Ticket",
    "title_link": "{{ticket.link}}",
    "color": "#2eb886",
    "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": "Last Public Comment",
    "value": "{{ticket.latest_public_comment}}",
    "short": false
    }
    ]
    }
    ]
    }

     

     

     

    1
  • Mirek Kokeš

    Hi @... team,

    Right now, we have one brand (A) in our Zendesk account and there is a Slack/Zendesk integration, which provides details about tickets, see here

    We are about to set up a new additional brand in our Zendesk (B) and we would like to differentiate in Slack between tickets coming from those brands:

    • Zendesk ticket brand=A -> Slack channel e.g. #A-brand
    • Zendesk ticket brand=B -> Slack channel e.g. #B-brand

    Is it possible to set this up? If yes, can you please provide more information?

    Thanks

    Mirek

    0
  • Jacob Johst Christensen

    Hi @...

    That should be doable. You would need an HTTP target for each of your Slack channels, and a trigger for each of your brands - specifying the conditions under which you want to push a message, e.g. if Ticket is created + Brand is A, then notify target A (your HTTP target for the Brand A channel).

    Let me know if you need more details than that - hope this helps!

    0
  • Lea Jane Hug

    Hey @... That worked perfectly!
    I created separate triggers for every status change, assigned "zendesk colors" to every status, and adjusted it a bit to give us the info we needed. And it's really good, I cant tell the difference from the native integration. Thank you so much!

    One difference is that i cant make it show "Read more" for placeholder: 

    "{{ticket.latest_public_comment}}"


    It keeps showing the entire response (which including the signature is a bit overwhelming at times), do you have any idea how to make it short and add read more for expanding to the entire comment?  

    0
  • Bobby Koch

    Hey team, 

    Is there a way to make this target work for a private channel? 

    I have this json. When it points to csewiki it breaks (private channel). But if I add in the text for a public channel, it works. Note my code is cut off. Curious if there is another parameter I should be passing. 

     

    {
    "channel": "csewiki",
    "attachments":
    [
    {
    "pretext": "{{ticket.status}} {{ticket.ticket_type}} update by *{{current_user.name}}*:",
    "fallback": "{{ticket.status}} {{ticket.ticket_type}} #{{ticket.id}} has been updated at {{ticket.upd

    0
  • Hervin Centeno
    Hi Bobby,

    I've looked into this a bit and it all may depend! If you had recently created the private channel or recently converted a public channel to a private one, that sadly isn't compatible with our Slack integration currently. I apologize for this limitation. If the channel you're working on does not meet those criteria, please let us know so we can take a deeper dive into what may be happening in your account.
     
    Thanks!
    0

Please sign in to leave a comment.

Powered by Zendesk