Search code examples
azurebotframeworkazure-cognitive-services

Microsoft bot framework with signalr


I'm wondering how I would connect a microsoft bot written in c# with a signalr chat. To be specific: I have a signalr chat in which users can talk to "coaches". But the bot has to listen to these chats in case the user asks the bot something (or other reasons the bot needs to do something). How would I do this?


Solution

  • Check out these resources that should give you enough combined information for you to build a connector for your bot to interact with SignalR.

    • This tutorial details how to build an ASP.NET Core app that integrates SignalR. Utilizes the SignalR client library.
    • This doc discusses how to build an Azure Function that "can leverage the Azure SignalR Service bindings to add real-time capabilities." I don't know if you are using the Azure flavor of SignalR and you don't mention Azure Functions, but this could give insight in how to design and implement.
    • You may need to use the BotFramework REST APIs (docs here) to forward and receive activities to your bot (depending on how you structure it all). If you build the connector as part of the same project as your bot, then this is less likely.
    • You will need to understand the activity schema so you an correctly interpolate the data being passed to and from your bot.
    • Lastly, here are some connectors from the Botbuilder-Community repo that you can use as a reference (Alexa, Google, Twitter) for development.

    As you are probably aware, you need to build a service that allows your bot to connect to SignalR. This means authenticating against your SignalR service to retrieve a token or similar. Once that is complete, then it's a matter of the data being passed around. If you can successfully pass data, then it's configuring your bot to reply and send activities that SignalR can accept (for instance, a hero card may render while an adaptive card may not).

    Hope of help!