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

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 agent

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

Creating a new agent
Creating a new agent

Setting the source agent

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

Setting a source agent
Setting a source agent

Configuring the agent

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

Agent properties
Agent properties

Editing the options block

In the options block, at the bottom of the properties panel, we will configure the granular operation of the agent. For an Email Agent, 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 agent 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 agent, ‘API Autocomplete’ allows you to more easily define JSONPaths in the options block. When a source agent is defined 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 the defined source agent. 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 Agent

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

Simple story with new agent
Simple story with new agent

To test that this agent 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” Agent, we can see the agent ran and successfully emitted an event similar the below. The corresponding email is also shown below.

Emitted event
Emitted event
Received email
Received email