我有一個chatbot我創建,要求用戶的用戶名,然後將其作爲變量存儲。但是,在我的一個對話框樹中,我不得不要求用戶輸入另一個答案,我已使其工作,以便用戶可以通過按鈕點擊進行導航。模擬chatbot切換輸入法?
關於用戶名捕獲,「輸入欄」將從控件中刪除,並附加帶有每個郵件功能的按鈕。我試圖做到這一點(刪除按鈕,並添加一個輸入)的反作用,但我無法讓我的輸入做任何事情。它不會在輸入時提交,它不會保存一個變量,在我的試驗和錯誤中,我發現如果我嘗試設置一個關閉該味精值的變量,它會更新用戶名。
這裏是我的功能,以獲取名稱
function get_username() {
send_msg("Hello I'm Mumbles, the Help Bot", function(){
send_msg("Who am I speaking with today?")
});
}
function ai(msg) {
if (username.length < 3) {
username = msg;
send_msg("Nice to meet you"+username+". What are you working on today?" , function() {
$("#controls").append(
'<button class="options one" value="my_certifications" type="button">My Certifications</button>' +
'<button class="options one" value="videos"type="button">Videos</butto/>' +
'<button class="options one" value="login"type="button">Login</butto/>' +
'<button class="options one" value="other"type="button">Other</butto/>'
);
});
}
// Remove text bar
$("#controls").empty();
};
這裏是我的功能,試圖捕捉電子郵件
} else if (b_val == "my_practicum") {
send_msg("What is the email address you submitted your practicum with? By having this we can give you a status update!" , function() {
$("#controls").append(
'<textarea id="message" class="practicum-bar" placeholder="Type Your Name - Then Hit Enter"></textarea><button style="display:none;" id="sendMsg">Send</button>' );
email = msg;
console.log(email);
});
}
}
如果你想看到這個動作,在這裏我JSFiddle。您可以通過這個用戶路徑
輸入名稱>證書>我的實習會看到它>輸入電子郵件
任何幫助表示讚賞!謝謝!
輸入電子郵件後你想要發生什麼 –
@jackblank當它運行api函數時,它會詢問後續問題(尚未放入示例中)。我只需要能夠將其存儲爲變量 –