botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

Bot Framework Nodejs unable to connect bot after deployment on azure

Open santhonydo opened this issue 10 years ago • 18 comments

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

santhonydo avatar Sep 01 '16 05:09 santhonydo

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).

santhonydo avatar Sep 02 '16 01:09 santhonydo

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?

jameslew avatar Sep 02 '16 23:09 jameslew

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

danmarshall avatar Sep 06 '16 22:09 danmarshall

@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

Stevenic avatar Sep 12 '16 18:09 Stevenic

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"
  }
}

Stevenic avatar Sep 12 '16 18:09 Stevenic

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

dandriscoll avatar Sep 18 '16 02:09 dandriscoll

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!

santhonydo avatar Sep 18 '16 04:09 santhonydo

Thanks @santhonydo!

dandriscoll avatar Sep 18 '16 04:09 dandriscoll

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"}

ankur-bansal2016 avatar Sep 21 '16 20:09 ankur-bansal2016

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

mog28 avatar Oct 04 '16 10:10 mog28

I'm having the same problem...

pedrohma avatar Nov 01 '16 16:11 pedrohma

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 .

robintel avatar Nov 10 '16 14:11 robintel

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 avatar Jan 01 '18 19:01 nikhilabhiman

@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 avatar Jan 02 '18 20:01 EricDahlvang

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

nikhilabhiman avatar Jan 02 '18 22:01 nikhilabhiman

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

vishmonne avatar Dec 17 '18 13:12 vishmonne

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

xtianus79 avatar May 19 '20 18:05 xtianus79

@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

EricDahlvang avatar May 19 '20 19:05 EricDahlvang