send direct message to slack user from a app bot but not in app channel

后端 未结 1 899
忘了有多久
忘了有多久 2021-01-16 05:13

Is there a way to send direct message to from a bot(myapp/user) to a user say xyz or to a user\'s slackbot. The message needs to appear against the user and not

相关标签:
1条回答
  • 2021-01-16 05:43

    Yes.

    Just send a message with the user ID for channel and it will appear in the slackbot channel of that user.

    Something like this:

    user_id="<touser>"
    slack_client.api_call("chat.postMessage",channel=user_id,text="hi buddy")
    

    However, note that every message on Slack must to use a channel that includes so called "direct messages". That is how Slack works.

    0 讨论(0)
提交回复
热议问题