mercredi 30 décembre 2015

if else statement chatbot

I try to make a simple chat bot. So far the bot answer is user type in defined question. But how can I make it that the chatbot gives out a "sorry I don't understand" if user ask something that is not defined?

function ai(message){
            if (username.length<3){
                username = message;
                send_message("Nice to meet you " + username + ", how are you today?");
                responsiveVoice.speak("Nice to meet you " + username + ", how are you today?");
            }

            if (message.toLowerCase().indexOf("how are you")>=0){
                send_message("Thanks, Iam good!");
                responsiveVoice.speak("Thanks, Iam good!");
            }

Aucun commentaire:

Enregistrer un commentaire