Vinayak Pandey
Vinayak Pandey

Reputation: 141

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.

Upvotes: 0

Views: 2384

Answers (1)

anoop-khandelwal
anoop-khandelwal

Reputation: 3860

use < !channel >

Also , check this

I have done this here put json as

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

you will get

 Hello @channel 

Upvotes: 3

Related Questions