Bot responds with "undefined"
System Information
- SDK Platform: Node
- SDK Version: 3.8.3
- Development Environment: Azure App Service
Issue Description
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.
Example Code
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: Anish BOT: Hello, Anish. 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)
I'm not really sure but I think I started experiencing this issue since I upgraded to BotBuilder 3.8.3.
Why is that undefined message being sent? How can I stop it?
Works fine if I removed session.endConversation();
Duplicate of https://stackoverflow.com/questions/44246376/bot-framework-bot-responds-with-undefined