QnAmaker sample - The bot's Microsoft App Id or Microsoft App Password is incorrect

﹥>﹥吖頭↗ 提交于 2021-01-05 06:59:08

问题


I downloaded the QnAmaker sample from here and trying to make it working from bot emulator. I gave the correct Microsoft App Id and App Password. I even tried with a newly regenerated password. But getting the same error.

Did anyone face this issue? any thoughts. What should I try next to get this resolved?

My app settings

My ngrok settings

Update

I removed ngrok settings from emulator settings.Removed MsApp Id and Ms App Password and then started emulator and the bot is responding. But I need to connect to my QnaMaker on azure and get response based on my knowledge base.

Update 2

I tried via Web chat from azure portal and it did not responded. Here is the error message I found in Application insights

Failed to acquire token for client credentials. (AADSTS700016: Application with identifier 'fXXXXXXXXXXXXXXXXXXXXX2' was not found in the directory 'botframework.com'. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You may have sent your authentication request to the wrong tenant. Trace ID: 9XXXXX-46a3-4XX-b8XXX7-c1XXXXX00

Question :

"This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You may have sent your authentication request to the wrong tenant"

How can I ensure that I am sending the request to correct tenant ? Where can I verify this ? or How can I fix this issue ?


回答1:


Try removing the values for MicrosoftAppId and MicrosoftAppPassword from your appsettings.json file then run the bot and attempt to connect it via the emulator again.

When you connect to a bot in the emulator, AND the appsettings.json (always) or .bot file (only for the development endpoint) has values set for the MicrosoftAppId and MicrosoftAppPassword then you will need to enter these details into the provided fields on the connection screen, see my image below:

If your values in your appsettings.json for MicrosoftAppId and MicrosoftAppPassword are empty i.e. "" then you will not have to enter them at the connection screen and your bot will still work when you are debugging locally, even though your live bot has these set. The exception is when you're using ngrok to debug a production channel using your local code, then you will have to provide the MicrosoftAppId and MicrosoftAppPassword when connecting even though they may not be set locally.




回答2:


If you want to see the response inside emulator then remove the app id and password from app settings.json file(it has worked for me) and add QnA kb keys in the app settings file. And if you want to test on web chat then add app id and password in the app settings file with QnA kb keys and publish it. Once your bot is published you will be able to test on web chat and change the messaging endpoint to your published url. By the way if you are using v4 botframework, you will not require ngrok.




回答3:


I think I might know what caused this - where did you get the Application ID and Application Password from? They need to be from a newly created "Bot" app in the Azure portal. If you don't have the right app+key combo, you can happily communicate with your bot through the emulator, for instance, but it won't be able to connect to other services (e.g. QnAMaker, MS Teams).

In the Azure portal, the "Web App Bot" template will create a Bot app AND a web hosting application in Azure, but there's also an option to create a "Bot Channels Registation" if you're using an existing sample application you've downloaded and are running on your local machine.

This "Bot Channels" option is basically just a placeholder of sorts in Azure, where all the key registration in Azure for the bot is done, but you can host the bot itself anywhere you like (for instance on your local machine, in which case you provide the ngrok address as the endpoint, something like: https://250a1f39.ngrok.io/api/messages (make sure you have the "/api/messages" on there).

On the Settings screen for the bot in the Azure portal, where you capture/update the endpoint, is the "Microsoft App Id" you need. There's also a link to "manage", which should take you to where you can get the password, but the link is currently broken (I think MS is working on fixing it), so to get the password you need a few more steps:

  1. Go to the main Azure home page / main resources listing (small menu icon on top left in Azure)
  2. Go to Azure Active Directory (yes, even in your own personal Azure subscription you would do this - there's still an Azure AD provisioned behind the scenes)
  3. Go to "App Registrations" on the left menu
  4. Go to "Applications from personal account" near the top of the page (NOT on the main top menu, a bit down)
  5. In there you will find your new bot - open it up
  6. Go to "Certificates and secrets"
  7. Click the button to create a "New client secret"
  8. Choose an expiry option and optionally give it a description.
  9. Click Add and once it's added - that's the app password you need


来源:https://stackoverflow.com/questions/56435198/qnamaker-sample-the-bots-microsoft-app-id-or-microsoft-app-password-is-incorr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!