Bot works locally but unresponsive on Bot Service

593 views Asked by At

I've got a bot set up for continuous integration via VSTS. The bot is running on an App Service plan (I only recently figured out that Consumption plan bots run as functions.) I have a working bot in the cloud on Consumption but it's limiting my ability to expand.

For this bot, I did a clean deploy of a Prompt bot - but trying to run it in the cloud yielded a dialog error. So I commented out the Prompt code and turned it into an echo bot. Still runs fine locally, but no response from the service. Tried logging into a Kudu console and running a manual npm install but it didn't help. Attempting to manually run the bot in kudu causes a Bad Request error.

Node version 6.11.2. File tree includes all files provided by Bot Service at time of initial deployment, including iisnode and web.config.

Here's my app.js and package.json. Has anyone else run into problems with locally valid bots not responding upon cloud deployment? Any tricks I haven't tried?

UPDATE: Found this error firing via the Azure log stream, but don't know how to fix it. Error: Request to 'https://state.botframework.com/v3/botstate/webchat/conversations/(snip)' failed: [500] Internal Server Error at Request._callback

var dotenv = require('dotenv');
dotenv.load();
var restify = require('restify');
var builder = require('botbuilder');

// 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 connector for communicating with the Bot Framework Service
var connector = new builder.ChatConnector({
    appId: process.env.MicrosoftAppId,
    appPassword: process.env.MicrosoftAppPassword,
 });

 // Listen for messages from users 
 server.post('/api/messages', connector.listen());

 var bot = new builder.UniversalBot(connector, function (session, args) {
     console.log("Initialized the bot.");
     session.send("You said: %s", session.message.text);
  });

Package.json:

{
  "name": "heretohelp-app",
  "version": "1.0.0",
  "description": "Azure bot",
  "main": "app.js",
  "dependencies": {
    "applicationinsights": "^0.21.0",
    "botbuilder": "^3.9.1",
    "botbuilder-azure": "^3.0.2",
    "dotenv": "^4.0.0",
    "restify": "^5.2.0"
  },
  "devDependencies": {
    "request": "^2.81.0",
    "zip-folder": "^1.0.0"
  }
}
1

There are 1 answers

0
C. Platz On

It took a ton of digging, but once I found the logged error it led me to a thread about an issue the Bot Service was having last week with the prototyping state environment: https://github.com/Microsoft/BotBuilder/issues/3463

I found a few dead ends trying to get my own state storage up and running but this article eventually got me functional: https://learn.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-state-azure-table-storage

Created Azure storage account, used above article to layer that into your bot. Breaks the link to the (apparently still broken) prototyping state management service. Once this step is completed, web chat works.