Botframework-sdk: Bot Framework Nodejs unable to connect bot after deployment on azure

Created on 1 Sep 2016  路  18Comments  路  Source: microsoft/botframework-sdk

I have deployed my nodejs bot to azure with proper appId and password configuration. The URL to the site works but when I test my bot connection (see below), I get this message....

"NotFound. The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."

When I try to reach my /api/messages end point on localhost, I get the same error.

When connecting my bot to webchat, I get the following error...

POST https://webchat.botframework.com/api/conversations/Kxf4zWQrE6f/messages 500 (Internal Server Error)

I have no clue what went wrong. I have followed the docs very carfully. Any help would be greatly appreicated.

Below are my server codes..

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

//Server setup
var server = restify.createServer();

server.listen(process.env.port || process.env.PORT || 3978, function() {
console.log('%s listening to %s', server.name, server.url);
});

//Get secrets from server environment
var connector = new builder.ChatConnector({
appId: process.env.MICROSOFT_APP_ID,
appPassword: process.env.MICROSOFT_APP_PASSWORD
});

//Create chat bot
var bot = new builder.UniversalBot(connector);
//Handle bot framework messages
server.post('/api/messages', connector.listen());
server.get(/.*/, restify.serveStatic({
'directory': '.',
'default': 'index.html'
}));

//LUIS Model
var model = process.env.model || 'https://api.projectoxford.ai/luis/v1/application?xxxxxxx';
var recognizer = new builder.LuisRecognizer(model);
var dialog = new builder.IntentDialog({ recognizers: [recognizer]});

screen shot 2016-08-31 at 11 00 05 pm

help wanted

Most helpful comment

The problem may be that in code you are not necessarily exposing /api/messages:

var bot = new builder.UniversalBot(connector);
server.post('/api/messages', connector.listen());

I had the same problem when configuring the bot to use the URL of the application, and not the URL of the application plus /api/messages .

All 18 comments

I deployed on heroku and the test connection was accepted. However, it doesn't seem to hit my bot.dialog function (can't wake my bot).

Can you share your botid so that we can diagnose? Offhand either we can't find the server endpoint. Any possibility you cleared the default port (process.env.PORT) in the Azure console and so it's trying 3978?

Hi @santhonydo - can you tell me your bot endpoint? is it http://pharmbot.azurewebsites.net/ ?

@santhonydo did you add a "start" script to you package.json file? Heroku won't automatically start your bot. You have to configure it to start node for you

Here's a sample:

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "start": "node app.js", "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "async": "^1.5.2",
    "chrono-node": "^1.1.3",
    "node-uuid": "^1.4.7",
    "request": "^2.69.0",
    "sprintf-js": "^1.0.3",
    "restify": "^4.1.1"
  }
}

Hi @santhonydo, was this sufficient to get your app running? Or do you need additional assistance?

Hi all. Sorry for late reply. For some reasons all my notifications have been going to my junk mail. Thank you for all the suggestions. Looks like I was missing package json for my bot. Got it to work. Thanks so much for all the advice!

Thanks @santhonydo!

After deploying my node js bot on heroku server successfully
On opening bot url in browser its just showing below error

{"code":"ResourceNotFound","message":"/ does not exist"}

Hi guys,
Im getting this error

ela

When trying to test my connection to the bot...I have appended /api/messages correctly as far as i can i don't see the error. @dandriscoll @santhonydo

I'm having the same problem...

The problem may be that in code you are not necessarily exposing /api/messages:

var bot = new builder.UniversalBot(connector);
server.post('/api/messages', connector.listen());

I had the same problem when configuring the bot to use the URL of the application, and not the URL of the application plus /api/messages .

Even, I get the same issue. How do I access the Bot I have built over the browser and give URL to someone to test. Everytime , I need to login in azure and see it in Web chat

I get the below error when accessed through the browser

https://{mydomain}.azurewebsites.net/ .
{"code":"ResourceNotFound","message":"/ does not exist"}

https://{mydomain}.azurewebsites.net/webchat?s={direct_line_secret_key}
{"code":"ResourceNotFound","message":"/webchat does not exist"}

@nikhilabhiman

You can provide testers with this url:
https://webchat.botframework.com/embed/{YourBotHandle}?s={YourWebchatSecret}

You can find the Webchat Secret in the WebChat channel's configuration page on the Channels tab under Bot Management. You can also find the iframe embed code here.

image

For the iframe, you would need to host this on a page on your site.


Please note, this is a closed issue. Please open a new issue, or ask on Stack Overflow for future questions.

@EricDahlvang : Thanks, I did the same. That helped me.

@santhonydo what exact package where u missing in package json when u solved it

@EricDahlvang is this really the best idea to be giving your secret away?

@xtianus79 No, exposing the secret is not 'the best idea' for all production bots. In a production environment, the secret should be exchanged for a token and the secret should not be shared.

https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-authentication?view=azure-bot-service-4.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hailiang-wang picture hailiang-wang  路  3Comments

sebsylvester picture sebsylvester  路  3Comments

RaoVenka picture RaoVenka  路  3Comments

stijnherreman picture stijnherreman  路  3Comments

somprabhsharma picture somprabhsharma  路  3Comments