How to: Use the K2 Workflow REST API with Microsoft Flow to Redirect a K2 Task
This is preview functionality. For more information see the Preview topic.
Exposing K2 workflow data through the Workflow REST API provides powerful integration with third party tools like Microsoft Flow. This topic shows you how to use the service to redirect a Task when that Task email arrives in an Outlook folder
These links take you directly to the scenarios. Make sure to read the Before you Begin section before following the steps in the scenarios:
Scenario - How to redirect a workflow Task in Microsoft Flow using an Outlook trigger
Before You Begin
If you have not done so already,
- Enable the Workflow REST API in the K2 Management site. See Configuring the Workflow REST Service for more information about enabling the API.
- Create a custom connector to the K2 Workflow REST API in Microsoft Flow. See Create a custom connector in Microsoft Flow to call the K2 Workflow REST API for more information.
Scenario - How to redirect a workflow Task in Microsoft Flow using an Outlook trigger
In this scenario, you create a blank Microsoft Flow and configure it to start a K2 workflow when a K2 Task email is sent to a folder in Outlook, in this case a leave request email gets routed to the Leave Tasks folder in the HR inbox using an Outlook rule.
The workflow has been configured to send a custom notification that sets the email Subject to the serial number of the task. This is what Flow will use to identify which task gets redirected. In the subject of the notification email of the task within your workflow definition, use the taskSerial Number field from the Workflow Context of the Context Browser within a Replace Inline Function to remove the SN= portion of the serial number object. Flow just needs the actual number.
High level steps
- Create a blank flow.
- Use the Outlook.com – When a new email arrives trigger.
- Select the K2 Workflow - Get Task action as the first step of the action, configuring it to use the Subject of the email to provide the serial number
- Set the K2 Workflow - Redirect Tasks action as the second step, specifying the person the task is redirected to
- Save your flow.
- Run your flow.
Detailed steps
- Open Microsoft Flow
- Click Create from blank
- From the Start with one of these popular triggers page select When a new email arrives
- If prompted, sign in to Outlook.com.
- Select the folder. In this example it is the Leave Tasks folder. Outlook has an email rule that examines the body of an email for the words "Leave Request Task" and then moves that email into this folder.
- Click + New Step
- Search for the K2 custom connector you created. Click K2 Workflow – Get Task action
- From the Dynamic content tab select the email Subject
to set the task serial number
- Click + New step .
- Search for the K2 actions. Select Redirect Task
- Click theSerial Numbertext box and select the Task Serial Number field from the Dynamic content tab
- Select theRedirect Informationtext box and type the email address of the person that this task is redirected to.
- Click Save flow
- You see a message stating your flow was created.
- Test the flow you created by starting the workflow. The task notification email (with the serial number of the task as the Subject) will arrive in the inbox and be routed to the Leave Tasks folder. That starts the flow and the task is redirected to the person configured in the Redirect Information text box.