Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
minLevel2
maxLevel27
typeflat

Description

The flow shown below is an example of data injection. After having transformed our data passing through an external web service (RandomUser.me) and several components which act as data formatting, the data will be written into and read from a Devo table. Then, a second sub-flow will get the data from the injected table, configure it, and send the results via Slack.

...

Uni type and description

Configuration

DevoSource

This unit will read the data from the my.app table where we injected the events.

Drag a DevoSource unit to the canvas and open its configuration options by double-clicking it.

Enter a Name for the unit (in this example, readFromDevo)and check off for the Check DB configuration field. In the Query field, enter the query from which you want to get data. In this example, we will use the following:

Code Block
from my.app.test
where format = "simpleetl"
select *

Also, you can optionally choose a Start time for the query.

Click Apply to save the configuration.

Map

We will use this unit to get the information we want to send through Slack and format it as required.

Drag a Map unit to the canvas and link the output port data of the DevoSource unit to the input port of this unit.

Then, open the configuration options of the unit by double-clicking it. In the General tab, simply add a name to the unit (in this example, we called it messageToEvent).

Now go to the Fields to add tab. Click the + icon in the fields section to add 6 new columns to the events sent, including the required format we will use to send the messages through Slack:

Column 1

  • Field name all

  • Type - java.lang.String[]

  • Expression - This is the expression that defines the new column:

Code Block
message.split("\\^\\^#\\|")

Column 2

  • Field name - country

  • Type - String

  • Expression - This is the expression that defines the new column:

Code Block
all[1].split("=")[1]

Column 3

  • Field name - city

  • Type - String

  • Expression - This is the expression that defines the new column:

Code Block
all[3].split("=")[1]

Column 4

  • Field name - surname

  • Type - String

  • Expression - This is the expression that defines the new column:

Code Block
all[4].split("=")[1]

Column 5

  • Field name - name

  • Type - String

  • Expression - This is the expression that defines the new column:

Code Block
all[5].split("=")[1]

Column 6

  • Field name - gender

  • Type - String

  • Expression - This is the expression that defines the new column:

Code Block
def g = all[2].split("=")[1]
if (g.equals("male"))
	return "him"
else 
  	return "her"

Click Apply to save the configuration.

SlackSink

The Slack Sink unit sends a Slack message to a configurable channel. 

Drag a SlackSink unit to the canvas and link the output port out of the Map unit to the input port of this unit.

Then, open the configuration options of the unit by double-clicking it and enter the following information:

  • Name - Add a name to the unit (in this example, we called it sendToSlack).

  • Message - This is the message that will be sent to the specified Slack channel. In this example, we will include the following message, referencing the fields defined in the previous unit:
    Dear Devos
    %%﹛name﹜%%﹛surname﹜from %%﹛city﹜in %%﹛country﹜has been added to your system!
    Please join me to welcome %%﹛gender﹜

  • Slack WebHook - Enter the Slack Webhook that references the required Slack workspace and channel where the messages will be sent. Learn more about Slack Webhooks and how to use them here.

Click Apply to save the configuration.

Result

Once you have defined the whole Flow, click the Start button to activate it and click the first unit (Tick). If everything is correctly configured, the Slack channel specified in the SlackSink unit through the corresponding Webhook will receive a notification indicating the user info for generated in the my.app table indicated.

...