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

does the web chat iframe support multiple messages in a response?

Open xmark opened this issue 10 years ago • 9 comments

I embedded the iframe into a custom site for testing and when I call the bot framework nodejs API:

session.send("my message");

followed by:

builder.Prompts.text(session, 'Please enter y/n');

On the emulator locally, I get the follow-up prompt, but the web chat iframe doesnt even send the second message. Also, this occurs on Slack as well... Is that just a limitation of the iframe application/slack channel that was built?

xmark avatar May 26 '16 23:05 xmark

It's likely your AppId or AppSecret aren't properly setup. Can you share your bots setup code?

Stevenic avatar May 27 '16 19:05 Stevenic

Which code are you after exactly? The iframe code, or the nodejs bot setup?

xmark avatar May 28 '16 00:05 xmark

The NodeJS code please.

Stevenic avatar May 28 '16 17:05 Stevenic

I'll try to show you as best as I can, Im just going to remove some of my private code as best I can.

Note, I have removed the application id and subscription key from the code below, I can provide these to you privately if need be?

var restify = require('restify');
var builder = require('botbuilder');
var gd = require("./dialogs/greeting-dialog.js");
var model = 'https://api.projectoxford.ai/luis/v1/application?id=MY_APP_ID&subscription-key=SUB_KEY';

var dialog = new builder.LuisDialog(model);
var myBot = new builder.BotConnectorBot();
var server = restify.createServer();

myBot.add('/', dialog);
gd.welcomeDialog(dialog);

dialog.onDefault(builder.DialogAction.send("I'm sorry I didn't understand."));

// Serve a static web page
server.get(/.*/, restify.serveStatic({
    'directory': '.',
    'default': 'index.html'
}));

server.post('/api/messages', myBot.listen());

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

The code : gd.welcomeDialog(dialog); is where I enact the multiple inputs as I mentioned is the original post.

xmark avatar May 29 '16 01:05 xmark

On the line below you should provide your bots AppId & AppSecret:

var myBot = new builder.BotConnectorBot();

And on the line below you should probably include a call to myBot.verifyBotFramework().

server.post('/api/messages', myBot.listen());

It's not required but helps make your bot more secure. You can leave it out until you get everything else working.

Stevenic avatar May 29 '16 19:05 Stevenic

Hey Stevenic, are you saying that this is the cause of the issue with the iframe/slack channel? Or is this just best practice?

xmark avatar May 29 '16 23:05 xmark

The first issue is likely why your bot isn't working with the WebChat control. The second is a best practice.

Stevenic avatar May 30 '16 19:05 Stevenic

Sorry Stevenic, I implemented your suggestions and it simply doesnt seem to respond with multiple responses... but still works fine in the emulator

xmark avatar Jun 05 '16 23:06 xmark

Closing this issue. @xmark - please open a new issue if this issue is not fixed and needs further discussion. @Stevenic - reopen if necessary. Thanks!

v-thgratMSGit avatar Jul 12 '16 22:07 v-thgratMSGit