1
votes

Deployed bot from local git repository to azure - https://docs.microsoft.com/en-us/bot-framework/deploy-bot-local-git

code :

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

var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () { });

// Create the chat connector for communicating with the Bot Framework Service
var connector = new builder.ChatConnector({
    appId: "app-id",
    appPassword: "app-password"
});

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

// Create your bot with a function to receive messages from the user
var bot = new builder.UniversalBot(connector, function (session) {
    // echo the user's message
    session.send("You said: %s", session.message.text);
});

Getting http 500 errror and message in web chat at https://dev.botframework.com -

There was an error sending this message to your bot: HTTP status code InternalServerError

I can connect to bot from Bot Framework Emulator with localhost url and App Id and password.

Maybe I need to specify that web application is nodejs? I don't see in application settings anything about entry point of app or nodejs option.

EDIT: change "main": "index.js" to "main": "app.js" but still can't send test message.

EDIT2: I add web.config to project (without any changes to suggested code), after that I get message on bot page (http://it-perf-bot.azurewebsites.net/api/messages) - The page cannot be displayed because an internal server error has occurred. Then I added IISnode.yml

loggingEnabled: true
devErrorsEnabled: true

and get this message - http://prntscr.com/gc8vww Log when push bot to azure - http://prntscr.com/gc8wia,

The package.json file does not specify node.js engine version constraints.

I add "engines":{"node": "8.1.4"} to package.json and get

The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. My bot - https://github.com/lavandil/skypeBot1.

EDIT3: While making edit2 I tested url http://it-perf-bot.azurewebsites.net/api/messages and get different warning

The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.

Then I test bot at dev.botframework.com and Bot Framework Emulator - everything is working after adding node version to package json. Thanks for replies!

2
If you are still having problems, please report this issue at: github.com/microsoft/botbuilder/issues/new - nilsw

2 Answers

3
votes

Maybe I need to specify that web application is nodejs? I don't see in application settings anything about entry point of app or nodejs option.

What you need to do is create a web.config file in the root of your Node.js application if not exists. For reference, the below is a default web.config for an application that uses app.js as the entry point.

<?xml version="1.0" encoding="UTF-8"?>
<!--
       This configuration file is required if iisnode is used to run node processes behind
       IIS or IIS Express.  For more information, visit:

       https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config
  -->
<configuration>
  <system.webServer>
    <!-- Visit http://blogs.msdn.com/b/windowsazure/archive/2013/11/14/introduction-to-websockets-on-windows-azure-web-sites.aspx for more information on WebSocket support -->
    <webSocket enabled="false" />
    <handlers>
      <!-- Indicates that the server.js file is a node.js web app to be handled by the iisnode module -->
      <add name="iisnode" path="app.js" verb="*" modules="iisnode" />
    </handlers>
    <rewrite>
      <rules>
        <!-- Do not interfere with requests for node-inspector debugging -->
        <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="^app.js\/debug[\/]?" />
        </rule>
        <!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
        <rule name="StaticContent">
          <action type="Rewrite" url="public{REQUEST_URI}" />
        </rule>
        <!-- All other URLs are mapped to the node.js web app entry point -->
        <rule name="DynamicContent">
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True" />
          </conditions>
          <action type="Rewrite" url="app.js" />
        </rule>
      </rules>
    </rewrite>
    <!--
        You can control how Node is hosted within IIS using the following options:
          * watchedFiles: semi-colon separated list of files that will be watched for changes to restart the server
          * node_env: will be propagated to node as NODE_ENV environment variable
          * debuggingEnabled - controls whether the built-in debugger is enabled

        See https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config for a full list of options
      -->
    <!--<iisnode watchedFiles="web.config;*.js"/>-->
  </system.webServer>
</configuration>

Also, for 500 error, you'll need to enable logging of stdout and stderr for troubleshooting and see what the logs say. To enable debugging, please refer to my earlier answer here.

0
votes

While making edit2 I test url http://it-perf-bot.azurewebsites.net/api/messages and get different warning

The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used. Then I test bot at dev.botframework.com and Bot Framework Emulator - everything is working after adding node version to package json. Thanks for replies!