问题
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 on the mybot app.
I am using the python slack-client
.
Using below code to send the message:
user_id="<touser>"
im_channel=self.open_dm(user_id)
slack_client.api_call("chat.postMessage",channel=im_channel,text="hi buddy", as_user=True)
The above code posts the message in the myapp app channel. Is there a way for the bot to send the message directly to the user and not in the app channel?
OR
Is there a way for the myapp
bot to send to slackbot
channel addressing the user?
回答1:
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.
来源:https://stackoverflow.com/questions/53759484/send-direct-message-to-slack-user-from-a-app-bot-but-not-in-app-channel