const Mocha = require("mocha")
const mochaReporter = require("mocha-unfunk-reporter")
const BotDriver = require("botium-core").BotDriver
const answers = [
{
input: ['buttons', 'show me buttons', 'show me some buttons', 'give me buttons'],
output: {
messageText: 'Here are some buttons',
buttons: [
{ text: 'First Button' },
{ text: 'Second Button' }
]
}
},
{
input: ['picture', 'show me a picture', 'give me a picture'],
output: {
messageText: 'Here is a picture',
media: [
{ altText: 'Botium Logo', mediaUri: 'http://www.botium.at/img/logo.png' }
]
}
},
{
input: ['card', 'show me a card', 'give me a card'],
output: {
messageText: 'Here is a card',
cards: [
{
text: 'Botium is great!',
image: { mediaUri: 'http://www.botium.at/img/logo.png' },
buttons: [
{ text: 'First Button' },
{ text: 'Second Button' }
]
}
]
}
}
]
const bot = ({ queueBotSays }) => ({
UserSays (msg) {
const template = answers.find((a) => a.input.indexOf(msg.messageText) >= 0)
if (template)
setTimeout(() => queueBotSays(Object.assign({}, { sender: 'bot', sourceData: msg }, template.output)), 0)
else
setTimeout(() => queueBotSays({ sender: 'bot', sourceData: msg, messageText: 'You said: ' + msg.messageText }), 0)
}
})