简体   繁体   中英

Personal notifications in slack messages sent by Python bot are not highlighted

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM