Note: You are looking at a static snapshot of documentation related to Robot Framework automations. The most recent documentation is at https://robocorp.com/docs

How to send messages to Slack from your software robots

You can easily send messages to a channel in your Slack workspace from your robots using the RPA.Notifier library.

Set up your Slack workspace to accept incoming webhooks

  1. In your Slack, select "Apps", find the Incoming WebHooks app, and add it to your workspace: Add the Incoming WebHooks App in Slack
  2. Select the channel where the webhook will post messages to: Choose webhook channel
  3. In the configuration page for the app, take note of the Webhook URL: Get the webhooks URL
  4. Done!

Robot example code

*** Settings *** Documentation Send messages to Slack. Library RPA.Notifier *** Variables *** ${SLACK_WEBHOOK_URL} https://hooks.slack.com/services/xxxx/xxxx/xxxx ${CHANNEL} general *** Tasks *** Send a message to a Slack channel Notify Slack ... Hello from the robot! ... channel=${CHANNEL} ... webhook_url=${SLACK_WEBHOOK_URL}

Robot code explained

  • We added the RPA.Notifier library in the *** Settings *** section.
  • We set the ${SLACK_WEBHOOK_URL} variable with the Webhook URL we got from Slack.

    NOTE: You should not use the webhook URL directly in your code. This is a good use case for the Vault feature of Control Room.

  • We set the ${CHANNEL} variable with the name of the channel we want to send the message to.

    NOTE: even if the Incoming Webhook app needs to be added to a specific channel, you can enter any public channel here.

  • We added a new task: Send a message to a Slack channel.
  • In our task, we used the Notify Slack keyword from the RPA.Notifier library, passing it the text of the message, our channel variable, and the webhook URL as arguments.

Running the robot sends the message to the channel in Slack.

See the sent message in the Slack channel

Last edit: June 30, 2021