我有一個簡單的聊天機器人,它接受用戶的姓名並回復詢問如何幫助他們。它在模擬器和網絡聊天工作正常,但當我通過DirectLine作爲Android應用程序嘗試時,我得到一個額外的提示,只是空的。所以我把一些代碼記錄在機器人的對話中,我發現機器人發送一條消息「未定義」以及我編程發送的提示。Bot Framework:Bot迴應「未定義」
我的代碼示例
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();
}
])
]));
當我把一些中間件日誌,我得到了以下的輸出:
USER:嗨
BOT:您好,我是一名聊天機器人。
BOT:你叫什麼名字?
用戶:Bob
BOT:你好,鮑勃。我今天怎麼可以幫你?
BOT:未定義
即使我的節點控制檯顯示2條消息在年底,而不是僅僅一個
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)
發送這是爲什麼發送消息未定義?我怎樣才能阻止它?
你會發生什麼事刪除'Session.endConversation()'? –
@EzequielJadib哇,工作。爲什麼'Session.endconversation()'造成這種情況? – Anish
但是,如果我不使用'session.endconversation()',機器人進入循環並詢問我的名字是什麼時候回覆「我可以如何幫助你」 – Anish