简体   繁体   中英

Send a Slack message to a user on a channel using Python

I am using Slack real time messaging API with Python and want to send a message to a user on a channel, using@ like @hellobot create a directory test2002.

The given code doesn't work:

slack_client.api_call("chat.postMessage", channel='#bot',text="create directory test2002",username='ecstesting1989')

If I use:

slack_client.api_call("chat.postMessage", channel='#bot',text="@hellobot create directory test2002",username='ecstesting1989')

This sends the command as @hellobot create directory test2002 in text format and doesn't work.

use < !channel >

Also , check this

I have done this here put json as

 {
   "text": "Hello <!channel|>"
 }

you will get

 Hello @channel 

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