microsoft / BotFramework-Composer

Dialog creation and management for Microsoft Bot Framework Applications
https://docs.microsoft.com/en-us/composer/
MIT License
869 stars 369 forks source link

Error: "Operation returned an invalid status code 'BadRequest' " while using hero-card to show buttons on telegram. #8669

Closed dhruv2103 closed 2 years ago

dhruv2103 commented 3 years ago

I am using a Hero Card to display options for multichoice questions. It works fine on webchat(on Azure Portal) but When I deploy on other channels(telegram), it shows me the error. image

I did use multichoice for the first question as shown in the screenshot. I am doing the same thing for one other question, but it is giving me error that "Operation returned an invalid status code 'BadRequest' ".

can anyone help me solve this?

dmvtech commented 3 years ago

@dhruv2103 I will take a look. Can you share your HeroCard + prompt? (feel free to sanitize of sensitive info)

dmvtech commented 3 years ago

Can you share your HeroCard + prompt? (feel free to sanitize of sensitive info)

For example, should be something like this:

        {
          "$kind": "Microsoft.ChoiceInput",
          "$designer": {
            "id": "WD52ci"
          },
          "defaultLocale": "en-us",
          "disabled": false,
          "maxTurnCount": 3,
          "alwaysPrompt": false,
          "allowInterruptions": false,
          "unrecognizedPrompt": "",
          "invalidPrompt": "",
          "defaultValueResponse": "",
          "prompt": "${ChoiceInput_Prompt_WD52ci()}",
          "choiceOptions": {
            "includeNumbers": true
          },
          "style": "heroCard",
          "choices": [
            "choice 1",
            "choice 2",
            "choice 3",
            "choice 4"
          ]
        }
dmvtech commented 3 years ago

I am not able to reproduce the issue, so knowing exactly how your prompt is set up will be essential.

What version of Composer and runtime are you using? C# or Node?

dhruv2103 commented 3 years ago

I am using a bot framework composer to create a bot in Azure Function (C#). I am following these steps:

Step 1:

Input: 1 2

expected output: 3

What I am getting: image

generally, it should work. in fact, it worked for me for one multi-choice question. but when I tried to create second one, it did not.

Code is something like this:

{
  "$kind": "Microsoft.ChoiceInput",
  "$designer": {
    "id": "KwYoii"
  },
  "defaultLocale": "en-us",
  "disabled": false,
  "maxTurnCount": 3,
  "alwaysPrompt": false,
  "allowInterruptions": false,
  "prompt": "${ChoiceInput_Prompt_KwYoii()}",
  "unrecognizedPrompt": "",
  "invalidPrompt": "",
  "defaultValueResponse": "",
  "choiceOptions": {
    "includeNumbers": true,
    "inlineOrMore": ", or ",
    "inlineOr": " or ",
    "inlineSeparator": ", "
  },
  "property": "user.xen_gel_topic",
  "style": "heroCard",
  "choices": [
    "option 1",
    "option 2",
    "option 3",
    "option 4",
    "option 5"
  ]
}

What do you suggest for this?

dmvtech commented 3 years ago

Hi @dhruv2103

A few questions:

I tried to reproduce by doing as close to what you are, but I am just not hitting the issue. Do you see any errors in your Bot Channels blade in the Azure portal? For example; like I do see for my WebChat: image

dhruv2103 commented 3 years ago

Answers to your queries:

In short, I have 2 multi-choice questions in my bot. I am using heroCard for both of them. for the first choice question, it is working perfectly fine. but for another, it is giving me an error. (user.xen_gel_topic is the one in which I am getting an error.)

and lastly, no, I am not getting an error on the portal. image

additionally, It is working when I try my bot in a web chat on the azure portal but is not working in telegram. In telegram, instead of asking a question and giving options, it is giving me an error I mentioned earlier. image

dmvtech commented 3 years ago

hi @dhruv2103 Thank you. This is certainly interesting.

Is this a production bot (in other channels)? Or are you able to https://docs.microsoft.com/en-us/azure/bot-service/bot-service-debug-channel-ngrok?view=azure-bot-service-4.0 the bot running locally?

Also, these two statements seem a bit contradictory:

error occurs as soon as the bot reaches the point where a user should be asked with his/her choice

as soon as the user selects an option. the bot should be asking subcategories based on users choice for the category. but instead, it is giving an error.

Please clarify; the error happens after choices are presented to user but before they actually click on them, correct?

dhruv2103 commented 2 years ago

Hi,

It is a production bot.

Explanation of two statements that you found contradictory:

as soon as the user selects an option(category). the bot should be asking subcategories based on users choice for the category. but instead, it is giving an error. (Here at this point, a user should be asked with his/her choice for subcategory but it does not ask for choice rather it is giving me that error.)

I hope now it is clear. if not, write me back.

dmvtech commented 2 years ago

as soon as the user selects an option(category). the bot should be asking subcategories based on users choice for the category. but instead, it is giving an error. (Here at this point, a user should be asked with his/her choice for subcategory but it does not ask for choice rather it is giving me that error.)

Thank you @dhruv2103 much more clear. Sorry for the hassle.

So, it seems like it is the follow-up/prompt for subcategory that might be the issue. I didn't attempt that yet and just did a simple reply which worked in Telegram: image

I need to understand more of how this dialog is designed, to be able to try and reproduce the issue. Can you send me more steps or code to reproduce? How is the prompt for subcategories configured? Are you able to share a (sanitized) copy of the dialog or the actions within the dialog? I need full steps to try and reproduce the issue.

dmvtech commented 2 years ago

Hi @dhruv2103 Any updates? Can you help me understand what you have configured after the prompt, so that I can try and reproduce?

If you can create a dummy bot that can reproduce the issue, then share that with me, that would be the best.