In part 1 of this blog post I’ve showed you the Power Automate Flow that created and sent the Actionable Message when a Playbook is launched from an Opportunity record. Now we need a receiving flow for processing the actions of the Actionable Messages.
Here is the overview of the receiving flow:
First we “secure” the trigger by turning on the schema validation and setting a trigger condition to check the host key from the headers:
@equals(triggerOutputs()[‘headers’]?[‘host’],’prod-14.westus.logic.azure.com’)
I use the following JSON schema to parse the properties:
{
"type": "object",
"properties": {
"taskId": {
"type": "string"
},
"response": {
"type": "string"
},
"reason": {
"type": "string"
},
"userName": {
"type": "string"
}
}
}
Then I initialize the variables to set the Originator id and Image URL for the response JSON.
The Condition will check if the reason is empty when the response is Rejected. If yes, then the response is an error (status code 406) with the message ‘Reason is required’.
If not, the related Task record is updated with the response and reason from the Actionable Message and the Status is set to Completed.
Because I’m lazy I just use the Get user profile (V2) action to get the display name of the user.
Then I use a Compose action to set the response for the Actionable Message with the code:
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"originator": "@{variables('Originator id')}",
"body": [
{
"type": "Image",
"separator": true,
"url": "@{variables('Image URL')}"
},
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"size": "Medium",
"weight": "Bolder",
"text": "Submitted response: @{triggerBody()?['response']}"
},
{
"type": "TextBlock",
"text": "Submitted by **@{outputs('Get_user_profile_(V2)')?['body/displayName']}** <<@{triggerBody()?['userName']}>>",
"wrap": true
}
]
}
]
}
The Outputs is added to the Body of the Response action with the headers key to update the card.
Now when I go back to the Actionable Message that was sent, first I test the check on the reason in case of Rejected. Yes, that works.
So when I enter a reason and submit, the card gets updated.
The Playbook will show the tasks that were updated and completed. In this way the progress can be tracked of all activities.
When all activities are completed the Playbook can be completed based on the response.
Now the formal response on the request for commitment is registered in the system and can be communicated to the sales people.