How to send direct messages to a user as app in app channel

后端 未结 2 1526
名媛妹妹
名媛妹妹 2020-11-27 19:46

How is it possible to send message in slack directly to the user, by user.id as application.

this application has scope: bot,channels:write,emoji:read,users:read,us

2条回答
  •  旧时难觅i
    2020-11-27 20:18

    If I understand your question correctly, you want to send direct messages to users in the app channel instead of the standard slackbot channel.

    In order to do that you need to

    1. Your app needs the bot scope and a bot user
    2. Open a direct message channel from your app with the user with im.open. You get back a direct message ID.
    3. Send a message with chat.postMessage to the the direct message channel ID

    Make sure to use your bot access token (not the user access token) from your Slack app.

    The bot scope gives you all permissions needed to open and send DMs to users from your bot channel. No other scopes are required.

    You can also use the new conversations methods, which work for all kind of channel types to do the same.

    See also this question on the same topic.

提交回复
热议问题