Using an email trigger to trigger a workflow

The earlier article about responding to customer email enquiries describes a workflow that helps a customer contact team respond to email from customers. In this scenario, customers send email to info@example.com that, in turn, starts a new case of a Respond to customer enquiry process.

Automatically trigger a workflow like this ‘Respond to customer enquiry’ process diagramm

This example assumes that the customer sends their enquiry by email. In practice, however, a customer contact team supports a number of communication channels. A typical alternative to email, is to use a simple web page contact form.

Customer enquiry form- window screen

Website platforms can generally also send email, so you should be able to integrate this kind of simple contact form with Signavio Workflow Accelerator by processing the contact form and sending its contents to Signavio Workflow Accelerator in an email that will trigger a workflow, via an email trigger.

Reading trigger email contents

In the Respond to customer enquiry process, the Write response task can display the email content in the form.

‘Write response’ user task form screen

You don’t have to do any extra setup to do this in Signavio Workflow Accelerator. In the form builder, you can select Trigger email / Body text and add it to the form as a read-only field, as in this example.

The case in Signavio Workflow Accelerator shows the contact form information as the trigger email contents, as well as the tasks for responding to the customer. The contact form works the same way as if the customer sent an email, so the process model in Signavio Workflow Accelerator didn’t require any changes. It gets more complex when the contact form has multiple fields.

Using JSON for structured form data

Customer contact forms sometimes include additional fields, such as an option to select a specific product.

Customer enquiry form with an additional field screen

When the customer specifies a product, the Respond to customer enquiry process can route the enquiry to product-specific tasks, assigned to different people.

Adding a product-specific task- diagram screen

This requires a script task that sets a process variable to the value of the Product pick list on the contact form. To make this work, the website that sends the email should encode the form using JSON:

{
  "product" : "Signavio Workflow Accelerator ",
  "enquiry" : "Is it available in French?"
}

This separates the values of the two enquiry form fields so that the script task can extract the product value.

Script task configuration - screenshot

This script introduces a new Product variable, and sets its value to the product field from the enquiry form. The script obtains the enquiry form by parsing its JSON representation from the trigger email body text.

Note that the lack of error handling code means that invalid JSON will cause the script task to fail when executing the case, which will halt the workflow. To continue without setting the product value, wrap the code in try-catch statements.

The exclusive gateway can now use the value of the Product variable to route the case to the product-specific task.

Exclusive gateway configuration screenshot

The result is a process that you can trigger asynchronously from an external system, via email, including structured data in JSON format.

Published on: November 25th 2016 - Last modified: February 21st, 2018