microsoft / BotBuilder-Samples

Welcome to the Bot Framework samples repository. Here you will find task-focused samples in C#, JavaScript/TypeScript, and Python to help you get started with the Bot Framework SDK!
https://github.com/Microsoft/botframework
MIT License
4.37k stars 4.87k forks source link

[Bug] - Python - "Unable to reach app. Please try again." with sample 54.teams-task-module #3314

Closed v-smalpure closed 3 years ago

v-smalpure commented 3 years ago

Github issues for C# /JS / Java/ Python should be used for bugs and feature requests. Use Stack Overflow for general "how-to" questions.

Sample information

  1. Sample type: [https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/python/54.teams-task-module]
  2. Sample language: [Python]
  3. Sample name: [54.teams-task-module]

Describe the bug

We tried invoking a task module using bot adaptive and hero cards. For the adaptive card the bot did not receive anything and the task module wasn't invoked. Whereas, for the hero card, a pop up comes up with an error message as shown below.

To Reproduce

Steps to reproduce the behavior:

  1. Go to 'https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/python/54.teams-task-module'
  2. Download above solution and follow the steps from README.md
  3. See error - On click of Adaptive card button - "Unable to reach app. Please try again"

Expected behavior

On click of Hero card/ Adaptive card button task module should open.

Screenshots

image image image image image

Additional context

Add any other context about the problem here.

mrivera-ms commented 3 years ago

@dmvtech, are there any updates on this?

dmvtech commented 3 years ago

@sa9arm Thank you for bringing to our attention. I am able to reproduce. Investigating now and will keep you updated.

dmvtech commented 3 years ago

Not sure what is going on here, currently having personal issues debugging. Adding @axelsrz for visibility.

dubi0us commented 3 years ago

I'm having this issue as well using the desktop client (when I use the bot emulator the task / fetch portion doesn't work and opens an explorer window instead). Is it possible that the 502 results from ngrok usage (for whatever reason)?

dmvtech commented 3 years ago

I can still reproduce without ngrok. Still investigating cause.

Zerryth commented 3 years ago

Can confirm I get the same results as @sagarm09 and the others are getting.

Just to be completely explicit, repro steps:

  1. Create Azure Bot resource in Azure portal:

    • image
  2. Run ngrok .\ngrok http 3978 -host-header="localhost:3978"

  3. Copy ngrok forwarding address into Azure Bot > Configuration > Messaging endpoint

    • image
  4. Copy all the appropriate values following sample 54's README inside the bot (like in config.py, manifest.json)

  5. Zipping up contents of teams_app_manifest and uploading into Teams

  6. Running bot locally with py app.py

Get error clicking on Adaptive Card button in conversation image

Zerryth commented 3 years ago

Few more details:

manifest.json: be sure to edit to include the bot's AppId as well as edit validDomains ``` "validDomains": [ "YourDeployedBotUrl.com", "localhost", "localhost:3978", "179a5db5b606.ngrok.io" ] ```
Plugging in a local copy of the python SDK into sample 54 does not help, as it doesn't appear that the bot is ever reached at all *requirements.txt* - point packages to local copies from cloned SDK ``` msrest botbuilder-schema>="C:\BF\py\task-mod\botbuilder-python\libraries\botbuilder-schema" botframework-connector>="C:\BF\py\task-mod\botbuilder-python\libraries\botframework-connector" botbuilder-integration-aiohttp>="C:\BF\py\task-mod\botbuilder-python\libraries\botbuilder-integration-aiohttp" ``` In terminal, where bot is run, there isn't any logging activity, as it appears the request from clicking on Adaptive Card in Teams never reaches the bot it seems ![image](https://user-images.githubusercontent.com/35248895/123461424-f744e000-d59d-11eb-85be-3c6ba1075a24.png)
Error in dev console when using web version of Teams ![image](https://user-images.githubusercontent.com/35248895/123461655-34a96d80-d59e-11eb-81b5-e54eb1889a3e.png)

To state the obvious, it appears that these issues are from Teams not being able to call the bot. I could see if this is ngrok-related by trying to call sample 54.teams-task-module bot that's deployed rather than using ngrok

It's possible that there was a change of behavior in Teams that's breaking--or perhaps there was change in Teams that requires the bot to be set up differently, but as of now the bot samples have remained the same.

tracyboehrer commented 3 years ago

I am unable to reproduce this. There is one step missing in the README. Updating the "BaseUrl" in config.py, but it doesn't seem to matter for the Apaptive Cards button.

My steps

1) Created the bot registration 2) Started ngrok (per README) 3) Updated the Azure Bot Messaging Endpoint (via the Azure Portal) to be {ngrok-url}/api/messages 4) Updated config.py a) MicrosoftAppId b) MicrosoftAppPassword c) BaseUrl (set to the ngrok url) 5) Update CustomForm.html with the MicrosoftAppId 6) Start the bot locally 7) Update teams_app_manifest/manifest.json a) Update <<YOUR-MICROSOFT-APP-ID>> in both locations b) Update validDomains to the ngrok hostname (not the entire URL) 8) In Teams a) Import the manifest.json. You don't actually need to create the zip. Just navigate to the manifest.json. Though it won't matter which method you use. b) Test & Distribute

NOTE: I am using the main branch locally for the SDK. I don't know of any change in main that would change this behavior though.

dubi0us commented 3 years ago

> I am unable to reproduce this. Are you saying that you got the sample working?

tracyboehrer commented 3 years ago

> I am unable to reproduce this. Are you saying that you got the sample working?

Yes. I was unable to reproduce the described "Unable to reach app" error. The Adaptive Cards button prompted for text, and sent it back to the bot. The other options worked as well.

dubi0us commented 3 years ago

Fantastic, could you please share your configuration files? It seems like there's some minor miscommunication going on and it'd be very helpful to see the specifics of your implementation in order to fix whatever problem is on my end.

dmvtech commented 3 years ago

@dubi0us Let me work on getting that for you. Obviously the readme needs to be updated as well.

tracyboehrer commented 3 years ago

Hold tight. There is something funny. Looking into it.

dmvtech commented 3 years ago

@sagarm09

This is resolved in R14. If you wish to test from the release candidate, you can update the requirements.txt to use 4.14.0rc3 for the bot packages and then pip install. Otherwise, it should be out sometime soon.

v-smalpure commented 3 years ago

@dmvtech, @tracyboehrer

Thank you for the solution its working now 👍 but I have a query that below library is not used anywhere in the code (botbuilder-integration-aiohttp).

image

I can see it used separately in the code could you please help me to understand how/where it referenced in the code as a single library "botbuilder-integration-aiohttp" ?

image

axelsrz commented 3 years ago

Looking into the sample, the library is not used. This means the dependency can be replaced by botbuilder-core.

Will be closing this issue due to original problem being solved.

winpisces commented 9 months ago

It appears that the issue can be resolved by adjusting the Token Exchange URL. Specifically, you should use the Application ID URL that you obtained in step 1.3 as stated in the Microsoft Teams Samples Bot Conversation SSO Quickstart Setup Guide. While many samples and documents on the internet suggest leaving this field blank, I found that filling in the Token Exchange URL field effectively resolved the "Unable to reach app. Please try again" error in Python.