Workflow triggered by email

Introduction

An email-triggered workflow automates actions when an email is received in a designated in app inbox. By default, the application can receive emails at any inbox formatted as inbox@myapp.octopus-esm.com, where "inbox" can be replaced with any word. In this case, the goal is to automate Ticket creation based on specific keywords in the subject and body of emails sent to support@myapp.octopus-esm.com.

Step-by-Step Instructions

1. Configure an Incoming Email Workflow

First, an incoming email workflow must be created, and its email trigger must be set in the support inbox. This ensures that only emails sent to support@myapp.octopus-esm.com will trigger the workflow. However, the configuration allows for any inbox or even all incoming emails to be used as triggers.

The workflow will only be triggered by emails received to the support inbox, but you can put any inbox you want to send emails to or select *(all incoming mails)

2. Automate High-Priority Incident Ticket Creation

In this example, the goal is to automate the creation of a high-priority incident ticket. The following is an example of an email received in the support inbox that triggers the workflow.  

If the email body contains the word "urgent" and the subject includes the word "incident" (both case-insensitive), the system will create a ticket for the type of incident with high priority. The ticket's subject and description will be directly extracted from the subject and body of the received email.

To properly process the files attached to emails received in the support inbox, an entity File needs to be created, with the fields id, name, mimeType, and size.

A parameter called emailFiles of type File must also be created for the create Ticket command. This parameter will store the attached files from the received email. The workflow processes attachments using the following mutation:

return emailFiles.map(f => ({

  ...f, _typename: 'File'

}))

Note: This create command is only available in the workflow and cannot be used in the UI.

A ticket of type incident with high priority, including a file containing a list of clients, has been created.

Note: the source.eml file contains the source email and is always included with our workflow data

3. Notify the Email Sender

Once the ticket is created, a notification is sent to the sender with details about the generated ticket. This ensures the sender is informed of the ticket's creation and its status.

Conclusion

By implementing this email-triggered workflow, ticket creation is fully automated based on predefined conditions. The system efficiently processes email content and attachments, reducing manual intervention while ensuring prompt ticket generation and sender notification.