Engineer's Blog

Engineer's Blog

Refine search

Intro to BLOCKS features #1: Slack notices

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.

Big Data Board screen

Big Data Board editor screen

 

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.

Start of Flow

Start of Flow BLOCK

 

The Start of Flow BLOCK should be placed on your editor as below:

Placed Start of Flow BLOCK

A placed Start of Flow BLOCK

 

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.

Displaying BLOCK properties

Displaying BLOCK properties

 

This opens up the BLOCK properties menu.

BLOCK properties menu

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:

* * * * *

Start time setting

Property settings

Property settings

 

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.

Slack Notice BLOCK

Placing the Slack Notice BLOCK

 

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.

  1. Webhook URL
  2. Channel
  3. Message
Slack Notice BLOCK properties

The Slack Notice BLOCK’s properties

 

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:

https://TEAMNAME.slack.com/home

Slack home screen

The Slack home screen

 

Click the Add Configuration button.

Configurations

Configurations

 

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.

Post to Channel menu

The Post to Channel menu

 

Once you’ve selected a channel, click the “Add Incoming WebHooks integration” button that should have turned green.

Add Incoming Webhooks

The Add Incoming Webhooks button

 

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.

Webhook URL

The Webhook URL

 

2. Channel

Enter the name of the channel that you used to set up the WebHook URL (where messages will be sent).

3. Message

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.

Manual Flow Execution

Executing a Flow once

 

The results of executing the Flow will be stored into the logs section.

Execution results

A log from executing the Flow

 

Once you’ve confirmed that the Flow executed successfully, take a look at Slack to see your new message.

Slack results

The message on Slack

 

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.

Auto-execution schedule

Enabling the auto-execution schedule

 

The Flow should now be executing each minute. Results of each execution are recorded into the logs.

Auto-execute results

Logs of the auto-execution results

 

We can also take a look at Slack to confirm that messages are being sent each minute.

Auto-execute Slack results

Results of auto-execution in Slack

 

To stop the Flow from continuing to execute, uncheck “Activating start times” and save once more.