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

[Question] Different behaviour of prompts in emulator and azure

Open Jake1996 opened this issue 9 years ago • 2 comments

System Information (Required)

  • SDK Platform: windows 10
  • SDK Version: 3.0.2(botbuilder-azure),3.8.3(botbuilder),restify(4.3.0)
  • Development Environment: localhost | Azure Bot Service | Azure App Service | other

Issue Description

When a prompt occurs in a dialog that is being called in bot.on(), the prompt behaves differently on azure and emulator

Example Code

// For more information about this template visit http://aka.ms/azurebots-node-qnamaker

"use strict";

var builder = require('botbuilder');
var botbuilder_azure = require("botbuilder-azure");
var path = require('path');

//ENV variables are checked for development mode
require('dotenv').load();
var useEmulator = (process.env.NODE_ENV == 'development');


//Universal Bot is configured by chatconnector to communicate either with the emulator or any other channels.
var connector = useEmulator ? new builder.ChatConnector() : new botbuilder_azure.BotServiceConnector({
    appId: process.env['MicrosoftAppId'],
    appPassword: process.env['MicrosoftAppPassword'],
    stateEndpoint: process.env['BotStateEndpoint'],
    openIdMetadata: process.env['BotOpenIdMetadata']
});
if (useEmulator) {
    var restify = require('restify');
    var server = restify.createServer();
    server.listen(3978, function() {
        console.log('test bot endpont at http://localhost:3978/api/messages');
    });
    server.post('/api/messages', connector.listen());
} else {
    module.exports = { default: connector.listen() }
}

 
var bot = new builder.UniversalBot(connector);
bot.localePath(path.join(__dirname, './locale'));

bot.on('conversationUpdate', function (message,session) {
    if (message.membersAdded) {
        message.membersAdded.forEach(function (identity) {
            if (identity.id === message.address.bot.id) {
                bot.beginDialog(message.address,'/next');
		
            }
        });
    }
});

bot.dialog('/next',[
    function(session,args,next)
    {
		builder.Prompts.text(session,"Enter your name");
	},
    function(session) {
        session.userData.name = session.message.text;
        session.endDialog();
    }
    
]);
	
bot.dialog('/',[
	function(session) {
        session.send("Hello "+ session.userData.name);
	
}]);

Steps to Reproduce

  1. Create a new simple bot on azure with the same code and one on the local system
  2. Run the bots on azure and localsystem
  3. enter your name and notice how they give different outputs

Expected Behavior

both the bots should have printed hello nameOfUser

Actual Results

When the bot ran locally on the emulator, the flow went to the second step of the waterfall in dialog '/next' whereas on azure we do not see this happen and after the prompt statement our input is being handled by '/' dialog and not the second step of the waterfall captureissue1 captureissue2

Jake1996 avatar May 31 '17 15:05 Jake1996

@Jake1996 The Node.js app templates from the Azure Bot Service have a specific purpose, which is to demonstrate the functionality of the Bot Service. They are not necessarily designed for local deployment as you observed. This is expected behavior.

nwhitmont avatar Jun 01 '17 19:06 nwhitmont

Isn't the local environment and the emulator designed for development ? If so, then differing behaviour is rather detrimental.

nebgor avatar Jan 23 '18 02:01 nebgor