How to host a Microsoft Bot without registering with Microsoft or Azure?

Viewed 650

I've been attempting to find an alternative to registering and hosting my Microsoft Bot with Microsoft/Azure. I'm aware that I can host the bot locally and simply register it with Microsoft to gain access to the various available channels but I'm looking to host my bot entirely separate from Microsoft's registration.

My basic goal is to expose a directline endpoint/api that can communicate with my bot without having to register said bot with Microsoft. I'm sure this could be accomplished with some sort of middleware but I'm having trouble finding resources that help. I've attempted to utilize a nodejs package, offline-directline, with no success. I believe the package is out of date and no longer works as expected. For the time being I'm using this package as a reference to attempt to concoct my own solution but any alternative resources would be helpful.

A few final details about the this project. The bot is written in .Net utilizing Microsoft's Bot Framework. I [need] a solution that works specifically with .Net bots but I'm open to one that can work with .Net [and] Nodejs bots. Thank you for any help and I'll be happy to answer any additional questions as they come up.


In relation to the offline-directline repo the following is the current state of my setup. I'm attempting to get a barebones version working by utilitizing the EchoBot sample from Microsoft. I connect to the webchat using this url http://localhost:8080/?domain=http://localhost:3000/directline. The following are the code snippets for my nodejs app and the client webchat.

app.js

const directline = require("offline-directline");
const express = require("express");

const app = express();
directline.initializeRoutes(app, 3000, "http://127.0.0.1:3978/api/messages");

index.html

<!DOCTYPE html>
<html>
   <body>
      <div id="webchat" role="main"></div>
      <script src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
      <script>

        function getUrlVars() {
          var vars = {};
          var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
            vars[key] = value;
          });
          return vars;
        }
        let params = getUrlVars();
        console.log(params);
        window.WebChat.renderWebChat({
          directLine: window.WebChat.createDirectLine({
            token: params['s'],
            secret: params['t'],
            domain: params['domain'],
            webSocket: false
          }),
        },
        document.getElementById('webchat')
        );
      </script>
   </body>
</html>

Errors

Console-Errors

2 Answers

Not sure how much refactoring you would need but Botkit might give you what you're looking for.

Botkit is just one part of a bigger set of developer tools and SDKs that encompass the Microsoft Bot Framework. The Bot Framework SDK provides the base upon which Botkit is built. It is available in multiple programming languages!

Or if you're daring enough, you could ask the folk over at Microsoft opencode@microsoft.com if you can pull their Bot Framework SDK and rip out the Azure bits?

Regarding the "offline-directline" package, it isn't out-of-date. My suspicion there is you are not configuring it correctly. This following code sample is enough to get the package running. Then you just need to point your bot to it.

const directline = require('offline-directline');
const express = require('express');

const app = express();

directline.initializeRoutes(app, 4000, "http://127.0.0.1:3978/api/messages");

If you continue to struggle, another option is the "browser bot" which you can find on the Botbuilder-Samples repo here. In this setup, the bot is hosted entirely within the browser and does not require using Direct Line. Setup is only slightly different and will require you to play with configurations some, as a result. But, it's worth a look.

Hope of help!

Related