howdyai / botkit

Botkit is an open source developer tool for building chat bots, apps and custom integrations for major messaging platforms.
MIT License
11.46k stars 2.28k forks source link

botkit unable to connect with Bot Framework's webchat? #2196

Closed pgoldweic closed 2 years ago

pgoldweic commented 2 years ago

As I understand, it should be possible to connect Botkit to MS webchat (see thread: https://github.com/howdyai/botkit/issues/2181 ) However, I've been unable to do so after following these steps:

1- Creating an AzureBot resource for my botkit bot on the Azure portal (note: my bot is not hosted on Azure) (note: I tried to do a channels registration instead, but this feature has been deprecated) 2- Used the Microsoft app Id and password that were created in step 1 to integrate the bot with the framework as explained in https://github.com/howdyai/botkit/blob/main/packages/docs/core.md#using-bot-framework-channels. 3- Successfully connecting the bot to the Microsoft Bot Framework Emulator (did not configure with an app Id and password; worked without them) 4- Following the instructions on this page to try to connect to webchat: https://docs.microsoft.com/en-us/azure/bot-service/bot-service-channel-connect-webchat?view=azure-bot-service-4.0. (in particular methods 1 and 2)

I've been getting the following error in my bot's own console when webchat tries to connect: "Experienced an error inside the turn handler Error: BotFrameworkAdapter.processActivity(): 401 ERROR Error: Unauthorized. Invalid AppId passed on token: blah" (note: I explain all of this in this post: https://stackoverflow.com/questions/70901441/unable-to-connect-botkit-based-bot-to-botframeworks-webchat-401-errors for details), So far, none of the similar posts has been helpful in resolving my problem (unfortunately I mistakenly upvoted the only answer provided on Stack Overflow, when in reality it did not help after all :-() .

I'm starting to suspect that I might be missing some important step (not documented anywhere), or that this connection is not possible after all. Would be great if a botkit expert could weigh in on this.

benbrown commented 2 years ago

@pgoldweic If you've got the adapter configured correctly, you should not be able to connect tothe Emulator without specifying the ID and password. Sounds like something is going wrong.

Using the latest version of Botkit, I can confirm that if I have the values properly passing through to the adapter, it should communicate with the Bot Framework service. See the screenshot below of the web chat testing interface -- this is connected to a boilerplate bot from the yeoman generator. image

benbrown commented 2 years ago

@pgoldweic i would introduce some tracing or use the debugger to make sure those values are properly being passed into the adapter.

pgoldweic commented 2 years ago

Thanks @benbrown for your input. I very recently realized that the name of the 'adapter config' attribute in the Botkit instance creation was misspelled (in my code it was 'adapter_config', while it was apparently meant to be 'adapterConfig' instead. This took forever to find out (required Microsoft support) but I'm glad to have found out that that was the problem (since the credentials were not getting to the bot service at all, that explains why the Emulator worked without them too).

benbrown commented 2 years ago

@pgoldweic sorry for the slow response! You are always very prompt in your replies.