cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
qho1585
Frequent Visitor

Adaptive card loop error when triggered with keyword

Hi, I'm building an adaptive card that waits for a response when Triggered by a keyword. When I enter "hi", "hello" or "position" it will return an infinite loop of the adaptive cards. or after I finished fill in the blanks and hit submit the adaptive card will run and 2 mores are waiting. I don't know how to solve this problem. I will attach the adaptive card JSOn below.

 273023106_325394366198678_4764584826631471033_n.jpg273166992_317807680395003_3111157906784067281_n.jpg

 

Adaptive card

 

{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "TextBlock",
"size": "Medium",
"weight": "Bolder",
"text": "Welcome ",
"horizontalAlignment": "Center",
"wrap": true,
"style": "heading"
},
{
"type": "TextBlock",
"text": "Enter the task that you need to process",
"wrap": true
},
{
"type": "Input.Text",
"id": "SimpleVal"
},
{
"type": "TextBlock",
"text": "Code or UUID",
"wrap": true
},
{
"type": "Input.Text",
"style": "Url",
"id": "UrlVal"
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Submit",
"data": {
"id": "1234567890"
}
}
]
}

1 ACCEPTED SOLUTION

Accepted Solutions
mattias1172
Responsive Resident
Responsive Resident

If the keyword exists in the bot's response, the bot will trigger itself and end up in an infinite loop. 

 

The simple solution is to make sure the keyword is not in the bot's response. One way to do this is using less simple keywords such as "gethelp" instead of "help". 

 

A more complex way is to detect if the bot posted the message and if so, cancel/handle the flow on another branch. Using the "Get Message Details" action with the Message ID, inside the "body" of the message there is a "from/user" section. 

 

  "from": {
    "application"null,
    "device"null,
    "user": {
      "id""string of characters here",
      "displayName""Display Name Here",
      "userIdentityType""aadUser"
    }
 
I store this as plain text in a variable and run a conditional against it. If a bot posts the message, "user" is empty since its considered an application. 
 
  "from": {
    "device"null,
    "user"null,
    "application": {
      "id""string of characters",
      "displayName""Flow",
      "applicationIdentityType""bot"
    }
 
If you have a True False looking at a value here such as user being empty or application being empty, you can have the flow exit itself if its from a bot. This will still show in the flow history but will prevent the rest of the flow from running. 

View solution in original post

1 REPLY 1
mattias1172
Responsive Resident
Responsive Resident

If the keyword exists in the bot's response, the bot will trigger itself and end up in an infinite loop. 

 

The simple solution is to make sure the keyword is not in the bot's response. One way to do this is using less simple keywords such as "gethelp" instead of "help". 

 

A more complex way is to detect if the bot posted the message and if so, cancel/handle the flow on another branch. Using the "Get Message Details" action with the Message ID, inside the "body" of the message there is a "from/user" section. 

 

  "from": {
    "application"null,
    "device"null,
    "user": {
      "id""string of characters here",
      "displayName""Display Name Here",
      "userIdentityType""aadUser"
    }
 
I store this as plain text in a variable and run a conditional against it. If a bot posts the message, "user" is empty since its considered an application. 
 
  "from": {
    "device"null,
    "user"null,
    "application": {
      "id""string of characters",
      "displayName""Flow",
      "applicationIdentityType""bot"
    }
 
If you have a True False looking at a value here such as user being empty or application being empty, you can have the flow exit itself if its from a bot. This will still show in the flow history but will prevent the rest of the flow from running. 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (4,728)