microsoft / botframework-sdk

Bot Framework provides the most comprehensive experience for building conversation applications.
MIT License
7.48k stars 2.44k forks source link

Multiple session.send() #297

Closed mikkhait closed 8 years ago

mikkhait commented 8 years ago

I know this is a duplicate(#107 #259), but I want to bubble it up.

@Stevenic, I am still experiencing issues with multiple session.send() even better... I'm trying to send a message, then start a dialog...

  function (session) {
    session.send("Let's begin");
    session.beginDialog('/begin');
  }

Does not work with Emulator or Facebook, so I assume does not work for BotFramework altogether.

The second message just gets swallowed.

theotheo commented 8 years ago

How does '/begin' dialog look like?

mikkhait commented 8 years ago
bot.add('/begin', [
  function (session) {
    builder.Prompts.choice(session, "What would you like to do?", ['Start Trivia', 'See Help']);
  },
  function (session, results) {
    // handle results
}]);
Stevenic commented 8 years ago

Are you running v0.10.2?

mikkhait commented 8 years ago

Yes

mikkhait commented 8 years ago

https://www.dropbox.com/s/sthdzrb2e5ucpld/Screenshot%202016-05-17%2021.44.49.png?dl=0

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

// Create bot and add dialogs
var bot = new builder.BotConnectorBot({ appId: 'YourAppId', appSecret: 'YourAppSecret' });
bot.add('/', function (session) {
   session.send('Hello World');
   session.send('Hello World2');
});

// Setup Restify Server
var server = restify.createServer();
server.post('/api/messages', bot.verifyBotFramework(), bot.listen());
server.listen(process.env.port || 3000, function () {
   console.log('%s listening to %s', server.name, server.url);
});
{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "botbuilder": "^0.10.2",
    "restify": "^4.0.4"
  }
}
Stevenic commented 8 years ago

This definitely works... That code wouldn't work when deployed for facebook because your app ID & Secret are wrong but should work with the latest build of the emulator. Are you on a mac or pc?

Stevenic commented 8 years ago

You're not running the bot in a VM are you?

Stevenic commented 8 years ago

The emulate runs a webserver so if it's not working its because the bot can't see the emulators server. It assumes it's running on localhost:9000

mikkhait commented 8 years ago

Steve, I'm running on VM, I do have explicit endpoint specified to my VM, I'm the one created a #282.

I am running latest copy of Emulator. The example above is for testing purpose only, I do realize it will not work with live FB.

var bot = new builder.BotConnectorBot({
  appId: settings.botConnector.appId,
  appSecret: settings.botConnector.appSecret,
  endpoint: 'http://192.168.0.108:9000'
});
mikkhait commented 8 years ago

linking #286

Stevenic commented 8 years ago

I'll assign to Tom as it would have to be an issue on the emulator side. The emulator runs a web server which is required for the second+ messages to work. Tom designed it assuming that it would be run on localhost so maybe there's something blocking the incoming request since they're coming from a different machine.

mikkhait commented 8 years ago

Thanks, just to be clear, this is also an issue with testing with Facebook connected to BotConnector.

Stevenic commented 8 years ago

We're working on it. Having a hard time nailing it down.

Stevenic commented 8 years ago

We finally tracked down the issue. I just published v0.11.1 which should resolve the issue. Sorry about that.

mikkhait commented 8 years ago

ok, I'm closing this item. Let me know if you want me to open a new one, related to Emulator not working as expected with this case.

SushmitaSahu commented 7 years ago

Hi, I have written a dummy bot using the latest botbuilder version : 3.4.4. My sample code is: var server = restify.createServer(); server.listen(config.port,config.ip,function () { try{ console.log('%s listening to %s', server.name, server.url); console.log("Welcome to Banker Bot!!!!"); } catch(err){ console.log("Server already in Use" + err); }

}); var connector = new builder.ChatConnector({ appId: config.MICROSOFT_APP_ID, appPassword: config.MICROSOFT_APP_PASSWORD

}); var bot = new builder.UniversalBot(connector); server.post('/api/messages', connector.listen()); var recognizer = new builder.LuisRecognizer(config.model); bot.dialog('/', [ function (session) { session.beginDialog('/askName'); }, function (session, results) { session.send('Hello %s!', results.response); } ]); bot.dialog('/askName', [ function (session) { builder.Prompts.text(session, 'Hi! What is your name?'); }, function (session, results) { session.endDialogWithResult(results); } ]); I am trying to talk to my bot using emulator. I am able to connect to bot as I get : "ChatConnector: Message Received" when I type anything, then I get a session.error(). Please guide me as to where I am going wrong. I am completely novice to chatbot and nodejs. Thanks in advance

Stevenic commented 7 years ago

I don't see anything obviously wrong. Could you please start a new issue versus adding on to a closed one? Thanks!