Search code examples
azurebotframeworkazure-bot-service

Using Azure Bot Service with non-Channel-Configurable Chat Service


When I create a bot in Slack, I can use channel configuration on Azure Bot Service to receive event/message from Slack and communicate with my Web App Bot which handles various functions.

However, when I create a bot in a chat service which is not supported in channel configuration (e.g., Discord), I need to set up a client in my Web App Bot (e.g., Discord.Net) to communicate with the service.

Then, although I guess the Direct Line channel (REST API) will handle communication between the Web App Bot and Bot Service, but am not sure if it's correct. Is my assumption right?

Also, it is not clear for me if there's an advantage of using Bot Service in this situation, because simply I may host an individual web app on Azure or another location and let it communicate with the chat service. Why do I need to add one more service to handle?

I suppose that one possible advantage could be that I can easily access various features (e.g., LUIS) via the Bot Service. Also, the bot can handle various platform like Skype or Cortana with one code.

But still I don't really understand this topic. Could anyone give me a suggestion and best practice?


Below is my current understanding, it could be wrong though.

enter image description here


Solution

  • Directline API isn't the easiest to work with, and making a Bot Framework bot work with Discord is going to take a good amount of work. But the purpose of the Directline is to be the connection between your bot (Azure Bot Service/Web App Bot) and Discord. To use the Directline API, you're going to:

    1) Get your directline secret by registering your bot on Azure (Azure Bot Services)

    2) Create your directline object, using above secret (this is the line of communication between ABS and Discord)

    3) Use your directline object to POST activities to the bot from the user and Listen for activities from the bot

    4) Additional purposes not related to conversation: your directline object will monitor connection status of your websockets, and keep the token refreshed for the conversations

    The Directline-js repo has a good README and code samples, but bear in mind that the framework is constantly being improved. As of this writing, there are 8 pull requests waiting for review for the repo.

    The AI Help Website wrote a preview back in July 2018 (before the release of v4) on how to use the Directline API with C#

    And finally, the official documentation for the Directline API is here

    As for connecting your bot with Discord, the Discord API reference has instructions on how to get your authorization token here.