Groovenauts engineer, Kai, here!
We’ll be introducing various features of MAGELLAN BLOCKS in this section of the blog. Today I’ll focus on the Slack Notice BLOCK.
What’s a Slack notice?
There are two BLOCKS capable of sending messages to Slack (a popular team messaging app): the Slack Notice BLOCK and the BigQuery Slack Notice BLOCK.
You can use these BLOCKS to send messages or data from BigQuery tables to Slack.
Let’s make a Flow with a Slack Notice BLOCK
For today’s example, we’ll make a Flow that uses the Slack Notice BLOCK to send a message to Slack every minute. This will also give us an opportunity to run through the basics of making Flows.
Self-Service Plan users: You’ll need to prepare your GCP (Google Cloud Platform) account and link it to BLOCKS before you can create Flows. Refer to Getting started with GCP #1 for details on how to do this.
Placing BLOCKS and making Flows
With that, let’s sign into BLOCKSand start making a Flow on a Big Data Board.
The BLOCKS list, which contains all of the BLOCKS you can use to make Flows, is located on the left side of the editor. The Basic category is selected by default.
To start, select a Start of Flow BLOCK and drag it onto the editing screen.
The Start of Flow BLOCK should be placed on your editor as below:
Now we’ll configure the properties of the BLOCK we just placed. Select the BLOCK and click the tab on the right side of the screen.
This opens up the BLOCK properties menu.
Since we want to send a message to Slack every minute, we’ll configure our Flow to execute on a regular schedule. This is done within the BLOCK properties menu of the Start of Flow BLOCK.
You should find a property called “Start time” where you can configure a schedule for the Flow to follow. We’ll input this schedule using the crontab format. The following crontab command will make our Flow execute every minute:
Next we’ll add a Slack Notice BLOCK to our Flow. This BLOCK takes care of actually sending messages to Slack.
First, select the Slack Notice BLOCK from the Basic category of the BLOCK list. Then, drag and drop it onto the Start of Flow BLOCK to connect them.
Open the BLOCK properties menu of the Slack notification BLOCK. We’ll need to edit the following properties for the BLOCK to be able to send a message to Slack. The BLOCK will run fine with the other properties left at their default settings, so we’ll ignore those for now.
- Webhook URL
1. Webhook URL
First, you’ll need to get a WebHook URL for the Slack channel you want to BLOCKS to send messages to. Do this from your Slack team’s home screen.
Use the following URL to access your team’s home screen and click the Incoming WebHooks link towards the bottom of the page:
Click the Add Configuration button.
In the “Post to Channel” section, select the channel you want messages sent to by typing its name or choosing it from the drop down. We’re using a channel named blocks_demo for this guide.
Once you’ve selected a channel, click the “Add Incoming WebHooks integration” button that should have turned green.
And with that, we’ve gotten the Webhook URL we’ll need for BLOCKS. Copy this URL into the Webhooks URL property of the Slack Notice BLOCK.
Enter the name of the channel that you used to set up the WebHook URL (where messages will be sent).
Enter the message that will be sent to Slack.
Finally, take an End of Flow BLOCK and connect it to the Slack notification BLOCK.
Testing the Flow once
Let’s try executing our Flow once to make sure it can send a message to Slack. First, save the Board using the Save button in the upper-right of the screen. Then, open the Start of Flow BLOCK’s properties and click the “Execute Flow” button.
The results of executing the Flow will be stored into the logs section.
Once you’ve confirmed that the Flow executed successfully, take a look at Slack to see your new message.
Running the Flow on a timed schedule
Now that we know our Flow can send messages to Slack, let’s try scheduling it to send a message every minute. To do this, just click the “Activating start times” checkbox and save.
The Flow should now be executing each minute. Results of each execution are recorded into the logs.
We can also take a look at Slack to confirm that messages are being sent each minute.
To stop the Flow from continuing to execute, uncheck “Activating start times” and save once more.