Links

Send message

Tags: #slack #message #send #operations #snippet
Author: Florent Ravenel
Description: This notebook allows you to quickly and easily send messages through Slack.

Input

Import needed library

from naas_drivers import slack

Setup Slack

  • Create Slack App
  • Add OAuth & Permissions(chat:write, chat:write.public to send message in a public channel)
  • Install your App
  • Get your Bot Token
SLACK_TOKEN = "xoxb-XXXXXXXXXXXXXXXXXXXXXXX"
SLACK_CHANNEL = "channel-name"
SLACK_MESSAGE = "Hello World!"

Model

Connect to Slack

SLACK = slack.connect(SLACK_TOKEN)

Output

Send your message

SLACK.send(SLACK_CHANNEL, SLACK_MESSAGE)