In the previous article we introduced the simple story. In this article we will expand that story by adding an additional action.

In the simple story, we created an automation story that sends a HTTP POST request when an alert is related to an infection and the affected user’s job is CEO. In this article we will expand the story by sending an email when the user’s job is “engineer”.

Creating an email action

On the storyboard page, drag an email action from the library panel and drop it onto the storyboard.

Creating a new action
Creating a new action

Setting the source action

Next we need to define from where our new email action should receive events. We do this by linking them together. From the icon on the User is engineer action, drag the link into the new Email action action.

Setting a source action
Setting a source action

Configuring the action

On the right hand side of the storyboard page is the Action Properties Panel. Here we can configure how the action should perform.

Action properties
Action properties

Editing the options block

In the options block, at the bottom of the properties panel, we will configure the granular operation of the action. For an Email Action, there are a number of options we can specify:

  • recipients: Include an email address (or an array of email addresses) to whom the email should be sent. Each recipient will receive an individual email.
  • subject: Include a subject for the email. Include information from upstream events by specifying the key.
  • body: (Optional) Customize the body of the email. Include information from upstream events by specifying the JSONPath (examples below). The body can contain simple HTML and will be sanitized. When using body, it will be wrapped with <html> and <body> tags, so these do not need to be added.

For our Email action we will use the following options block:


{
  "recipients": "tinesdemouser@outlook.com",
  "subject": "Engineer in infected",
  "body": "Hello,<br/><br/>An alert has been detected that relates to an infected engineer. The user's details are shown below:<br/><b>Name:</b> {{.explode_users.user.name}}<br/><b>Age:</b> {{.explode_users.user.age}}<br/><b>Country:</b> {{.explode_users.user.country}}<br/><br/>Thanks!"
}

API Autocomplete

When editing or creating an action, ‘API Autocomplete’ allows you to more easily define JSONPaths in the options block. When a source action is linked and two sets of curly braces are entered into a field with a period, ({{ . }} ), Tines will provide a list of available keys from the most recent event emitted by that linked source action. When a key is selected and another period is pressed, Tines will present the keys from the most recent event at that level.

API Autocomplete in options block
API Autocomplete in options block

Testing the Action

There is now a new action ready to receive events from the “User is engineer” action (shown below).

Simple story with new action
Simple story with new action

To test that this action is working as expected, we can “reemit” an event from the “User is engineer” events page.

Reemit an event
Reemit an event

Viewing the events emitted by our new “Notify by email” action, we can see that the action ran and successfully emitted an event similar to the following. The corresponding email is also shown below.

Emitted event
Emitted event
Received email
Received email