I created a small test bot connecting a local python script with Slack. The main task of the bot is to create a custom string, and send it to a channel in Slack. This is done with
from slack_sdk import WebClient
client = WebClient(token = slack_token)
slack_message = "Hello @demo_user" # @demo_user is an existing user, which can be mentioned in chat
client.chat_postMessage(channel = channel_ID, text = slack_message)
In this message I would like to explicitly mention certain groups or persons by using @<username>
. This works fine if I type out the message directly in Slack, but if the bot itself sends the message, the groups are not messaged/pinged, even though the message contains the corresponding handle. What is happening here, and how can I ping those people/groups instead via Python?
I'm using the Slack API with NodeJS, but it might come from the link_names argument. Did you try to set it to true?
https://api.slack.com/methods/chat.postMessage#arg_link_names