How to automatically trigger a workflow with form data

Published on

By Peter Hilton

Signavio Workflow users typically start executing workflows manually, by clicking a Start new case button, and entering initial data on a trigger form. However, sometimes you want another system, such as a company’s public website, to trigger a workflow. This Signavio Workflow tutorial shows you how to set this up by using email to automatically start cases in a workflow.

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.

Website platforms can generally also send email, so you should be able to integrate this kind of simple contact form with Signavio Workflow by processing the contact form and sending its contents to Signavio Workflow 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. 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 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 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.

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

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”,
“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.

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.

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

To try this for yourself, sign up for a free 30-day trial of Signavio Workflow.