Sending notifications and updates via Slack will keep you and your co-workers informed on-time. To configure Slack events from your Ubidots App does require a small integration using the “Incoming WebHooks” app, which is powered by Slack. The Incoming WebHooks App is a simple way to post messages from Ubidots into Slack.
Follow the steps below to configure Slack events in order to keep your team informed.
Requirements
An Ubidots account.
A Slack account with the “incoming webhooks” option enabled. See "Sending messages using Incoming WebHooks".
1. Setup an Incoming Webhook in Slack
To ensure reliable delivery of Ubidots Slack Events to the correct Slack channel, follow these steps:
1. Go to the “apps” section of your Slack account and add "Incoming WebHooks" from the Slack App Directory. The URL to access a team's Slack channel APPS is:
https://CHANNEL_NAME.slack.com/apps
2. Next, click on "Add to Slack".
3. Select the channel or person that will be notified, or create a new channel.
4. Click on “Add Incoming WebHooks integration”
5. Copy the webhook URL, as it will be used later in your Ubidots event setup.
2. Create a new event
After setting up an incoming webhook in your Slack app, go to your Ubidots account, head to the “data” tab →"Events" and hover over the “+” button, located at the upper right corner of the screen, and create a conditional event, global event, or scheduled event depending on your needs.
Next, configure the event’s triggers with an AND/OR logic. For additional details on how to configure these triggers, head to their corresponding guides: value based, inactivity, geofence.
3. Configure the Slack action
1. Fill all the following fields:
To:
A #channel or an @individual team member that will receive the alert message.
Bot name:
Bot icon type:
Bot icon:
Either an emoji or the URL of the image.
Incoming webhook URL:
Paste the webhook URL that you copied before in Slack.
2. Customize the “active trigger” and the “back to normal” (optional) messages that will be sent to Slack.
By using the tag icon at the upper right corners of the “subject” and “message” fields you can easily add information such as device ID, timestamp, variable name, etc.
Note: By default, data inputs involving timestamps are sent in human-readable format (YYY-MM-DD HH:mm:ss TZ). If you'd rather attach UNIX epoch time in milliseconds, double-click on the data input and delete the text from the pipe symbol ("|") until the end, as shown below.
3. Optionally, enable the “repeat action” option if you want to set the variable multiple times while the event is triggered. You can choose how often and up to how many times the action will be repeated. There’s a limit of 50 action repetitions.
4. Click on “save” once you finish configuring the action and on “next”, unless you want to set up multiple actions.
5. After completing the action configuration you’ll proceed to the final step, the “settings” tab. There, you’ll name the event and give it a description (optional).
6. Another optional step is to use a tag on the event. This is a great tool to control what your end users see in your app. In this case, for instance, you could decide that your end user sees one event, but not another, using tags. Learn more about tags here.
7. Finally (unless the event you created is a scheduled event), determine the activity window in which the events should be executed. An event can have multiple active windows by clicking on the “+ add window button” and configuring them correspondingly. After finishing this, click on “save” and your event will be deployed.
Now you just have to wait for the next time that your data exceeds the threshold for the notification to appear in your Slack channel.