Daniel Egan
Daniel Egan

Reputation: 454

BotFramework WebChat not receiving messages.

I have a bot that works locally when using the emulator but if I try to use the WebChat or Skype. It will only work one way (Meaning, the request comes in from webchat and skype but the response back to them does not go). My code is more complex but I get the same response when I use the code below.

   var restify = require('restify');
var builder = require('botbuilder');

//=========================================================
// Bot Setup
//=========================================================

// Setup Restify Server
var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
   console.log('%s listening to %s', server.name, server.url); 
});

// Create chat bot
var connector = new builder.ChatConnector({
    appId: process.env.MICROSOFT_APP_ID,
    appPassword: process.env.MICROSOFT_APP_PASSWORD
});
var bot = new builder.UniversalBot(connector);
server.post('/api/messages', connector.listen());

server.get('/', restify.serveStatic({
 directory: __dirname,
 default: '/index.html'
}));

//=========================================================
// Bots Dialogs
//=========================================================

bot.dialog('/', function (session) {
    session.send("Hello World");
}); 

I am using NGrok to point to my local machine and use the Ngrok url as the messaging endpoint. As you can see, testing the bot comes back as accepted.

BotFramework Screen 1

I am using VSCode in Debug mode and attaching so that I can step through. If I run from the emulator, It is caught, I can debug through and receive back the "Hello World" sent from the

session.send("Hello World");

If I try from Skype or Webchat Channels. It hits the endpoint, runs through the code like the emulator. But the session.send does not return anything to Skype or the webchat (at least nothing shows up)

If I look at the traffic. The difference between the two (emulator vs others) is that

1) I get both a 202 Accepted AND a 100 Continue (No 100 continue from skype or webchat) 2)The Authorization Bearer has a token in it. The same thing happens if I load it to azure and run it from there.

any help would be appreciated.

enter image description here

Upvotes: 1

Views: 1019

Answers (2)

jorenl
jorenl

Reputation: 94

After walking through the issue over at the BotBuilder Gitter Channel, we resolved the issue. It turned out the MICROSOFT_APP_ID and MICROSOFT_APP_PASSWORD environment variables weren't correctly set.

I figured I would post here since this could be useful information for others experiencing the same problem.

The fact that the BotBuilder SDK didn't inform you of this missing configuration is a bug, and I'm working on a bug report for it.

Upvotes: 3

Jim Lewallen
Jim Lewallen

Reputation: 1006

First, I'd highly suggest hooking up Azure App Insights for your Bot in the bot registration. We log a lot there, and at it's free I believe for the first 5 million data points per month.

In our logs, I'm seeing calls from the bot to Skype being rejected with a 403. Probably your MSAAppID and MSAAppPassword aren't set properly and as a result your requests into the service aren't properly being signed.

Let us know if you don't find anything in that investigation.

Upvotes: 1

Related Questions