The Automation Bot: Launching Contextual Flow from Teams

   Words by Paul McQuillan

   on 15/02/2021 18:00:00

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


See it in action..


Share this Article

Search Articles

Filter Articles

CRM Tech DocMan

Recent Articles

HOW TO: Integrate SQL Users into Dataverse Teams HOW TO: Prepare to go LIVE on Linked-In! Creating a Homepage Canvas App HOW TO: Virtual Entities in Dynamics 365 Release Wave 2 New Feature: The Columns Button HOW TO: Search a date field in Microsoft Dynamics The Relevance Search COMING SOON to Power Apps Portals HOW TO: Manage Your Dynamics 365 Database Size (Video Included) Dynamics 365 Marketing vs ClickDimensions It’s time to pause, reflect and acknowledge a new era of inclusivity and collaboration. Part 2 - How to get the most from a Technology Expert – Asset Management Hub Property & Asset Management Hub Part 1 – Balancing CRM and Asset Management Scopes - Asset Management Hub Creating a Multi-Lingual PowerApps Portal How to Set Up a Microsoft Teams Site Using DocDrive365 Microsoft Teams - Adding a Microsoft Teams URL to a Dynamics Appointment Dynamics 365 Marketing – Customer Voice Survey Not Appearing In Emails? Using SQL Management Studio to connect to the Dynamics DB Calling a Power Platform AI Builder Model via oData How to use DocDrive365 to integrate permissions between Business Units in Dynamics with Sites in SharePoint Getting started with the Power Platform AI Builder. Power Apps Portal Information Hub DocDrive365 Security: Day One - Getting Started with Dynamics to SharePoint Permissions Part 5 - Power Apps Portals: How To Connect Azure B2C With Linked-In Part 4 – Power Apps Portals: Styling Azure B2C for Power Apps Portals
Contact Us

Want expert advice or a demo?

Get in touch now and see how we can help your business grow.

  • Name
  • Email Address
  • Phone Number

Understanding Your Challenges

Our strong understanding of CRM and emerging technologies within the Microsoft environment means we deliver the right solutions for you.

Proven Real-World Solutions

As a leader in the field of Dynamics solutions, our pedigree developing and delivering real-world solutions is unsurpassed.

Long Term Support

We provide support beyond our design, implementation and 'go-live' delivery using Sprints and continual updates to our AppSource apps.

CRMCS | Design by Thinktank Marketing | Citrus-Lime Limited

To improve your experience today and in the future, this site uses cookies. Read our full Privacy Policy & Cookie information here I Understand