I have a simple chatbot which takes the user's name and replies asking how it can help them. It works fine in the emulator and webchat but when I tried that as an android app via DirectLine I'm getting an additional prompt which is just empty. So I put some code to log the bot's conversation and I found that the bot is sending a message "undefined" along with the prompt I programmed it to send.
My Code sample
bot.dialog('/', new builder.IntentDialog()
.matchesAny([/hi/i], [
function (session) {
session.send('Hi, I am a chatbot.');
session.beginDialog('/step2')
},
bot.dialog('/step2', [
function (session) {
builder.Prompts.text(session,'What is your name?');
},
function(session, args, next) {
session.send('Hello, ' + args.response + '. How may I help you today?');
name = args.response;
session.endConversation();
}
])
]
));
When I put in some middleware logging, I got the following output:
USER: Hi
BOT: Hi, I am a chatbot.
BOT: What is your name?
USER: Bob
BOT: Hello, Bob. How may I help you today?
BOT: undefined
Even my node console shows that 2 messages are sent at the end instead of just one
ChatConnector: message received.
UniversalBot("*") routing "Anish" from "emulator"
Library("BotBuilder").findRoutes() explanation:
ActiveDialog(0.5)
..BotBuilder:prompt-text - Prompt.returning(Anish)
..BotBuilder:prompt-text - Session.endDialogWithResult()
./step2 - waterfall() step 2 of 2
./step2 - Session.send()
./step2 - Session.endConversation()
Session.sendBatch() sending 2 message(s)
Why is that undefined message being sent? How can I stop it?
via Anish
No comments:
Post a Comment