Search code examples
c#botframeworkdirect-line-botframeworkweb-chatbot-framework-composer

Typing indicator shows even afterr message is sent Bot Framework Composer


Exactly what the title says. I've been trying to implement the typing indicator (befor bot sends a message) for a bot created through Bot Framework Composer. The guidelines are to set the the showTyping property in appsettings.json to true but when I do this it will sometimes displays the typing indicator before the bot sends a message but sometimes it will display the typing indicator after the bot message.

I've already looked up this error and there doesn't seem to be support on it anywhere for Bot Framework Composer but there are resources for this same issue occurring using Bot Framework SDK. I have extensively read and tried all the suggestions for the SDK version but can't seem to get it to work. I don't know if I'm missing some code that hooks the components together but I've done a number of things which generally include

  • Creating a CustomShowTypingMiddleware.cs
  • Create and edit the AdapterWithErrorHandler.cs
  • Use the adapter in Startup.cs

I don't know if something else is meant to be added to any of the other composer c# files (ex. BotController.cs, Program.cs) but these were the changes I noticed in the code samples so this is all I added. By making these changes, it seems to do nothing. It doesn't break the bot but it doesn't add any typing functionality either. An alternative I've tried that was working only locally was creating a custom middleware component (following this https://learn.microsoft.com/en-us/composer/how-to-create-custom-actions?tabs=csharp#export-the-bot-runtime), referencing it inside my composer bot and then adding the name of the new component to my components array in appsettings.json. This successfully sent the typing activity and showed it in chat locally but whenever I would deploy the code to Azure and Test in Webchat or use it in our client application linked to this hosted Azure bot, it would always send back a 502/500 error saying that there's a missing secret or token on the request webchat/join when in fact the Authorization header shows otherwise.

I would appreciate any help on trying to make either methods (adapter or custom component) work or a new one if there is anything else.


Solution

  • it turned out the problem with my custom bot component implementation was that it was an external project.

    I think because the docs are a littled dated. They reference a .sln file that as far as I know does not exist anymore in the template Composer projects. Because of this, I created a blank solution in VS where I opened my existing bot project and created a new project for the component. I mainly followed the instructions here which are very similar to the docs (just specifically for components instead of actions) but at the end I moved the component project into the bot project directory. Then I adjusted the project reference in the <bot>.csproj to point to the newly moved component project. Added some <Generate...Attribute>false</Generate...Attribute> attributes in <PropertyGroup> of the <component>.csproj (again now in the bot project instead of outside of it) to remove the duplicate attribute errors I was getting. Deleted the bin/ and obj/ directories of both the bot project and the component project. Then it worked fine both locally and on Azure.