Search code examples
node.jsazurebotframeworkdirect-line-botframework

Bot Framework WebChat Failure [405] Method Not Allowed


We have developed a Chatbot using Microsoft Bot Framework NodeJS Template. We deployed on to Azure. On opening the output console, we are seeing the below errors:

Bot Source Code:

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:My APP ID',
    appPassword:My APP Password
});

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

// Receive messages from the user and respond by echoing each message back (prefixed with 'You said:')
var bot = new builder.UniversalBot(connector, function (session) {
    session.send("You said: %s", session.message.text);
});

Package.JSON

{
  "name": "",
  "version": "",
  "dependencies": {
    "botbuilder": "^3.15.0",
    "restify": "^7.2.1"
  }
}

Output on console

        Error: GET to 'https://state.botframework.com/v3/botstate/webchat/conversations/0560d6047ba0487bd762e7e86a1b6ca/users/A8r4akHZE1Z' failed: [405] Method Not Allowed
    at Request._callback (D:\home\site\wwwroot\node_modules\botbuilder\lib\bots\ChatConnector.js:647:46)
    at Request.self.callback (D:\home\site\wwwroot\node_modules\request\request.js:185:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request. (D:\home\site\wwwroot\node_modules\request\request.js:1157:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage. (D:\home\site\wwwroot\node_modules\request\request.js:1079:12)
    at IncomingMessage.g (events.js:291:16)
    at emitNone (events.js:91:20)

We tried a number of workarounds and nothing worked.


Solution

  • It looks like you are trying to use the old StateClient which is deprecated for a while now.

    Follow the documentation about how to save state in Bot Framework here for Node.js

    Without mode details about your code, I can't help more