Use Adaptive Cards in Teams and Power Automate with Quality Inspector

Skip to main content

Use Adaptive Cards in Teams and Power Automate with Quality Inspector

You are here:

“Adaptive Cards” in Microsoft Teams are a way of collecting and submitting simple form data to another system.

They are small, interactive panels that pop into Microsoft Teams conversations to let someone see or update information without opening another app.

Adaptive Cards with Microsoft Teams with Quality Inspector and Power Automate allow a simple and clean way of collecting information for more simple quality inspection tests.

They are another means of collecting data from Quality Inspectors.

This capability further increased Quality Inspectors ability to inspect anywhere, results can be entered wherever Microsoft Teams is used (a phone, tablet, desktop) without logging into Business Central where people already communicate.

Limitations and Considerations of using Adaptive Cards to collect quality inspection data from Quality Inspector in teams:

  • Cannot be used with sampling.
  • Cannot be used with field-dependent dynamic expressions (all values are sent to Business Central at once, not one at a time)
  • Cannot be used with processes that require immediate knowledge if a value has passed or failed
  • Complex allowed and number conditions won't be evaluated until the values are received from Business Central.
  • Most actions available inside of Business Central are not available inside of the adaptive card.
  • Not all features are available in adaptive cards (such as tools, interactive instructions, additional actions, etc…)
  • Requires a Power Automate license to use, and 'premium' Power Automate blocks within Power Automate.

A Quality Inspection test rendered as an adaptive card in teams when it is collecting information will look similar to the below when it's open.

Use Adaptive Time Cards

To use adaptive cards with Teams you need to create a Power Automate flow with at least four blocks.

  • The event block triggering the flow (Can be anything, but could be when a test has been created, or re-opened, or finished as examples).
  • A Business Central  “Get record ” block  connected to the iwxQualityAdaptiveCards web service.
    • What this does: This calls into Quality Inspector within Business Central to generate the adaptive card Json that teams will use.
    • Significant parameters:
      • API Category set to “insightworks/qualityinspection/v2.0”
      • Table name set to  “iwxQualityAdaptiveCards”
      • A “Row id” parameter set to the guid of the system id.  When used with Quality Inspector events this is often “pguidTestID” or “iwxQISystemIDOfTest”.
  • A Teams “Post adaptive card and wait for a response” block.
    • What this does: Takes the adaptive card Json generated from the previous step and sends it to Microsoft Teams.
    • Significant parameters:
      • In the “Message” block connect it to “iwxQIAdaptiveCardJson”
    •  Other considerations:
      • If you anticipate that tests will not always be sent via teams then consider adding a timeout or a fallback mechanism to avoid power automate flows that run without end.
  • A “Run Action” block.
    • What this does: Takes the response of the teams message and sends it back to Quality Inspector withing Business Central.
    • Significant Parameters:
      • API  Category set to: insightworks/qualityinspection/v2.0
      • Action name set to: iwxQualityAdaptiveCard-processAdaptiveCardJson
      • iwxQISystemIDOfTest: set to the system id of the test from the earlier blocks, such as pguidTestID, or iwxQISystemIDOfTest
      • “InputAdaptiveCardJson”:  (You might need to click the “Show all” button to see this parameter) set to the “Body” response of the “Post Adaptive card and wait for a response”.

Your flow will likely look different with different workflows, but at the core the main process will end up looking like this:

Post an Adaptive Card

The following is a Step by Step walkthrough to post an adaptive card to collect simple values from a quality inspection test from Quality Inspector.

The form will be posted as a flowbot into a specific channel.

  1. Adjust as needed to suit your use case.
  2. Create a flow when “When a business event occurs (V3)”, connect it to your Business Central environment.
  3. In the “Event” dropdown choose “Quality Inspection Test Created (Insight Works)”

This example will use the “Quality Inspection Test Created (Insight Works)” event.

The “Code view” will look similar to this:

{ "type": "OpenApiConnectionWebhook", "inputs": { "parameters": { "bcenvironment": "INVCOUNTDEV", "businessevent": "IWXQIOnTestCreated(769adc1c-0616-432d-ad55-e2d81a080ae9)", "company": "571e25e2-0c98-ed11-bff5-002248b087b8" }, "host": { "apiId": "/providers/Microsoft.PowerApps/apis/shared_dynamicssmbsaas", "connection": "shared_dynamicssmbsaas", "operationId": "CreateBusinessEventSubscriptionV3" } }, "runtimeConfiguration": { "concurrency": { "runs": 10, "maximumWaitingRuns": 10 } }, "splitOn": "@triggerOutputs()?['body/value']" }
  1. Add a “Get Record (V3)” block from Business Central and connect it to your Business Central environment.
  2. Set “API Category” to “insightworks/qualityinspection/v2.0”
  3. Set “Table name” to “iwxQualityAdaptiveCards”
  4. Set “Row id” to be “pguidTestID”, which in this example comes from the previous block, representing the system id of the test (a system id in business central is the ‘row id’ in Power Automate)

It should look similar to this:

The “Code view” will look similar to this:

{ "type": "OpenApiConnection", "inputs": { "parameters": { "bcenvironment": "INVCOUNTDEV", "company": "571e25e2-0c98-ed11-bff5-002248b087b8", "dataset": "insightworks/qualityinspection/v2.0", "table": "iwxQualityAdaptiveCards", "id": "@triggerBody()?['pguidTestID']" }, "host": { "apiId": "/providers/Microsoft.PowerApps/apis/shared_dynamicssmbsaas", "connection": "shared_dynamicssmbsaas", "operationId": "GetItemV3" } }, "runAfter": {}, "limit": { "timeout": "PT20S" } }
  1. Add a Teams “Post adaptive card and wait for a response” block, and connect it to your teams environment.
  2. Set “Post As” to “Flow bot”.
  3. Set “Post in” to a “Channel”
  4. Our example Teams has a team called “Insight Works Examples”, we’ll set the team to that.  Choose a channel that exists.
  5. Our example Teams has a channel called “Quality Inspectors”
  6. Set “Message” to be “iwxQIAdaptiveCardJson”, which is an output from the previous “Get record (V3)” block.
  1. Optional, but considerations for process:
    1. In the “Settings” view consider setting an action timeout to avoid having un-answered forms from leaving flows running too long.
    2. Change to a realistic setting for your process in your implementation.
    3. For demos and training, consider setting it to a short amount to allow flows to expire if they’re not completed.

The resulting block should look similar to this:

The code view of the “Post adaptive card and wait for a response” will look similar to this:

{ "type": "OpenApiConnectionWebhook", "inputs": { "parameters": { "poster": "Flow bot", "location": "Channel", "body/body/messageBody": "@outputs('Get_record_(V3)')?['body/iwxQIAdaptiveCardJson']", "body/body/updateMessage": "@outputs('Get_record_(V3)')?['body/iwxQIUrlToRecord']", "body/body/recipient/groupId": "db5e3687-1d11-499b-b64e-e06fc6218327", "body/body/recipient/channelId": "19:[email protected]" }, "host": { "apiId": "/providers/Microsoft.PowerApps/apis/shared_teams", "connection": "shared_teams", "operationId": "PostCardAndWaitForResponse" }, "retryPolicy": { "type": "none" } }, "runAfter": { "Get_record_(V3)": [ "Succeeded" ] }, "limit": { "timeout": "PT1M" } }
  1. Add a “Run action (V3)” block and connect it to your Business Central environment.
  2. Set “API  Category” to “insightworks/qualityinspection/v2.0”
  3. Set “Action name” to “iwxQualityAdaptiveCard-processAdaptiveCardJson”
  4. Set “iwxQISystemIDOfTest” to the system id of the test from the earlier blocks, such as pguidTestID, or iwxQISystemIDOfTest.  Either will work and they should be the same.
  1. In “Advanced parameters” click “Show all”.
  2. Set “InputAdaptiveCardJson”  to the “Body” response of the “Post Adaptive card and wait for a response”.

The overall result should look similar to this:

With the code view looking similar to this:

{ "type": "OpenApiConnection", "inputs": { "parameters": { "bcenvironment": "INVCOUNTDEV", "company": "571e25e2-0c98-ed11-bff5-002248b087b8", "dataset": "insightworks/qualityinspection/v2.0", "procedure": "iwxQualityAdaptiveCard-processAdaptiveCardJson", "parameters/iwxQISystemIDOfTest": "@outputs('Get_record_(V3)')?['body/iwxQISystemIDOfTest']", "parameters/inputAdaptiveCardJson": "@body('Post_adaptive_card_and_wait_for_a_response')" }, "host": { "apiId": "/providers/Microsoft.PowerApps/apis/shared_dynamicssmbsaas", "connection": "shared_dynamicssmbsaas", "operationId": "ExecuteProcedureV3" }, "retryPolicy": { "type": "none" } }, "runAfter": { "Post_adaptive_card_and_wait_for_a_response": [ "Succeeded" ] }, "limit": { "timeout": "PT20S" } }
Was this article helpful?
0 out Of 5 Stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
5
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.
Need help?

Leave A Comment

Table of Contents
Go to Top