Sorry für meine schlechte Englisch, aber ich gebe mein Bestes :) Ich habe eine Frage und ich hoffe, ich bin hier, um eine Antwort zu finden. Ich möchte einen Offline-Chatbot in html/css/js erstellen und das Programm Intel XDK verwenden.Chatbot Antwort/Antwort Code in js
- Ich weiß nicht, wie man dem Chatbot einen speziellen Befehl gibt? Also, dass er auf spezielle Wörter/Themen antwortet. Hier ist ein Beispiel: "Me: hey" "Bot: hey/hallo"
2.Die nächste Problem ist, eine Reaktionszeit auf spezielle Wörter/Themen zu erstellen. Ein Beispiel: Wenn ich "hey" sage, muss die Reaktionszeit von Chatbot von "1min" sein.
Ich benutze diesen index.js Code
var $messages = $('.messages-content'),
d, h, m,
i = 0;
$(window).load(function() {
$messages.mCustomScrollbar();
setTimeout(function() {
fakeMessage();
}, 100);
});
function updateScrollbar() {
$messages.mCustomScrollbar("update").mCustomScrollbar('scrollTo', 'bottom', {
scrollInertia: 10,
timeout: 0
});
}
function setDate(){
d = new Date()
if (m != d.getMinutes()) {
m = d.getMinutes();
$('<div class="timestamp">' + d.getHours() + ':' + m + '</div>').appendTo($('.message:last'));
}
}
function insertMessage() {
msg = $('.message-input').val();
if ($.trim(msg) == '') {
return false;
}
$('<div class="message message-personal">' + msg + '</div>').appendTo($('.mCSB_container')).addClass('new');
setDate();
$('.message-input').val(null);
updateScrollbar();
setTimeout(function() {
fakeMessage();
}, 1000 + (Math.random() * 20) * 100);
}
$('.message-submit').click(function() {
insertMessage();
});
$(window).on('keydown', function(e) {
if (e.which == 13) {
insertMessage();
return false;
}
})
var Fake = [
'Hi there, I\'m Fabio and you?',
'Nice to meet you',
'How are you?',
'Not too bad, thanks',
'What do you do?',
'That\'s awesome',
'Codepen is a nice place to stay',
'I think you\'re a nice person',
'Why do you think that?',
'Can you explain?',
'Anyway I\'ve gotta go now',
'It was a pleasure chat with you',
'Time to make a new codepen',
'Bye',
':)'
]
function fakeMessage() {
if ($('.message-input').val() != '') {
return false;
}