Ken Liu
Ken Liu

Reputation: 22914

Slack API: how do I tell if a message is coming from a single user private channel to my Slackbot?

How can I detect if a message is from a user who is chatting with my bot in a private channel (DM with only the bot) using the Event API?

Upvotes: 2

Views: 998

Answers (1)

Aswin Kumar K P
Aswin Kumar K P

Reputation: 1102

Check the first letter in the channel id. If it starts with D it is a DM channel. If it starts with C it is a public channel.

For example, D2AH456 is a DM channel, whereas C234F56 is a public #channel

Upvotes: 7

Related Questions