I want to send a message to a client slack workspace member through a Slack bot.
The bot creator is not part of the client’s Slack workspace. I used the sharable URL option to get access to the client workspace. After confirmation from the client’s Slack admin, I received the bot token. I am using this token to send the message.
I set all the required scopes to send the message.
I am facing a weird issue: whenever I try to send a direct message (DM) to the client Slack members through the bot, it sends the message to its own DM instead.
For more information, I am able to list all the users of the client Slack workspace.
const webClient = new WebClient(
"xoxb-bot token"
);
const conversationResponse = await webClient.conversations.open({
users: "userID",
});
const messageResponse = await webClient.chat.postMessage({
channel: conversationResponse.channel.id,
text: "Hello from peakflo bot",
});
Response :
messageResponse {
ok: true,
channel: 'D078RF47X4P',
ts: '1719061250.486089',
message: {
user: 'U078ZD0KMFY',
type: 'message',
ts: '1719061250.486089',
bot_id: 'B079625GN9Y',
app_id: 'A079A5Y52F3',
text: 'Hello from peakflo bot',
team: 'T078UG9TAJH',
bot_profile: {
id: 'B079625GN9Y',
app_id: 'A079A5Y52F3',
name: 'peakflo_bot',
icons: [Object],
deleted: false,
updated: 1719042406,
team_id: 'T078UG9TAJH'
},
blocks: [ [Object] ]
},
response_metadata: {
scopes: [
'channels:join',
'channels:read',
'channels:write.invites',
'chat:write',
'files:write',
'groups:read',
'groups:write',
'im:write',
'mpim:write',
'users:read',
'im:read',
'mpim:read',
'users:read.email'
],
acceptedScopes: [ 'chat:write' ]
}
}
i am trying to send the message on client slack workspace without adding bot creator to client workspace
Tejas Thombare is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.