I've tried to send a message with @channel, @here and @user, but they are sent as text.
This is the code....
import os
from slack import WebClient
from slack.errors import SlackApiError
client = WebClient(token='xoxb-**************************')
try:
response = client.chat_postMessage(
channel='#prueba',
text="@channel Hello world!",
as_user=False)
assert response["message"]["text"] == "Hello world!"
except SlackApiError as e:
# You will get a SlackApiError if "ok" is False
assert e.response["ok"] is False
assert e.response["error"] # str like 'invalid_auth', 'channel_not_found'
print(f"Got an error: {e.response['error']}")
I've read both PythonSlackclient Docs and the API Docs, but I don't find an option to broadcast my messages or how to mention someone.
You need to change your code to
response = client.chat_postMessage(
channel='#prueba',
text="<!channel> Hello world!",
as_user=False)
assert response["message"]["text"] == "@channel Hello world!"
Slack API has one of the best documentations, to get started with linking users read this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With