After designing and configuring a form in Miracle Studio, it's time for you to create a workflow in MS Flow. If you haven't already, sign up for the service on https://flow.microsoft.com. There are three pricing plans which you can choose them. For the purpose of this tutorial, we chose the Free plan.
For more information and a detailed documentation of Microsoft Flow, please click here.
To create a workflow for processing orders, you need to create the following flows to streamline the process.
Flow 1: Create a Task When a Row is Inserted in the Microsoft SQL Table
- Under the My Flows section, select "Create from blank". You can also choose "Create from Template" and use a pre-defined template. For the sake of this example, we chose a blank flow.
- To add a trigger, search for "SQL", and then select SQL Server.
- A new flow will open with the SQL trigger "When an item is created" selected. Enter your database server credentials and select the database table on which a flow will initiate when a row is inserted.
- Click on the "New Step" button, followed by "Add an action". Search for "Miracle Task".
- Select the "Miracle Task Connector - Create Task" action and enter the information required according to your app's settings. You can use the example below as a point of reference. Leave the "WebhookURL" field empty for now.
- Again, click on "New Step" and select "Add an action".
- Search for "SQL Server" and select "SQL Server - Update Row"
With these steps, you are creating a workflow for the following scenario:
- A Site Supervisor enters a new order requisition.
- This new order requisition inserts a new row in a table.
- A flow is created, one that's triggered after a new row is inserted in a table.
- When an order row is inserted in the table, a new task is created and assigned it to the Project Manager.
- Now, the record will update with the task ID created in the previous step.
When a task created in the previous flow is approved or rejected, the webhook callback URL will be called, initiating a new configured Microsoft Flow.
The above flow initiates when a its webhook URL is being called with the task information as a JSON.
Flow 2: Initiate to Check Whether a Task was Approved or Rejected, and Create Another Task and Assign it to Respective Users
For this flow, we need to first add an HTTP request receiving trigger.
- Create a blank flow and search for "http request". Select "Request - When a HTTP request is received" trigger as show below.
- Enter the required JSON code to receive task information which was approved, rejected or completed.
- Click save and a URL will generate in the HTTP POST URL field.
- Copy that URL and paste it in the task action defined in the previous flow.
- Save the previous flow.
- Next, we need to add a condition.
- Click on "New step" and "Add a condition". In condition, enter values as shown below:
- To define the flows for "Yes" and "No" branch, add an "Apply to each" action in each branch and add actions as shown below. You can add the "Create Task" action by searching "Miracle Task" in the action window.
The flow you create should look something like this.
Flow 3: Send an Email when a Task is Completed
For this flow, first add an HTTP Request received trigger and configure it as described in the previous flow. Once you're done, follow the steps below.
- Search for send email action such as Gmail, and save it.
With these three flows, you are now ready to use workflows in Miracle Mobile App.