biao
biao

Reputation: 321

How to post formatted message into a channel with Slack API

I have a json formatted message like this, I want to post this message into Slack with Slack postMessage API. Pasting the json string into text section would not work, how/where should I input that?

Thanks

Upvotes: 1

Views: 5042

Answers (1)

Steven T
Steven T

Reputation: 93

Using the link you posted, you'll need to generate an API token for your slack account. After that, choose a channel to post the message and put

*bold* `code` _italic_ ~strike~

next to the "text" field. The message should be posted in your slack channel.

Since you're using python, you can use the python slack api to do this. The code would then be

from slackclient import SlackClient
slack_client = SlackClient(API TOKEN)
slack_client.api_call("chat.postMessage", channel=CHANNEL ID, text="*bold* `code` _italic_ ~strike~", as_user=True)

Upvotes: 3

Related Questions