So, I build a messenger bot using node js. How can I make:
- Whenever user send a random text (except the right command) the Bot will reply "Sorry I cant recognize that command"..
- How to make bot storing the Text from user and will confirm later ? Example : USER : Hello. BOT : What Else ? USER : World. BOT : What Else ? USER : done. BOT : I understood, BOT : 1. Hello BOT : 2. World BOT : Is that correct ?
Here is my current scripts for no. 1 :
function replyByText(sender, text, payload) {
let kata = text.toLowerCase()
let date = new Date()
let current_hour = date.getHours()
if (S(kata).contains('produk') || S(kata).contains('produknya') || S(kata).contains('product')) {
sendOpeningProduct(sender, "Wait Sec..")
}
if (S(kata).contains('layanan')|| S(kata).contains('services')|| S(kata).contains('diagnose')){
// sendOpeningServices(sender, 'Wait sec..' )
sendPlainMessage(sender, 'Hi, what concern you most about your health? Please describe your symptoms..' )
}
if (S(kata).contains('health symptoms')){
sendPlainMessage(sender, 'Tell me What You Feel..' )
}
if (S(kata).contains('im feeling sick') || S(kata).contains('im feeling unwell') || S(kata).contains('im feeling dizzy') || S(kata).contains('dizzy') || S(kata).contains('sick')){
sendPlainMessage(sender, 'How old are you ?' )
}
if (S(kata).contains('3') || S(kata).contains('4') || S(kata).contains('5') || S(kata).contains('6') || S(kata).contains('7') || S(kata).contains('8') || S(kata).contains('9')){
sendPlainMessage(sender, 'I see...' )
sendOpeningProductKids(sender, "Just try our products")
}}
Any help will appreciate..