One of the best features in Power Automate is the ability to create HTTP Triggers or Webhooks.
These allow us to create no-flow business logic that can be triggered from any given App – in our case, triggered from our Teams Bot App.
In one way however, simply launching a Flow is okay to a point, but the true power of Teams is launching a Flow that is contextual to the Channel or Conversation we are in engaged in. In this way our existing engagement through communication with our colleagues is then progressed into the follow-up automation or next steps, limiting the disconnect from action to reaction.
Step 1 – Create our Flow and define the Details coming from Teams
We can Power Automate as our No-Code Engine for the Business Logic we want – but as we want this triggering from a 3rd party, we can create the Flow in Power Automate as a HTTP Trigger.
To do this, we open Power Automate and create a new Instant Flow:


This creates a Flow capable of being started by a JSON Message – and ultimately this JSON Message will come from our Team Bot.
But we first must define the format of the JSON Message that our Flow will expect.
Fortunately Flow provides us a method to type out an example message and then define our Flow’s expected schema there – we can access this view from the Use Sample Payload to Generate Schema.


For our Flow here, we want a JSON Message Format that will be readily passed from our Bot our Flow, and for this example this will fit a simple format to pass the core Teams Message details into the Flow:
{
"TeamId": "{TeamId}",
"ChannelId": "{ChannelId}",
"ConversationId": "{ConversationId}",
"UserId": "{UserId}",
"Content": "{Content}"
}
This then sets up to implement the actual logic we want in our Flow.
(however we will be back to this step for the HTTP POST URL in a few steps time!)
Step 2 – Define our Business Logic
In our example, we are going to use a simple example where our Flow finds the Project in Dynamics that relates to the Channel in Teams and adds a series of Tasks for different people connected to that Project.
We can build this logic into our Flow in a similar way to a traditional Dynamics Workflow.
Our first action is to find the Project Record that relates to the Teams Channel that the Message has come from – we can do this with a quick List Rows action in our Flow:

This retrieves 1 or more records from Dynamics that relate to the Channel – the context to the request which has been made to the Bot in Teams by the User.
We can see in this Action how we use the Parameters from the JSON Message which has launched the Flow - as we defined those Parameters from our Example Payload, we can customise our Flow to use those details throughout. in this case, finding any Project Records where the ‘crmcs_msteams_channelid’ is equal to our original ‘ChannelId’.
With our List of Projects available to us, we can then configure the logic we want to run on each Project.
In this example, a simple action to create a Task regarding the Project:

We can note here how we an use the ConversationId from the Bot in the attributes we create for the Task (in as Description above, but best saved into a custom field for ‘crmcs_msteams_conversationid’).
This will create a bridge between the Task and the Conversation between the User and Bot that was responsible for it creation.
This link can be used to send Notifications about the Task back to the original conversation in Teams. These Notifications potentially coming from any event in Dynamics that relates to the Task – but most notably the event when the Task is completed or cancelled. We can see more of this concept in action in the Notification Bot article in this series.
Step 3 – Add an Action into our Bot to run the Flow
xx
See it in action..
xxx