Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
const {BotkitConversation} = require("botkit");
const MY_DIALOG_ID = 'my-dialog-name-constant';
let convo = new BotkitConversation(MY_DIALOG_ID, controller);
module.exports = function(controller) {
//gretting and presentation
controller.on('hello',function(bot,message){
bot.reply(message,'Hi my name is Fit01 your personal fitness trainer, How I can help you today');
});
controller.on('welcome_back',function(bot,message){
bot.reply(message,'Ready for a new fitness session?, What would you like to do today?');
});
controller.hears([hi, hello,],'message_received',function(bot,message){
bot.reply(message,{
text: 'Hi are you alright?',
typingDelay: 1000,
});
});
// ask a question, handle the response with a function
convo.ask('What is your name?', async(response, convo, bot, full_message) => {
await bot.say('Oh your name is ' + response);
}, {key: 'name'});
// ask a question, evaluate answer, take conditional action based on response
convo.ask('Do you want to try 10 minutes workout today?', [
{
pattern: 'yes',
type: 'string',
handler: async(response_text, convo, bot, full_message) => {
return await convo.gotoThread('OK then let is start');
}
},
{
pattern: 'no',
type: 'string',
handler: async(response_text, convo, bot, full_message) => {
return await convo.gotoThread('oooh, maybe would yuo like to start with a different exercice?');
}
},
{
default: true,
handler: async(response_text, convo, bot, full_message) => {
await bot.say('I do not understand your response!');
// start over!
return await convo.repeat();
}
}
], {key: 'workout'});
}