How to post message to particular Slack channer or user using Slack integration Endpoint.

2 댓글

  • Jiri Kanicky

    I figured out that I can create new Slack app and configure it in the way that I can use the JSON payload to instruct the message which channel it should go.

    The problem I have now is that Zendesk is not allowing me to set additional headers in Extensions.

    Is there any way to set different headers for the HTTP extension? This should be possible, but it seems, yet again, Zendesk has got everything hardcoded.

    Unfortunatelly there is no way to send API call to Slack without setting both headers.

    curl --request POST \

    --url https://slack.com/api/chat.postMessage \

    --header 'authorization: Bearer xoxb-0000000000000000000000000000000 \

    --header 'content-type: application/json' \

     

    I can share the whole solution, but without being able to set the hearders in "HTTP Target" Extension, it will be useless.

    0
  • Jiri Kanicky

    The solution is actually very simple.

    Create one webhook to any channel.

    Use the following to override the channel in the payload

    "channel": "#other-channel"

    Use the following to send the message to a specific user.

    "channel": "@username"

    example to send a message to a user Jiri Kanicky


    "channel":"@jiri.kanicky",
    "icon_emoji":":fire:",
    "blocks": [
    {
    "type": "section",
    "text": {
    "type": "mrkdwn",
    "text": "FRT SLA will breached soon on ticket! Please take ownership and respond to the customer as soon as possible. Also please acknowledge the message here that everyone knows you are handling the issue"
    }
    },
    {
    "type": "divider"
    },
    {
    "type": "section",
    "fields": [
    {
    "type": "mrkdwn",
    "text": "*Ticket #:*\n{{ticket.id}}"
    },
    {
    "type": "mrkdwn",
    "text": "*Organization:*\n{{user.organization.id}}"
    },
    {
    "type": "mrkdwn",
    "text": "*Status:*\n{{ticket.status}}"
    },
    {
    "type": "mrkdwn",
    "text": "*Created:*\n{{ticket.created_at_with_time}}"
    },
    {
    "type": "mrkdwn",
    "text": "*Subject:*\n{{ticket.title}}"
    }
    ]
    },
    {
    "type": "actions",
    "elements": [
    {
    "type": "button",
    "text": {
    "type": "plain_text",
    "text": "Open Zendesk Ticket"
    },
    "url": "{{ticket.link}}"
    }
    ]
    }
    ]
    }

     

    Why is it useful?

    Basically, you don't have to create new webhooks for your channels or your users. You can simply use the payload in the Triggers or Automation to send notifications to any channel you want with one Extention configured.

    Moreover, you can set dynamic payload for users. Example:

    "channel": "@{{user.name}}" or use custom field which matches the Slack username.

     

     

    0

댓글을 남기려면 로그인하세요.

Zendesk 제공