Slack Incoming Webhook sends as my user

后端 未结 2 2034
無奈伤痛
無奈伤痛 2020-12-21 04:39

I\'ve created an Incoming Webhook within my Slack workspace. I\'m using it from a third party tool to post a JSON object to the hook url. I want to send a notification to

相关标签:
2条回答
  • 2020-12-21 05:07

    For webhook-based direct messages, prefix the Slack user's ID with an '@' in the payload:

    { 
       "text": "This is a line of text in a channel.",
       "channel": "@U1A2B3C4D"
    }
    

    Note that such messages will appear to have been posted by Slackbot. Also note that you can actually use any active webhook for direct messaging regardless of the channel that the webhook was defined for.

    0 讨论(0)
  • 2020-12-21 05:11

    This seams to be standard behavior when setting up a webhook through a Slack app.

    But there is an alternative approach: You can also set up incoming webhooks as custom integration. Then you are then able to send messages to the slackbot channel of a user.

    To setup a webhook as a custom integration go to Slack App Directory and add the app "Incoming Webhook". Then create a new webhook. You can either directly use the ID of the destination user as channel in the initial configuration, or use the channel override feature by including a channel property in the message.

    Example:

    { 
       "text": "This is a line of text in a channel.",
       "channel": "U12345678"
    }
    
    0 讨论(0)
提交回复
热议问题