mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-17 19:26:23 +00:00
test: 🔥 a lot test e2e
This commit is contained in:
89
__test__/0.1.1-case.test.js
Normal file
89
__test__/0.1.1-case.test.js
Normal file
@@ -0,0 +1,89 @@
|
||||
const { suite } = require('uvu')
|
||||
const assert = require('uvu/assert')
|
||||
const { addKeyword, createBot, createFlow } = require('../packages/bot/index')
|
||||
const { setup, clear, delay } = require('../__mocks__/env')
|
||||
|
||||
const fakeHTTP = async () => {
|
||||
await delay(10)
|
||||
}
|
||||
|
||||
const suiteCase = suite('Flujo: hijos con callbacks')
|
||||
|
||||
suiteCase.before.each(setup)
|
||||
suiteCase.after.each(clear)
|
||||
|
||||
suiteCase(`Debe continuar el flujo del hijo`, async ({ database, provider }) => {
|
||||
const flowCash = addKeyword('cash').addAnswer('Traeme los billetes! 😎')
|
||||
|
||||
const flowOnline = addKeyword('paypal')
|
||||
.addAnswer('Voy generar un link de paypal *escribe algo*', { capture: true }, async (_, { flowDynamic }) => {
|
||||
await fakeHTTP()
|
||||
await flowDynamic('Esperate.... estoy generando esto toma su tiempo')
|
||||
})
|
||||
.addAnswer('Aqui lo tienes 😎😎', null, async (_, { flowDynamic }) => {
|
||||
await fakeHTTP()
|
||||
await flowDynamic('http://paypal.com')
|
||||
})
|
||||
.addAnswer('Apurate!')
|
||||
|
||||
const flujoPrincipal = addKeyword('hola')
|
||||
.addAnswer('¿Como estas todo bien?')
|
||||
.addAnswer('Espero que si')
|
||||
.addAnswer('¿Cual es tu email?', { capture: true }, async (ctx, { fallBack }) => {
|
||||
if (!ctx.body.includes('@')) {
|
||||
return fallBack('Veo que no es um mail *bien*')
|
||||
}
|
||||
})
|
||||
.addAnswer('Voy a validar tu email...', null, async (_, { flowDynamic }) => {
|
||||
await fakeHTTP()
|
||||
return flowDynamic('Email validado correctamten!')
|
||||
})
|
||||
.addAnswer('¿Como vas a pagar *paypal* o *cash*?', { capture: true }, async () => {}, [flowCash, flowOnline])
|
||||
|
||||
createBot({
|
||||
database,
|
||||
flow: createFlow([flujoPrincipal]),
|
||||
provider,
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(0, 'message', {
|
||||
from: '000',
|
||||
body: 'hola',
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(10, 'message', {
|
||||
from: '000',
|
||||
body: 'test@test.com',
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(15, 'message', {
|
||||
from: '000',
|
||||
body: 'paypal',
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(20, 'message', {
|
||||
from: '000',
|
||||
body: 'continue!',
|
||||
})
|
||||
|
||||
await delay(500)
|
||||
const getHistory = database.listHistory.map((i) => i.answer)
|
||||
|
||||
assert.is('¿Como estas todo bien?', getHistory[0])
|
||||
assert.is('Espero que si', getHistory[1])
|
||||
assert.is('¿Cual es tu email?', getHistory[2])
|
||||
assert.is('test@test.com', getHistory[3])
|
||||
assert.is('Voy a validar tu email...', getHistory[4])
|
||||
assert.is('Email validado correctamten!', getHistory[5])
|
||||
assert.is('¿Como vas a pagar *paypal* o *cash*?', getHistory[6])
|
||||
assert.is('paypal', getHistory[7])
|
||||
assert.is('Voy generar un link de paypal *escribe algo*', getHistory[8])
|
||||
assert.is('continue!', getHistory[9])
|
||||
assert.is('Esperate.... estoy generando esto toma su tiempo', getHistory[10])
|
||||
assert.is('Aqui lo tienes 😎😎', getHistory[11])
|
||||
assert.is('http://paypal.com', getHistory[12])
|
||||
assert.is('Apurate!', getHistory[13])
|
||||
assert.is(undefined, getHistory[14])
|
||||
})
|
||||
|
||||
suiteCase.run()
|
||||
@@ -1,59 +0,0 @@
|
||||
const { suite } = require('uvu')
|
||||
const assert = require('uvu/assert')
|
||||
const { addKeyword, createBot, createFlow } = require('../packages/bot/index')
|
||||
const { setup, clear, delay } = require('../__mocks__/env')
|
||||
|
||||
const suiteCase = suite('Flujo: regex')
|
||||
|
||||
suiteCase.before.each(setup)
|
||||
suiteCase.after.each(clear)
|
||||
|
||||
suiteCase(`Responder a una expresion regular`, async ({ database, provider }) => {
|
||||
const REGEX_CREDIT_NUMBER = `/(^4[0-9]{12}(?:[0-9]{3})?$)|(^(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$)|(3[47][0-9]{13})|(^3(?:0[0-5]|[68][0-9])[0-9]{11}$)|(^6(?:011|5[0-9]{2})[0-9]{12}$)|(^(?:2131|1800|35\d{3})\d{11}$)/gm`
|
||||
|
||||
const flow = addKeyword(REGEX_CREDIT_NUMBER, { regex: true })
|
||||
.addAnswer(`Gracias por proporcionar un numero de tarjeta valido`)
|
||||
.addAnswer('Fin!')
|
||||
|
||||
createBot({
|
||||
database,
|
||||
provider,
|
||||
flow: createFlow([flow]),
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(0, 'message', {
|
||||
from: '000',
|
||||
body: '374245455400126',
|
||||
})
|
||||
|
||||
await delay(10)
|
||||
|
||||
assert.is('Gracias por proporcionar un numero de tarjeta valido', database.listHistory[0].answer)
|
||||
assert.is('Fin!', database.listHistory[1].answer)
|
||||
assert.is(undefined, database.listHistory[2])
|
||||
})
|
||||
|
||||
suiteCase(`NO Responder a una expresion regular`, async ({ database, provider }) => {
|
||||
const REGEX_CREDIT_NUMBER = `/(^4[0-9]{12}(?:[0-9]{3})?$)|(^(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$)|(3[47][0-9]{13})|(^3(?:0[0-5]|[68][0-9])[0-9]{11}$)|(^6(?:011|5[0-9]{2})[0-9]{12}$)|(^(?:2131|1800|35\d{3})\d{11}$)/gm`
|
||||
const flow = addKeyword(REGEX_CREDIT_NUMBER, { regex: true })
|
||||
.addAnswer(`Gracias por proporcionar un numero de tarjeta valido`)
|
||||
.addAnswer('Fin!')
|
||||
|
||||
createBot({
|
||||
database,
|
||||
provider,
|
||||
flow: createFlow([flow]),
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(0, 'message', {
|
||||
from: '000',
|
||||
body: 'hola',
|
||||
})
|
||||
|
||||
await delay(10)
|
||||
|
||||
assert.is(undefined, database.listHistory[0])
|
||||
assert.is(undefined, database.listHistory[1])
|
||||
})
|
||||
|
||||
suiteCase.run()
|
||||
@@ -3,15 +3,41 @@ const assert = require('uvu/assert')
|
||||
const { addKeyword, createBot, createFlow } = require('../packages/bot/index')
|
||||
const { setup, clear, delay } = require('../__mocks__/env')
|
||||
|
||||
const suiteCase = suite('Flujo: capture')
|
||||
const suiteCase = suite('Flujo: regex')
|
||||
|
||||
suiteCase.before.each(setup)
|
||||
suiteCase.after.each(clear)
|
||||
|
||||
suiteCase(`Responder a "pregunta"`, async ({ database, provider }) => {
|
||||
const flow = addKeyword(['hola'])
|
||||
.addAnswer(['Hola como estas?', '¿Cual es tu edad?'], { capture: true })
|
||||
.addAnswer('Gracias por tu respuesta')
|
||||
suiteCase(`Responder a una expresion regular`, async ({ database, provider }) => {
|
||||
const REGEX_CREDIT_NUMBER = `/(^4[0-9]{12}(?:[0-9]{3})?$)|(^(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$)|(3[47][0-9]{13})|(^3(?:0[0-5]|[68][0-9])[0-9]{11}$)|(^6(?:011|5[0-9]{2})[0-9]{12}$)|(^(?:2131|1800|35\d{3})\d{11}$)/gm`
|
||||
|
||||
const flow = addKeyword(REGEX_CREDIT_NUMBER, { regex: true })
|
||||
.addAnswer(`Gracias por proporcionar un numero de tarjeta valido`)
|
||||
.addAnswer('Fin!')
|
||||
|
||||
createBot({
|
||||
database,
|
||||
provider,
|
||||
flow: createFlow([flow]),
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(0, 'message', {
|
||||
from: '000',
|
||||
body: '374245455400126',
|
||||
})
|
||||
|
||||
await delay(10)
|
||||
|
||||
assert.is('Gracias por proporcionar un numero de tarjeta valido', database.listHistory[0].answer)
|
||||
assert.is('Fin!', database.listHistory[1].answer)
|
||||
assert.is(undefined, database.listHistory[2])
|
||||
})
|
||||
|
||||
suiteCase(`NO Responder a una expresion regular`, async ({ database, provider }) => {
|
||||
const REGEX_CREDIT_NUMBER = `/(^4[0-9]{12}(?:[0-9]{3})?$)|(^(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$)|(3[47][0-9]{13})|(^3(?:0[0-5]|[68][0-9])[0-9]{11}$)|(^6(?:011|5[0-9]{2})[0-9]{12}$)|(^(?:2131|1800|35\d{3})\d{11}$)/gm`
|
||||
const flow = addKeyword(REGEX_CREDIT_NUMBER, { regex: true })
|
||||
.addAnswer(`Gracias por proporcionar un numero de tarjeta valido`)
|
||||
.addAnswer('Fin!')
|
||||
|
||||
createBot({
|
||||
database,
|
||||
@@ -24,17 +50,10 @@ suiteCase(`Responder a "pregunta"`, async ({ database, provider }) => {
|
||||
body: 'hola',
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(10, 'message', {
|
||||
from: '000',
|
||||
body: '90',
|
||||
})
|
||||
await delay(10)
|
||||
|
||||
await delay(20)
|
||||
|
||||
assert.is(['Hola como estas?', '¿Cual es tu edad?'].join('\n'), database.listHistory[0].answer)
|
||||
assert.is('90', database.listHistory[1].answer)
|
||||
assert.is('Gracias por tu respuesta', database.listHistory[2].answer)
|
||||
assert.is(undefined, database.listHistory[3])
|
||||
assert.is(undefined, database.listHistory[0])
|
||||
assert.is(undefined, database.listHistory[1])
|
||||
})
|
||||
|
||||
suiteCase.run()
|
||||
|
||||
@@ -3,41 +3,15 @@ const assert = require('uvu/assert')
|
||||
const { addKeyword, createBot, createFlow } = require('../packages/bot/index')
|
||||
const { setup, clear, delay } = require('../__mocks__/env')
|
||||
|
||||
const fakeHTTP = async (fakeData = []) => {
|
||||
await delay(50)
|
||||
const data = fakeData.map((u) => ({ body: `${u}` }))
|
||||
return Promise.resolve(data)
|
||||
}
|
||||
|
||||
const suiteCase = suite('Flujo: flowDynamic')
|
||||
const suiteCase = suite('Flujo: capture')
|
||||
|
||||
suiteCase.before.each(setup)
|
||||
suiteCase.after.each(clear)
|
||||
|
||||
suiteCase(`Responder con mensajes asyncronos`, async ({ database, provider }) => {
|
||||
const MOCK_VALUES = [
|
||||
'Bienvenido te envio muchas marcas (5510)',
|
||||
'Seleccione marca del auto a cotizar, con el *número* correspondiente',
|
||||
'Seleccione la sub marca del auto a cotizar, con el *número* correspondiente:',
|
||||
'Los precios rondan:',
|
||||
]
|
||||
suiteCase(`Responder a "pregunta"`, async ({ database, provider }) => {
|
||||
const flow = addKeyword(['hola'])
|
||||
.addAnswer(MOCK_VALUES[0], null, async (_, { flowDynamic }) => {
|
||||
const data = await fakeHTTP(['Ford', 'GM', 'BMW'])
|
||||
return flowDynamic(data)
|
||||
})
|
||||
.addAnswer(MOCK_VALUES[1], null, async (_, { flowDynamic }) => {
|
||||
const data = await fakeHTTP(['Ranger', 'Explorer'])
|
||||
return flowDynamic(data)
|
||||
})
|
||||
.addAnswer(MOCK_VALUES[2], null, async (_, { flowDynamic }) => {
|
||||
const data = await fakeHTTP(['Usado', 'Nuevos'])
|
||||
return flowDynamic(data)
|
||||
})
|
||||
.addAnswer(MOCK_VALUES[3], null, async (_, { flowDynamic }) => {
|
||||
const data = await fakeHTTP(['1000', '2000', '3000'])
|
||||
return flowDynamic(data)
|
||||
})
|
||||
.addAnswer(['Hola como estas?', '¿Cual es tu edad?'], { capture: true })
|
||||
.addAnswer('Gracias por tu respuesta')
|
||||
|
||||
createBot({
|
||||
database,
|
||||
@@ -50,113 +24,17 @@ suiteCase(`Responder con mensajes asyncronos`, async ({ database, provider }) =>
|
||||
body: 'hola',
|
||||
})
|
||||
|
||||
await delay(1200)
|
||||
const getHistory = database.listHistory.map((i) => i.answer)
|
||||
assert.is(MOCK_VALUES[0], getHistory[0])
|
||||
|
||||
//FlowDynamic
|
||||
assert.is('Ford', getHistory[1])
|
||||
assert.is('GM', getHistory[2])
|
||||
assert.is('BMW', getHistory[3])
|
||||
|
||||
assert.is(MOCK_VALUES[1], getHistory[4])
|
||||
|
||||
//FlowDynamic
|
||||
assert.is('Ranger', getHistory[5])
|
||||
assert.is('Explorer', getHistory[6])
|
||||
|
||||
assert.is(MOCK_VALUES[2], getHistory[7])
|
||||
|
||||
//FlowDynamic
|
||||
assert.is('Usado', getHistory[8])
|
||||
assert.is('Nuevos', getHistory[9])
|
||||
|
||||
assert.is(MOCK_VALUES[3], getHistory[10])
|
||||
|
||||
//FlowDynamic
|
||||
assert.is('1000', getHistory[11])
|
||||
assert.is('2000', getHistory[12])
|
||||
assert.is('3000', getHistory[13])
|
||||
assert.is(undefined, getHistory[14])
|
||||
})
|
||||
|
||||
suiteCase(`Responder con un "string"`, async ({ database, provider }) => {
|
||||
const flow = addKeyword(['hola'])
|
||||
.addAnswer('Como vas?', null, async (_, { flowDynamic }) => {
|
||||
return flowDynamic('Todo bien!')
|
||||
})
|
||||
.addAnswer('y vos?')
|
||||
|
||||
createBot({
|
||||
database,
|
||||
provider,
|
||||
flow: createFlow([flow]),
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(0, 'message', {
|
||||
await provider.delaySendMessage(10, 'message', {
|
||||
from: '000',
|
||||
body: 'hola',
|
||||
body: '90',
|
||||
})
|
||||
|
||||
await delay(10)
|
||||
const getHistory = database.listHistory.map((i) => i.answer)
|
||||
assert.is('Como vas?', getHistory[0])
|
||||
assert.is('Todo bien!', getHistory[1])
|
||||
assert.is('y vos?', getHistory[2])
|
||||
assert.is(undefined, getHistory[3])
|
||||
})
|
||||
await delay(20)
|
||||
|
||||
suiteCase(`Responder con un "array"`, async ({ database, provider }) => {
|
||||
const flow = addKeyword(['hola'])
|
||||
.addAnswer('Como vas?', null, async (_, { flowDynamic }) => {
|
||||
return flowDynamic(['Todo bien!', 'trabajando'])
|
||||
})
|
||||
.addAnswer('y vos?')
|
||||
|
||||
createBot({
|
||||
database,
|
||||
provider,
|
||||
flow: createFlow([flow]),
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(0, 'message', {
|
||||
from: '000',
|
||||
body: 'hola',
|
||||
})
|
||||
|
||||
await delay(10)
|
||||
const getHistory = database.listHistory.map((i) => i.answer)
|
||||
assert.is('Como vas?', getHistory[0])
|
||||
assert.is('Todo bien!', getHistory[1])
|
||||
assert.is('trabajando', getHistory[2])
|
||||
assert.is('y vos?', getHistory[3])
|
||||
assert.is(undefined, getHistory[4])
|
||||
})
|
||||
|
||||
suiteCase(`Responder con un "object"`, async ({ database, provider }) => {
|
||||
const flow = addKeyword(['hola'])
|
||||
.addAnswer('Como vas?', null, async (_, { flowDynamic }) => {
|
||||
return flowDynamic([{ body: 'Todo bien!' }])
|
||||
})
|
||||
.addAnswer('y vos?')
|
||||
|
||||
createBot({
|
||||
database,
|
||||
provider,
|
||||
flow: createFlow([flow]),
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(0, 'message', {
|
||||
from: '000',
|
||||
body: 'hola',
|
||||
})
|
||||
|
||||
await delay(10)
|
||||
const getHistory = database.listHistory.map((i) => i.answer)
|
||||
assert.is('Como vas?', getHistory[0])
|
||||
assert.is('Todo bien!', getHistory[1])
|
||||
assert.is('y vos?', getHistory[2])
|
||||
assert.is(undefined, getHistory[3])
|
||||
assert.is(['Hola como estas?', '¿Cual es tu edad?'].join('\n'), database.listHistory[0].answer)
|
||||
assert.is('90', database.listHistory[1].answer)
|
||||
assert.is('Gracias por tu respuesta', database.listHistory[2].answer)
|
||||
assert.is(undefined, database.listHistory[3])
|
||||
})
|
||||
|
||||
suiteCase.run()
|
||||
|
||||
@@ -9,14 +9,14 @@ const fakeHTTP = async (fakeData = []) => {
|
||||
return Promise.resolve(data)
|
||||
}
|
||||
|
||||
const suiteCase = suite('Flujo: endFlow')
|
||||
const suiteCase = suite('Flujo: flowDynamic')
|
||||
|
||||
suiteCase.before.each(setup)
|
||||
suiteCase.after.each(clear)
|
||||
|
||||
suiteCase(`Detener el flujo`, async ({ database, provider }) => {
|
||||
suiteCase(`Responder con mensajes asyncronos`, async ({ database, provider }) => {
|
||||
const MOCK_VALUES = [
|
||||
'Bienvenido te envio muchas marcas',
|
||||
'Bienvenido te envio muchas marcas (5510)',
|
||||
'Seleccione marca del auto a cotizar, con el *número* correspondiente',
|
||||
'Seleccione la sub marca del auto a cotizar, con el *número* correspondiente:',
|
||||
'Los precios rondan:',
|
||||
@@ -26,10 +26,14 @@ suiteCase(`Detener el flujo`, async ({ database, provider }) => {
|
||||
const data = await fakeHTTP(['Ford', 'GM', 'BMW'])
|
||||
return flowDynamic(data)
|
||||
})
|
||||
.addAnswer(MOCK_VALUES[1], null, async (_, { endFlow }) => {
|
||||
return endFlow()
|
||||
.addAnswer(MOCK_VALUES[1], null, async (_, { flowDynamic }) => {
|
||||
const data = await fakeHTTP(['Ranger', 'Explorer'])
|
||||
return flowDynamic(data)
|
||||
})
|
||||
.addAnswer(MOCK_VALUES[2], null, async (_, { flowDynamic }) => {
|
||||
const data = await fakeHTTP(['Usado', 'Nuevos'])
|
||||
return flowDynamic(data)
|
||||
})
|
||||
.addAnswer(MOCK_VALUES[2])
|
||||
.addAnswer(MOCK_VALUES[3], null, async (_, { flowDynamic }) => {
|
||||
const data = await fakeHTTP(['1000', '2000', '3000'])
|
||||
return flowDynamic(data)
|
||||
@@ -46,7 +50,7 @@ suiteCase(`Detener el flujo`, async ({ database, provider }) => {
|
||||
body: 'hola',
|
||||
})
|
||||
|
||||
await delay(500)
|
||||
await delay(1200)
|
||||
const getHistory = database.listHistory.map((i) => i.answer)
|
||||
assert.is(MOCK_VALUES[0], getHistory[0])
|
||||
|
||||
@@ -58,17 +62,30 @@ suiteCase(`Detener el flujo`, async ({ database, provider }) => {
|
||||
assert.is(MOCK_VALUES[1], getHistory[4])
|
||||
|
||||
//FlowDynamic
|
||||
assert.is(undefined, getHistory[5])
|
||||
assert.is(undefined, getHistory[6])
|
||||
assert.is('Ranger', getHistory[5])
|
||||
assert.is('Explorer', getHistory[6])
|
||||
|
||||
assert.is(MOCK_VALUES[2], getHistory[7])
|
||||
|
||||
//FlowDynamic
|
||||
assert.is('Usado', getHistory[8])
|
||||
assert.is('Nuevos', getHistory[9])
|
||||
|
||||
assert.is(MOCK_VALUES[3], getHistory[10])
|
||||
|
||||
//FlowDynamic
|
||||
assert.is('1000', getHistory[11])
|
||||
assert.is('2000', getHistory[12])
|
||||
assert.is('3000', getHistory[13])
|
||||
assert.is(undefined, getHistory[14])
|
||||
})
|
||||
|
||||
suiteCase(`Detener el flujo flowDynamic`, async ({ database, provider }) => {
|
||||
suiteCase(`Responder con un "string"`, async ({ database, provider }) => {
|
||||
const flow = addKeyword(['hola'])
|
||||
.addAnswer('Buenas!', null, async (_, { endFlow, flowDynamic }) => {
|
||||
await flowDynamic('Continuamos...')
|
||||
return endFlow()
|
||||
.addAnswer('Como vas?', null, async (_, { flowDynamic }) => {
|
||||
return flowDynamic('Todo bien!')
|
||||
})
|
||||
.addAnswer('Como estas!')
|
||||
.addAnswer('y vos?')
|
||||
|
||||
createBot({
|
||||
database,
|
||||
@@ -83,39 +100,18 @@ suiteCase(`Detener el flujo flowDynamic`, async ({ database, provider }) => {
|
||||
|
||||
await delay(10)
|
||||
const getHistory = database.listHistory.map((i) => i.answer)
|
||||
assert.is('Buenas!', getHistory[0])
|
||||
assert.is('Continuamos...', getHistory[1])
|
||||
assert.is(undefined, getHistory[2])
|
||||
assert.is('Como vas?', getHistory[0])
|
||||
assert.is('Todo bien!', getHistory[1])
|
||||
assert.is('y vos?', getHistory[2])
|
||||
assert.is(undefined, getHistory[3])
|
||||
})
|
||||
|
||||
suiteCase(`flowDynamic con capture`, async ({ database, provider }) => {
|
||||
const MOCK_VALUES = ['¿CUal es tu email?', 'Continuamos....', '¿Cual es tu edad?']
|
||||
|
||||
suiteCase(`Responder con un "array"`, async ({ database, provider }) => {
|
||||
const flow = addKeyword(['hola'])
|
||||
.addAnswer(
|
||||
MOCK_VALUES[0],
|
||||
{
|
||||
capture: true,
|
||||
},
|
||||
async (ctx, { flowDynamic, fallBack }) => {
|
||||
const validation = ctx.body.includes('@')
|
||||
|
||||
if (validation) {
|
||||
const getDataFromApi = await fakeHTTP(['Gracias por tu email se ha validado de manera correcta'])
|
||||
return flowDynamic(getDataFromApi)
|
||||
}
|
||||
return fallBack()
|
||||
}
|
||||
)
|
||||
.addAnswer(MOCK_VALUES[1])
|
||||
.addAnswer(MOCK_VALUES[2], { capture: true }, async (ctx, { flowDynamic, fallBack }) => {
|
||||
if (ctx.body !== '18') {
|
||||
await delay(20)
|
||||
return fallBack('Ups creo que no eres mayor de edad')
|
||||
}
|
||||
return flowDynamic('Bien tu edad es correcta!')
|
||||
.addAnswer('Como vas?', null, async (_, { flowDynamic }) => {
|
||||
return flowDynamic(['Todo bien!', 'trabajando'])
|
||||
})
|
||||
.addAnswer('Puedes pasar')
|
||||
.addAnswer('y vos?')
|
||||
|
||||
createBot({
|
||||
database,
|
||||
@@ -128,40 +124,39 @@ suiteCase(`flowDynamic con capture`, async ({ database, provider }) => {
|
||||
body: 'hola',
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(10, 'message', {
|
||||
from: '000',
|
||||
body: 'this is not email value',
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(20, 'message', {
|
||||
from: '000',
|
||||
body: 'test@test.com',
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(90, 'message', {
|
||||
from: '000',
|
||||
body: '20',
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(200, 'message', {
|
||||
from: '000',
|
||||
body: '18',
|
||||
})
|
||||
|
||||
await delay(500)
|
||||
await delay(10)
|
||||
const getHistory = database.listHistory.map((i) => i.answer)
|
||||
assert.is(MOCK_VALUES[0], getHistory[0])
|
||||
assert.is('this is not email value', getHistory[1])
|
||||
assert.is(MOCK_VALUES[0], getHistory[2])
|
||||
assert.is('test@test.com', getHistory[3])
|
||||
assert.is('Gracias por tu email se ha validado de manera correcta', getHistory[4])
|
||||
assert.is(MOCK_VALUES[1], getHistory[5])
|
||||
assert.is(MOCK_VALUES[2], getHistory[6])
|
||||
assert.is('20', getHistory[7])
|
||||
assert.is('Ups creo que no eres mayor de edad', getHistory[8])
|
||||
assert.is('18', getHistory[9])
|
||||
assert.is('Bien tu edad es correcta!', getHistory[10])
|
||||
assert.is('Puedes pasar', getHistory[11])
|
||||
assert.is('Como vas?', getHistory[0])
|
||||
assert.is('Todo bien!', getHistory[1])
|
||||
assert.is('trabajando', getHistory[2])
|
||||
assert.is('y vos?', getHistory[3])
|
||||
assert.is(undefined, getHistory[4])
|
||||
})
|
||||
|
||||
suiteCase(`Responder con un "object"`, async ({ database, provider }) => {
|
||||
const flow = addKeyword(['hola'])
|
||||
.addAnswer('Como vas?', null, async (_, { flowDynamic }) => {
|
||||
return flowDynamic([{ body: 'Todo bien!' }])
|
||||
})
|
||||
.addAnswer('y vos?')
|
||||
|
||||
createBot({
|
||||
database,
|
||||
provider,
|
||||
flow: createFlow([flow]),
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(0, 'message', {
|
||||
from: '000',
|
||||
body: 'hola',
|
||||
})
|
||||
|
||||
await delay(10)
|
||||
const getHistory = database.listHistory.map((i) => i.answer)
|
||||
assert.is('Como vas?', getHistory[0])
|
||||
assert.is('Todo bien!', getHistory[1])
|
||||
assert.is('y vos?', getHistory[2])
|
||||
assert.is(undefined, getHistory[3])
|
||||
})
|
||||
|
||||
suiteCase.run()
|
||||
|
||||
@@ -3,95 +3,165 @@ const assert = require('uvu/assert')
|
||||
const { addKeyword, createBot, createFlow } = require('../packages/bot/index')
|
||||
const { setup, clear, delay } = require('../__mocks__/env')
|
||||
|
||||
const suiteCase = suite('Flujo: manejo de estado')
|
||||
const fakeHTTP = async (fakeData = []) => {
|
||||
await delay(50)
|
||||
const data = fakeData.map((u) => ({ body: `${u}` }))
|
||||
return Promise.resolve(data)
|
||||
}
|
||||
|
||||
const suiteCase = suite('Flujo: endFlow')
|
||||
|
||||
suiteCase.before.each(setup)
|
||||
suiteCase.after.each(clear)
|
||||
|
||||
suiteCase(`Debe retornar un mensaje resumen`, async ({ database, provider }) => {
|
||||
let STATE_APP = {}
|
||||
const MOCK_VALUES = ['¿Cual es tu nombre?', '¿Cual es tu edad?', 'Tu datos son:']
|
||||
|
||||
const flujoPrincipal = addKeyword(['hola'])
|
||||
.addAnswer(
|
||||
MOCK_VALUES[0],
|
||||
{
|
||||
capture: true,
|
||||
},
|
||||
async (ctx, { flowDynamic }) => {
|
||||
STATE_APP[ctx.from] = { ...STATE_APP[ctx.from], name: ctx.body }
|
||||
|
||||
flowDynamic('Gracias por tu nombre!')
|
||||
}
|
||||
)
|
||||
.addAnswer(
|
||||
MOCK_VALUES[1],
|
||||
{
|
||||
capture: true,
|
||||
},
|
||||
async (ctx, { flowDynamic }) => {
|
||||
STATE_APP[ctx.from] = { ...STATE_APP[ctx.from], age: ctx.body }
|
||||
|
||||
await flowDynamic(`Gracias por tu edad! ${STATE_APP[ctx.from].name}`)
|
||||
}
|
||||
)
|
||||
.addAnswer(MOCK_VALUES[2], null, async (ctx, { flowDynamic }) => {
|
||||
flowDynamic(`Nombre: ${STATE_APP[ctx.from].name} Edad: ${STATE_APP[ctx.from].age}`)
|
||||
suiteCase(`Detener el flujo`, async ({ database, provider }) => {
|
||||
const MOCK_VALUES = [
|
||||
'Bienvenido te envio muchas marcas',
|
||||
'Seleccione marca del auto a cotizar, con el *número* correspondiente',
|
||||
'Seleccione la sub marca del auto a cotizar, con el *número* correspondiente:',
|
||||
'Los precios rondan:',
|
||||
]
|
||||
const flow = addKeyword(['hola'])
|
||||
.addAnswer(MOCK_VALUES[0], null, async (_, { flowDynamic }) => {
|
||||
const data = await fakeHTTP(['Ford', 'GM', 'BMW'])
|
||||
return flowDynamic(data)
|
||||
})
|
||||
.addAnswer(MOCK_VALUES[1], null, async (_, { endFlow }) => {
|
||||
return endFlow()
|
||||
})
|
||||
.addAnswer(MOCK_VALUES[2])
|
||||
.addAnswer(MOCK_VALUES[3], null, async (_, { flowDynamic }) => {
|
||||
const data = await fakeHTTP(['1000', '2000', '3000'])
|
||||
return flowDynamic(data)
|
||||
})
|
||||
.addAnswer('🤖🤖 Gracias por tu participacion')
|
||||
|
||||
createBot({
|
||||
database,
|
||||
flow: createFlow([flujoPrincipal]),
|
||||
provider,
|
||||
flow: createFlow([flow]),
|
||||
})
|
||||
|
||||
provider.delaySendMessage(0, 'message', {
|
||||
await provider.delaySendMessage(0, 'message', {
|
||||
from: '000',
|
||||
body: 'hola',
|
||||
})
|
||||
|
||||
provider.delaySendMessage(5, 'message', {
|
||||
from: '001',
|
||||
body: 'hola',
|
||||
})
|
||||
|
||||
provider.delaySendMessage(10, 'message', {
|
||||
from: '000',
|
||||
body: 'Leifer',
|
||||
})
|
||||
|
||||
provider.delaySendMessage(15, 'message', {
|
||||
from: '000',
|
||||
body: '90',
|
||||
})
|
||||
|
||||
provider.delaySendMessage(20, 'message', {
|
||||
from: '001',
|
||||
body: 'Maria',
|
||||
})
|
||||
|
||||
provider.delaySendMessage(25, 'message', {
|
||||
from: '001',
|
||||
body: '100',
|
||||
})
|
||||
|
||||
await delay(500)
|
||||
const getHistory = database.listHistory.map((i) => i.answer)
|
||||
assert.is(MOCK_VALUES[0], getHistory[0])
|
||||
assert.is('¿Cual es tu nombre?', getHistory[1])
|
||||
assert.is('Leifer', getHistory[2])
|
||||
assert.is('Gracias por tu nombre!', getHistory[3])
|
||||
assert.is('¿Cual es tu edad?', getHistory[4])
|
||||
assert.is('90', getHistory[5])
|
||||
assert.is('Gracias por tu edad! Leifer', getHistory[6])
|
||||
assert.is('Tu datos son:', getHistory[7])
|
||||
assert.is('Nombre: Leifer Edad: 90', getHistory[8])
|
||||
assert.is('🤖🤖 Gracias por tu participacion', getHistory[9])
|
||||
assert.is('Maria', getHistory[10])
|
||||
assert.is('Gracias por tu nombre!', getHistory[11])
|
||||
assert.is('100', getHistory[12])
|
||||
assert.is(undefined, getHistory[13])
|
||||
|
||||
//FlowDynamic
|
||||
assert.is('Ford', getHistory[1])
|
||||
assert.is('GM', getHistory[2])
|
||||
assert.is('BMW', getHistory[3])
|
||||
|
||||
assert.is(MOCK_VALUES[1], getHistory[4])
|
||||
|
||||
//FlowDynamic
|
||||
assert.is(undefined, getHistory[5])
|
||||
assert.is(undefined, getHistory[6])
|
||||
})
|
||||
|
||||
suiteCase(`Detener el flujo flowDynamic`, async ({ database, provider }) => {
|
||||
const flow = addKeyword(['hola'])
|
||||
.addAnswer('Buenas!', null, async (_, { endFlow, flowDynamic }) => {
|
||||
await flowDynamic('Continuamos...')
|
||||
return endFlow()
|
||||
})
|
||||
.addAnswer('Como estas!')
|
||||
|
||||
createBot({
|
||||
database,
|
||||
provider,
|
||||
flow: createFlow([flow]),
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(0, 'message', {
|
||||
from: '000',
|
||||
body: 'hola',
|
||||
})
|
||||
|
||||
await delay(10)
|
||||
const getHistory = database.listHistory.map((i) => i.answer)
|
||||
assert.is('Buenas!', getHistory[0])
|
||||
assert.is('Continuamos...', getHistory[1])
|
||||
assert.is(undefined, getHistory[2])
|
||||
})
|
||||
|
||||
suiteCase(`flowDynamic con capture`, async ({ database, provider }) => {
|
||||
const MOCK_VALUES = ['¿CUal es tu email?', 'Continuamos....', '¿Cual es tu edad?']
|
||||
|
||||
const flow = addKeyword(['hola'])
|
||||
.addAnswer(
|
||||
MOCK_VALUES[0],
|
||||
{
|
||||
capture: true,
|
||||
},
|
||||
async (ctx, { flowDynamic, fallBack }) => {
|
||||
const validation = ctx.body.includes('@')
|
||||
|
||||
if (validation) {
|
||||
const getDataFromApi = await fakeHTTP(['Gracias por tu email se ha validado de manera correcta'])
|
||||
return flowDynamic(getDataFromApi)
|
||||
}
|
||||
return fallBack()
|
||||
}
|
||||
)
|
||||
.addAnswer(MOCK_VALUES[1])
|
||||
.addAnswer(MOCK_VALUES[2], { capture: true }, async (ctx, { flowDynamic, fallBack }) => {
|
||||
if (ctx.body !== '18') {
|
||||
await delay(20)
|
||||
return fallBack('Ups creo que no eres mayor de edad')
|
||||
}
|
||||
return flowDynamic('Bien tu edad es correcta!')
|
||||
})
|
||||
.addAnswer('Puedes pasar')
|
||||
|
||||
createBot({
|
||||
database,
|
||||
provider,
|
||||
flow: createFlow([flow]),
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(0, 'message', {
|
||||
from: '000',
|
||||
body: 'hola',
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(10, 'message', {
|
||||
from: '000',
|
||||
body: 'this is not email value',
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(20, 'message', {
|
||||
from: '000',
|
||||
body: 'test@test.com',
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(90, 'message', {
|
||||
from: '000',
|
||||
body: '20',
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(200, 'message', {
|
||||
from: '000',
|
||||
body: '18',
|
||||
})
|
||||
|
||||
await delay(500)
|
||||
const getHistory = database.listHistory.map((i) => i.answer)
|
||||
assert.is(MOCK_VALUES[0], getHistory[0])
|
||||
assert.is('this is not email value', getHistory[1])
|
||||
assert.is(MOCK_VALUES[0], getHistory[2])
|
||||
assert.is('test@test.com', getHistory[3])
|
||||
assert.is('Gracias por tu email se ha validado de manera correcta', getHistory[4])
|
||||
assert.is(MOCK_VALUES[1], getHistory[5])
|
||||
assert.is(MOCK_VALUES[2], getHistory[6])
|
||||
assert.is('20', getHistory[7])
|
||||
assert.is('Ups creo que no eres mayor de edad', getHistory[8])
|
||||
assert.is('18', getHistory[9])
|
||||
assert.is('Bien tu edad es correcta!', getHistory[10])
|
||||
assert.is('Puedes pasar', getHistory[11])
|
||||
})
|
||||
|
||||
suiteCase.run()
|
||||
|
||||
97
__test__/06-case.test.js
Normal file
97
__test__/06-case.test.js
Normal file
@@ -0,0 +1,97 @@
|
||||
const { suite } = require('uvu')
|
||||
const assert = require('uvu/assert')
|
||||
const { addKeyword, createBot, createFlow } = require('../packages/bot/index')
|
||||
const { setup, clear, delay } = require('../__mocks__/env')
|
||||
|
||||
const suiteCase = suite('Flujo: manejo de estado')
|
||||
|
||||
suiteCase.before.each(setup)
|
||||
suiteCase.after.each(clear)
|
||||
|
||||
suiteCase(`Debe retornar un mensaje resumen`, async ({ database, provider }) => {
|
||||
let STATE_APP = {}
|
||||
const MOCK_VALUES = ['¿Cual es tu nombre?', '¿Cual es tu edad?', 'Tu datos son:']
|
||||
|
||||
const flujoPrincipal = addKeyword(['hola'])
|
||||
.addAnswer(
|
||||
MOCK_VALUES[0],
|
||||
{
|
||||
capture: true,
|
||||
},
|
||||
async (ctx, { flowDynamic }) => {
|
||||
STATE_APP[ctx.from] = { ...STATE_APP[ctx.from], name: ctx.body }
|
||||
|
||||
flowDynamic('Gracias por tu nombre!')
|
||||
}
|
||||
)
|
||||
.addAnswer(
|
||||
MOCK_VALUES[1],
|
||||
{
|
||||
capture: true,
|
||||
},
|
||||
async (ctx, { flowDynamic }) => {
|
||||
STATE_APP[ctx.from] = { ...STATE_APP[ctx.from], age: ctx.body }
|
||||
|
||||
await flowDynamic(`Gracias por tu edad! ${STATE_APP[ctx.from].name}`)
|
||||
}
|
||||
)
|
||||
.addAnswer(MOCK_VALUES[2], null, async (ctx, { flowDynamic }) => {
|
||||
flowDynamic(`Nombre: ${STATE_APP[ctx.from].name} Edad: ${STATE_APP[ctx.from].age}`)
|
||||
})
|
||||
.addAnswer('🤖🤖 Gracias por tu participacion')
|
||||
|
||||
createBot({
|
||||
database,
|
||||
flow: createFlow([flujoPrincipal]),
|
||||
provider,
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(0, 'message', {
|
||||
from: '000',
|
||||
body: 'hola',
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(5, 'message', {
|
||||
from: '001',
|
||||
body: 'hola',
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(10, 'message', {
|
||||
from: '000',
|
||||
body: 'Leifer',
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(15, 'message', {
|
||||
from: '000',
|
||||
body: '90',
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(20, 'message', {
|
||||
from: '001',
|
||||
body: 'Maria',
|
||||
})
|
||||
|
||||
await provider.delaySendMessage(25, 'message', {
|
||||
from: '001',
|
||||
body: '100',
|
||||
})
|
||||
|
||||
await delay(500)
|
||||
const getHistory = database.listHistory.map((i) => i.answer)
|
||||
assert.is(MOCK_VALUES[0], getHistory[0])
|
||||
assert.is('¿Cual es tu nombre?', getHistory[1])
|
||||
assert.is('Leifer', getHistory[2])
|
||||
assert.is('Gracias por tu nombre!', getHistory[3])
|
||||
assert.is('¿Cual es tu edad?', getHistory[4])
|
||||
assert.is('90', getHistory[5])
|
||||
assert.is('Gracias por tu edad! Leifer', getHistory[6])
|
||||
assert.is('Tu datos son:', getHistory[7])
|
||||
assert.is('Nombre: Leifer Edad: 90', getHistory[8])
|
||||
assert.is('🤖🤖 Gracias por tu participacion', getHistory[9])
|
||||
assert.is('Maria', getHistory[10])
|
||||
assert.is('Gracias por tu nombre!', getHistory[11])
|
||||
assert.is('100', getHistory[12])
|
||||
assert.is(undefined, getHistory[13])
|
||||
})
|
||||
|
||||
suiteCase.run()
|
||||
@@ -1,28 +1,10 @@
|
||||
module.exports = {
|
||||
disableEmoji: false,
|
||||
format: '{type}{scope}: {emoji}{subject}',
|
||||
list: [
|
||||
'test',
|
||||
'feat',
|
||||
'fix',
|
||||
'chore',
|
||||
'docs',
|
||||
'refactor',
|
||||
'style',
|
||||
'ci',
|
||||
'perf',
|
||||
],
|
||||
list: ['test', 'feat', 'fix', 'chore', 'docs', 'refactor', 'style', 'ci', 'perf'],
|
||||
maxMessageLength: 64,
|
||||
minMessageLength: 3,
|
||||
questions: [
|
||||
'type',
|
||||
'scope',
|
||||
'subject',
|
||||
'body',
|
||||
'breaking',
|
||||
'issues',
|
||||
'lerna',
|
||||
],
|
||||
questions: ['type', 'scope', 'subject', 'body', 'breaking', 'issues', 'lerna'],
|
||||
scopes: [],
|
||||
types: {
|
||||
chore: {
|
||||
@@ -56,8 +38,7 @@ module.exports = {
|
||||
value: 'perf',
|
||||
},
|
||||
refactor: {
|
||||
description:
|
||||
'A code change that neither fixes a bug or adds a feature',
|
||||
description: 'A code change that neither fixes a bug or adds a feature',
|
||||
emoji: '(💡)',
|
||||
value: 'refactor',
|
||||
},
|
||||
@@ -67,8 +48,7 @@ module.exports = {
|
||||
value: 'release',
|
||||
},
|
||||
style: {
|
||||
description:
|
||||
'Markup, white-space, formatting, missing semi-colons...',
|
||||
description: 'Markup, white-space, formatting, missing semi-colons...',
|
||||
emoji: '(💄)',
|
||||
value: 'style',
|
||||
},
|
||||
@@ -80,8 +60,7 @@ module.exports = {
|
||||
messages: {
|
||||
type: "Select the type of change that you're committing:",
|
||||
customScope: 'Select the scope this component affects:',
|
||||
subject:
|
||||
'Write a short, imperative mood description of the change:\n',
|
||||
subject: 'Write a short, imperative mood description of the change:\n',
|
||||
body: 'Provide a longer description of the change:\n ',
|
||||
breaking: 'List any breaking changes:\n',
|
||||
footer: 'Issues this commit closes, e.g #123:',
|
||||
|
||||
@@ -142,8 +142,19 @@ class CoreClass {
|
||||
const nextFlow = (await this.flowClass.find(refToContinue?.ref, true)) ?? []
|
||||
const filterNextFlow = nextFlow.filter((msg) => msg.refSerialize !== currentPrev?.refSerialize)
|
||||
const isContinueFlow = filterNextFlow.map((i) => i.keyword).includes(currentPrev?.ref)
|
||||
if (!isContinueFlow) await sendFlow(filterNextFlow, from, { prev: undefined })
|
||||
return
|
||||
|
||||
if (!isContinueFlow) {
|
||||
const refToContinueChild = this.flowClass.getRefToContinueChild(currentPrev?.keyword)
|
||||
const flowStandaloneChild = this.flowClass.getFlowsChild()
|
||||
const nextChildMessages =
|
||||
(await this.flowClass.find(refToContinueChild?.ref, true, flowStandaloneChild)) || []
|
||||
if (nextChildMessages?.length) return await sendFlow(nextChildMessages, from, { prev: undefined })
|
||||
}
|
||||
|
||||
if (!isContinueFlow) {
|
||||
await sendFlow(filterNextFlow, from, { prev: undefined })
|
||||
return
|
||||
}
|
||||
}
|
||||
// 📄 [options: fallBack]: esta funcion se encarga de repetir el ultimo mensaje
|
||||
const fallBack =
|
||||
|
||||
@@ -59,6 +59,37 @@ class FlowClass {
|
||||
findBySerialize = (refSerialize) => this.flowSerialize.find((r) => r.refSerialize === refSerialize)
|
||||
|
||||
findIndexByRef = (ref) => this.flowSerialize.findIndex((r) => r.ref === ref)
|
||||
|
||||
getRefToContinueChild = (keyword) => {
|
||||
try {
|
||||
const flowChilds = this.flowSerialize
|
||||
.reduce((acc, cur) => {
|
||||
const merge = [...acc, cur?.options?.nested].flat(2)
|
||||
return merge
|
||||
}, [])
|
||||
.filter((i) => !!i && i?.refSerialize === keyword)
|
||||
.shift()
|
||||
|
||||
return flowChilds
|
||||
} catch (e) {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
getFlowsChild = () => {
|
||||
try {
|
||||
const flowChilds = this.flowSerialize
|
||||
.reduce((acc, cur) => {
|
||||
const merge = [...acc, cur?.options?.nested].flat(2)
|
||||
return merge
|
||||
}, [])
|
||||
.filter((i) => !!i)
|
||||
|
||||
return flowChilds
|
||||
} catch (e) {
|
||||
return []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = FlowClass
|
||||
|
||||
@@ -23,6 +23,8 @@ class ProviderClass extends EventEmitter {
|
||||
if (NODE_ENV !== 'production') console.log('[sendMessage]', { userId, message })
|
||||
return message
|
||||
}
|
||||
|
||||
getInstance = () => this.vendor
|
||||
}
|
||||
|
||||
module.exports = ProviderClass
|
||||
|
||||
@@ -30,7 +30,6 @@ class MongoAdapter {
|
||||
|
||||
save = async (ctx) => {
|
||||
await this.db.collection('history').insert(ctx)
|
||||
console.log('Guardando DB...', ctx)
|
||||
this.listHistory.push(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,57 +152,65 @@ const flowString = addKeyword('hola')
|
||||
|
||||
## endFlow()
|
||||
|
||||
Esta funcion se utliza para finalizar un flujo con dos o más addAnswer. Un ejemplo de uso sería registrar 3 datos de un usuario en 3 preguntas distinas y
|
||||
que el usuario pueda finalizar por él mismo el flujo.
|
||||
Esta funcion se utliza para **finalizar un flujo con dos** o más addAnswer. Un ejemplo de uso sería registrar 3 datos de un usuario en 3 preguntas distinas y
|
||||
que el usuario **pueda finalizar por él mismo el flujo**.
|
||||
Como podrás comprobar en el ejemplo siguiente, se puede vincular flowDynamic y todas sus funciones; como por ejemplo botones.
|
||||
|
||||
```js
|
||||
const flowFormulario = addKeyword(['Hola'])
|
||||
let nombre;
|
||||
let apellidos;
|
||||
let telefono;
|
||||
|
||||
const flowFormulario = addKeyword(['Hola','⬅️ Volver al Inicio'])
|
||||
.addAnswer(
|
||||
['Hola!', 'Escriba su *Nombre* para generar su solicitud'],
|
||||
['Hola!','Para enviar el formulario necesito unos datos...' ,'Escriba su *Nombre*'],
|
||||
{ capture: true, buttons: [{ body: '❌ Cancelar solicitud' }] },
|
||||
|
||||
async (ctx, { flowDynamic, endFlow }) => {
|
||||
if (ctx.body == '❌ Cancelar solicitud') {
|
||||
await flowDynamic([
|
||||
{
|
||||
body: '❌ *Su solicitud de cita ha sido cancelada* ❌',
|
||||
buttons: [{ body: '⬅️ Volver al Inicio' }],
|
||||
},
|
||||
])
|
||||
return endFlow()
|
||||
}
|
||||
if (ctx.body == '❌ Cancelar solicitud')
|
||||
return endFlow({body: '❌ Su solicitud ha sido cancelada ❌', // Aquí terminamos el flow si la condicion se comple
|
||||
buttons:[{body:'⬅️ Volver al Inicio' }] // Y además, añadimos un botón por si necesitas derivarlo a otro flow
|
||||
|
||||
|
||||
})
|
||||
nombre = ctx.body
|
||||
return flowDynamic(`Encantado *${nombre}*, continuamos...`)
|
||||
}
|
||||
)
|
||||
.addAnswer(
|
||||
['También necesito tus dos apellidos'],
|
||||
{ capture: true, buttons: [{ body: '❌ Cancelar solicitud' }] },
|
||||
|
||||
async (ctx, { flowDynamic, endFlow }) => {
|
||||
if (ctx.body == '❌ Cancelar solicitud') {
|
||||
await flowDynamic([
|
||||
{
|
||||
body: '❌ *Su solicitud de cita ha sido cancelada* ❌',
|
||||
buttons: [{ body: '⬅️ Volver al Inicio' }],
|
||||
},
|
||||
])
|
||||
return endFlow()
|
||||
}
|
||||
if (ctx.body == '❌ Cancelar solicitud')
|
||||
return endFlow({body: '❌ Su solicitud ha sido cancelada ❌',
|
||||
buttons:[{body:'⬅️ Volver al Inicio' }]
|
||||
|
||||
|
||||
})
|
||||
apellidos = ctx.body
|
||||
return flowDynamic(`Perfecto *${nombre}*, por último...`)
|
||||
}
|
||||
)
|
||||
.addAnswer(
|
||||
['Dejeme su número de teléfono y le llamaré lo antes posible.'],
|
||||
{ capture: true, buttons: [{ body: '❌ Cancelar solicitud' }] },
|
||||
|
||||
async (ctx, { flowDynamic, endFlow }) => {
|
||||
if (ctx.body == '❌ Cancelar solicitud') {
|
||||
await flowDynamic([
|
||||
{
|
||||
body: '❌ *Su solicitud de cita ha sido cancelada* ❌',
|
||||
buttons: [{ body: '⬅️ Volver al Inicio' }],
|
||||
},
|
||||
])
|
||||
return endFlow()
|
||||
}
|
||||
if (ctx.body == '❌ Cancelar solicitud')
|
||||
return endFlow({body: '❌ Su solicitud ha sido cancelada ❌',
|
||||
buttons:[{body:'⬅️ Volver al Inicio' }]
|
||||
})
|
||||
|
||||
|
||||
telefono = ctx.body
|
||||
await delay(2000)
|
||||
return flowDynamic(`Estupendo *${nombre}*! te dejo el resumen de tu formulario
|
||||
\n- Nombre y apellidos: *${nombre} ${apellidos}*
|
||||
\n- Telefono: *${telefono}*`)
|
||||
}
|
||||
)
|
||||
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@@ -148,6 +148,11 @@ class BaileysProvider extends ProviderClass {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Funcion SendRaw envia opciones directamente del proveedor
|
||||
* @example await sendMessage('+XXXXXXXXXXX', 'Hello World')
|
||||
*/
|
||||
|
||||
/**
|
||||
* @alpha
|
||||
* @param {string} number
|
||||
@@ -204,10 +209,10 @@ class BaileysProvider extends ProviderClass {
|
||||
* @example await sendMessage('+XXXXXXXXXXX', 'audio.mp3')
|
||||
*/
|
||||
|
||||
sendAudio = async (number, audioUrl, voiceNote = false) => {
|
||||
sendAudio = async (number, audioUrl) => {
|
||||
return this.vendor.sendMessage(number, {
|
||||
audio: { url: audioUrl },
|
||||
ptt: voiceNote,
|
||||
ptt: true,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -273,6 +278,7 @@ class BaileysProvider extends ProviderClass {
|
||||
* @param {string} message
|
||||
* @example await sendMessage('+XXXXXXXXXXX', 'Hello World')
|
||||
*/
|
||||
|
||||
sendMessage = async (numberIn, message, { options }) => {
|
||||
const number = baileyCleanNumber(numberIn)
|
||||
|
||||
|
||||
@@ -225,6 +225,14 @@ class WebWhatsappProvider extends ProviderClass {
|
||||
return this.sendFile(number, fileDownloaded)
|
||||
}
|
||||
|
||||
/**
|
||||
* Funcion SendRaw envia opciones directamente del proveedor
|
||||
* @param {string} number
|
||||
* @param {string} message
|
||||
* @example await sendMessage('+XXXXXXXXXXX', 'Hello World')
|
||||
*/
|
||||
|
||||
sendRaw = () => this.vendor.sendMessage
|
||||
/**
|
||||
*
|
||||
* @param {*} userId
|
||||
|
||||
@@ -18,13 +18,9 @@ const [PKG_NAME, PKG_STABLE] = process.argv.slice(2) || [null, null]
|
||||
* @param {*} pkgName
|
||||
*/
|
||||
const checkPkg = async (pkgName = '') => {
|
||||
const { stdout } = await cmd(
|
||||
NPM_COMMAND,
|
||||
['show', `${pkgName}`, 'version'],
|
||||
{
|
||||
stdio: 'inherit',
|
||||
}
|
||||
)
|
||||
const { stdout } = await cmd(NPM_COMMAND, ['show', `${pkgName}`, 'version'], {
|
||||
stdio: 'inherit',
|
||||
})
|
||||
|
||||
return stdout.trim().replace('\n', '')
|
||||
}
|
||||
@@ -36,12 +32,7 @@ const checkPkg = async (pkgName = '') => {
|
||||
const checkPkgStable = async (pkgName = '', version = '') => {
|
||||
const { stdout } = await cmd(
|
||||
NPM_COMMAND,
|
||||
[
|
||||
'show',
|
||||
`${pkgName}@${version.split('.').shift()}.*`,
|
||||
'version',
|
||||
'--json',
|
||||
],
|
||||
['show', `${pkgName}@${version.split('.').shift()}.*`, 'version', '--json'],
|
||||
{
|
||||
stdio: 'inherit',
|
||||
}
|
||||
@@ -65,17 +56,14 @@ const checkPkgStable = async (pkgName = '', version = '') => {
|
||||
* @returns
|
||||
*/
|
||||
const checkEveryProvider = async (provider = '', stable = true) => {
|
||||
const pkgDependencies = readFileSync(
|
||||
join(PATH_PACKAGES, 'provider', 'src', provider, 'package.json')
|
||||
)
|
||||
const pkgDependencies = readFileSync(join(PATH_PACKAGES, 'provider', 'src', provider, 'package.json'))
|
||||
try {
|
||||
const { dependencies } = JSON.parse(pkgDependencies)
|
||||
const devParse = Object.entries(dependencies)
|
||||
const newDevParse = {}
|
||||
for (const [pkgName, pkgVersion] of devParse) {
|
||||
if (!stable) newDevParse[pkgName] = await checkPkg(pkgName)
|
||||
if (stable)
|
||||
newDevParse[pkgName] = await checkPkgStable(pkgName, pkgVersion)
|
||||
if (stable) newDevParse[pkgName] = await checkPkgStable(pkgName, pkgVersion)
|
||||
|
||||
console.log(newDevParse)
|
||||
}
|
||||
@@ -93,25 +81,12 @@ const checkEveryProvider = async (provider = '', stable = true) => {
|
||||
* @returns
|
||||
*/
|
||||
const updateDependencies = async (provider = '', list = {}) => {
|
||||
const pathProvider = join(
|
||||
PATH_PACKAGES,
|
||||
'provider',
|
||||
'src',
|
||||
provider,
|
||||
'package.json'
|
||||
)
|
||||
const pathProvider = join(PATH_PACKAGES, 'provider', 'src', provider, 'package.json')
|
||||
|
||||
try {
|
||||
const pkgDependencies = readFileSync(pathProvider)
|
||||
const { dependencies } = JSON.parse(pkgDependencies)
|
||||
writeFileSync(
|
||||
pathProvider,
|
||||
JSON.stringify(
|
||||
{ dependencies: { ...dependencies, ...list } },
|
||||
null,
|
||||
2
|
||||
)
|
||||
)
|
||||
writeFileSync(pathProvider, JSON.stringify({ dependencies: { ...dependencies, ...list } }, null, 2))
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
return {}
|
||||
@@ -125,15 +100,11 @@ const updateDependencies = async (provider = '', list = {}) => {
|
||||
*/
|
||||
const updateStarters = async (provider = '', updateDev = {}) => {
|
||||
provider = provider === 'web-whatsapp' ? 'wweb' : provider
|
||||
const allStarters = readdirSync(PATH_STARTERS).filter((n) =>
|
||||
n.includes(provider)
|
||||
)
|
||||
const allStarters = readdirSync(PATH_STARTERS).filter((n) => n.includes(provider))
|
||||
|
||||
try {
|
||||
for (const base of allStarters) {
|
||||
const pkgDependenciesBase = readFileSync(
|
||||
join(PATH_STARTERS, base, 'package.json')
|
||||
)
|
||||
const pkgDependenciesBase = readFileSync(join(PATH_STARTERS, base, 'package.json'))
|
||||
const pkgBase = JSON.parse(pkgDependenciesBase)
|
||||
writeFileSync(
|
||||
join(PATH_STARTERS, base, 'package.json'),
|
||||
@@ -157,10 +128,7 @@ const main = async () => {
|
||||
if (PKG_NAME) {
|
||||
const providerName = PKG_NAME ? PKG_NAME.split('=').at(1) : null
|
||||
const providerStable = PKG_STABLE ? PKG_STABLE.split('=').at(1) : null
|
||||
const list = await checkEveryProvider(
|
||||
providerName,
|
||||
providerStable === 'true'
|
||||
)
|
||||
const list = await checkEveryProvider(providerName, providerStable === 'true')
|
||||
await updateDependencies(providerName, list)
|
||||
await updateStarters(providerName, list)
|
||||
}
|
||||
|
||||
@@ -39,8 +39,7 @@ const main = async () => {
|
||||
const githubToken = GITHUB_TOKEN ? GITHUB_TOKEN.split('=').at(1) : null
|
||||
const pkgNumber = PKG_ARG ? PKG_ARG.split('=').at(1) : null
|
||||
|
||||
if (pkgNumber)
|
||||
await githubGithubRelease(`v${pkgNumber}`, pkgNumber, githubToken)
|
||||
if (pkgNumber) await githubGithubRelease(`v${pkgNumber}`, pkgNumber, githubToken)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,14 +10,7 @@ const copyLibPkg = async (pkgName, to) => {
|
||||
await fs.copy(FROM, TO)
|
||||
}
|
||||
|
||||
const listLib = [
|
||||
'create-bot-whatsapp',
|
||||
'bot',
|
||||
'database',
|
||||
'provider',
|
||||
'contexts',
|
||||
'portal',
|
||||
]
|
||||
const listLib = ['create-bot-whatsapp', 'bot', 'database', 'provider', 'contexts', 'portal']
|
||||
|
||||
const main = async () => {
|
||||
for (const iterator of listLib) {
|
||||
|
||||
@@ -18,14 +18,10 @@ const cmd = util.promisify(execFile)
|
||||
*/
|
||||
const npmToken = (token = null) =>
|
||||
new Promise((resolve, reject) => {
|
||||
writeFile(
|
||||
`${process.cwd()}/.npmrc`,
|
||||
`//registry.npmjs.org/:_authToken=${token}`,
|
||||
(error) => {
|
||||
if (error) reject(error)
|
||||
resolve()
|
||||
}
|
||||
)
|
||||
writeFile(`${process.cwd()}/.npmrc`, `//registry.npmjs.org/:_authToken=${token}`, (error) => {
|
||||
if (error) reject(error)
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
@@ -66,18 +62,11 @@ const updateVersion = async (packageName = null, number = null) => {
|
||||
|
||||
const pkgJsonObject = readPackage(packageName)
|
||||
const { version } = pkgJsonObject
|
||||
const newVersion = !number
|
||||
? semver.inc(version, 'prepatch', 'alpha')
|
||||
: `${number}`
|
||||
const newVersion = !number ? semver.inc(version, 'prepatch', 'alpha') : `${number}`
|
||||
|
||||
if (!semver.valid(newVersion))
|
||||
throw new Error(`VERSION_ERROR: ${newVersion}`)
|
||||
if (!semver.valid(newVersion)) throw new Error(`VERSION_ERROR: ${newVersion}`)
|
||||
|
||||
const newPkgJson = JSON.stringify(
|
||||
{ ...pkgJsonObject, version: newVersion },
|
||||
null,
|
||||
2
|
||||
)
|
||||
const newPkgJson = JSON.stringify({ ...pkgJsonObject, version: newVersion }, null, 2)
|
||||
await updatePackage(packageName, newPkgJson)
|
||||
return { version: newVersion }
|
||||
}
|
||||
@@ -92,14 +81,10 @@ const checkExistVersion = async (packageName = null, version = null) => {
|
||||
try {
|
||||
const pkgJson = join(PATH_PACKAGES, packageName)
|
||||
const pkgJsonObject = readPackage(packageName)
|
||||
const { stdout } = await cmd(
|
||||
NPM_COMMAND,
|
||||
['view', `${pkgJsonObject.name}@${version}`],
|
||||
{
|
||||
stdio: 'inherit',
|
||||
cwd: pkgJson,
|
||||
}
|
||||
)
|
||||
const { stdout } = await cmd(NPM_COMMAND, ['view', `${pkgJsonObject.name}@${version}`], {
|
||||
stdio: 'inherit',
|
||||
cwd: pkgJson,
|
||||
})
|
||||
return true
|
||||
} catch (e) {
|
||||
return false
|
||||
@@ -149,9 +134,7 @@ const main = async () => {
|
||||
let EXIST_VERSION = true
|
||||
const tokenNpm = NPM_TOKEN ? NPM_TOKEN.split('=').at(1) : null
|
||||
const pkgName = PKG_ARG ? PKG_ARG.split('=').at(1) : null
|
||||
const pkgNumber = PKG_ARG_VERSION
|
||||
? PKG_ARG_VERSION.split('=').at(1)
|
||||
: null
|
||||
const pkgNumber = PKG_ARG_VERSION ? PKG_ARG_VERSION.split('=').at(1) : null
|
||||
if (tokenNpm) await npmToken(tokenNpm)
|
||||
|
||||
while (EXIST_VERSION) {
|
||||
|
||||
@@ -1,23 +1,12 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
const { createBot, createProvider, createFlow, addKeyword } = require('@bot-whatsapp/bot')
|
||||
|
||||
const QRPortalWeb = require('@bot-whatsapp/portal')
|
||||
const BaileysProvider = require('@bot-whatsapp/provider/baileys')
|
||||
const JsonFileAdapter = require('@bot-whatsapp/database/json')
|
||||
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer([
|
||||
'📄 Aquí tenemos el flujo secundario',
|
||||
])
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer(['📄 Aquí tenemos el flujo secundario'])
|
||||
|
||||
const flowDocs = addKeyword([
|
||||
'doc',
|
||||
'documentacion',
|
||||
'documentación',
|
||||
]).addAnswer(
|
||||
const flowDocs = addKeyword(['doc', 'documentacion', 'documentación']).addAnswer(
|
||||
[
|
||||
'📄 Aquí encontras las documentación recuerda que puedes mejorarla',
|
||||
'https://bot-whatsapp.netlify.app/',
|
||||
@@ -53,11 +42,7 @@ const flowGracias = addKeyword(['gracias', 'grac']).addAnswer(
|
||||
)
|
||||
|
||||
const flowDiscord = addKeyword(['discord']).addAnswer(
|
||||
[
|
||||
'🤪 Únete al discord',
|
||||
'https://link.codigoencasa.com/DISCORD',
|
||||
'\n*2* Para siguiente paso.',
|
||||
],
|
||||
['🤪 Únete al discord', 'https://link.codigoencasa.com/DISCORD', '\n*2* Para siguiente paso.'],
|
||||
null,
|
||||
null,
|
||||
[flowSecundario]
|
||||
|
||||
@@ -1,23 +1,12 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
const { createBot, createProvider, createFlow, addKeyword } = require('@bot-whatsapp/bot')
|
||||
|
||||
const QRPortalWeb = require('@bot-whatsapp/portal')
|
||||
const BaileysProvider = require('@bot-whatsapp/provider/baileys')
|
||||
const MockAdapter = require('@bot-whatsapp/database/mock')
|
||||
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer([
|
||||
'📄 Aquí tenemos el flujo secundario',
|
||||
])
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer(['📄 Aquí tenemos el flujo secundario'])
|
||||
|
||||
const flowDocs = addKeyword([
|
||||
'doc',
|
||||
'documentacion',
|
||||
'documentación',
|
||||
]).addAnswer(
|
||||
const flowDocs = addKeyword(['doc', 'documentacion', 'documentación']).addAnswer(
|
||||
[
|
||||
'📄 Aquí encontras las documentación recuerda que puedes mejorarla',
|
||||
'https://bot-whatsapp.netlify.app/',
|
||||
@@ -53,11 +42,7 @@ const flowGracias = addKeyword(['gracias', 'grac']).addAnswer(
|
||||
)
|
||||
|
||||
const flowDiscord = addKeyword(['discord']).addAnswer(
|
||||
[
|
||||
'🤪 Únete al discord',
|
||||
'https://link.codigoencasa.com/DISCORD',
|
||||
'\n*2* Para siguiente paso.',
|
||||
],
|
||||
['🤪 Únete al discord', 'https://link.codigoencasa.com/DISCORD', '\n*2* Para siguiente paso.'],
|
||||
null,
|
||||
null,
|
||||
[flowSecundario]
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
const { createBot, createProvider, createFlow, addKeyword } = require('@bot-whatsapp/bot')
|
||||
|
||||
const QRPortalWeb = require('@bot-whatsapp/portal')
|
||||
const BaileysProvider = require('@bot-whatsapp/provider/baileys')
|
||||
@@ -28,15 +23,9 @@ const MONGO_DB_NAME = 'db_bot'
|
||||
* Primero declaras los submenus 1.1 y 2.1, luego el 1 y 2 y al final el principal.
|
||||
*/
|
||||
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer([
|
||||
'📄 Aquí tenemos el flujo secundario',
|
||||
])
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer(['📄 Aquí tenemos el flujo secundario'])
|
||||
|
||||
const flowDocs = addKeyword([
|
||||
'doc',
|
||||
'documentacion',
|
||||
'documentación',
|
||||
]).addAnswer(
|
||||
const flowDocs = addKeyword(['doc', 'documentacion', 'documentación']).addAnswer(
|
||||
[
|
||||
'📄 Aquí encontras las documentación recuerda que puedes mejorarla',
|
||||
'https://bot-whatsapp.netlify.app/',
|
||||
@@ -72,11 +61,7 @@ const flowGracias = addKeyword(['gracias', 'grac']).addAnswer(
|
||||
)
|
||||
|
||||
const flowDiscord = addKeyword(['discord']).addAnswer(
|
||||
[
|
||||
'🤪 Únete al discord',
|
||||
'https://link.codigoencasa.com/DISCORD',
|
||||
'\n*2* Para siguiente paso.',
|
||||
],
|
||||
['🤪 Únete al discord', 'https://link.codigoencasa.com/DISCORD', '\n*2* Para siguiente paso.'],
|
||||
null,
|
||||
null,
|
||||
[flowSecundario]
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
const { createBot, createProvider, createFlow, addKeyword } = require('@bot-whatsapp/bot')
|
||||
|
||||
const QRPortalWeb = require('@bot-whatsapp/portal')
|
||||
const BaileysProvider = require('@bot-whatsapp/provider/baileys')
|
||||
@@ -29,15 +24,9 @@ const MYSQL_DB_NAME = 'bot'
|
||||
* Primero declaras los submenus 1.1 y 2.1, luego el 1 y 2 y al final el principal.
|
||||
*/
|
||||
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer([
|
||||
'📄 Aquí tenemos el flujo secundario',
|
||||
])
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer(['📄 Aquí tenemos el flujo secundario'])
|
||||
|
||||
const flowDocs = addKeyword([
|
||||
'doc',
|
||||
'documentacion',
|
||||
'documentación',
|
||||
]).addAnswer(
|
||||
const flowDocs = addKeyword(['doc', 'documentacion', 'documentación']).addAnswer(
|
||||
[
|
||||
'📄 Aquí encontras las documentación recuerda que puedes mejorarla',
|
||||
'https://bot-whatsapp.netlify.app/',
|
||||
@@ -73,11 +62,7 @@ const flowGracias = addKeyword(['gracias', 'grac']).addAnswer(
|
||||
)
|
||||
|
||||
const flowDiscord = addKeyword(['discord']).addAnswer(
|
||||
[
|
||||
'🤪 Únete al discord',
|
||||
'https://link.codigoencasa.com/DISCORD',
|
||||
'\n*2* Para siguiente paso.',
|
||||
],
|
||||
['🤪 Únete al discord', 'https://link.codigoencasa.com/DISCORD', '\n*2* Para siguiente paso.'],
|
||||
null,
|
||||
null,
|
||||
[flowSecundario]
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
const { createBot, createProvider, createFlow, addKeyword } = require('@bot-whatsapp/bot')
|
||||
|
||||
const MetaProvider = require('@bot-whatsapp/provider/meta')
|
||||
const JsonFileAdapter = require('@bot-whatsapp/database/json')
|
||||
@@ -20,15 +15,9 @@ const JsonFileAdapter = require('@bot-whatsapp/database/json')
|
||||
* Primero declaras los submenus 1.1 y 2.1, luego el 1 y 2 y al final el principal.
|
||||
*/
|
||||
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer([
|
||||
'📄 Aquí tenemos el flujo secundario',
|
||||
])
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer(['📄 Aquí tenemos el flujo secundario'])
|
||||
|
||||
const flowDocs = addKeyword([
|
||||
'doc',
|
||||
'documentacion',
|
||||
'documentación',
|
||||
]).addAnswer(
|
||||
const flowDocs = addKeyword(['doc', 'documentacion', 'documentación']).addAnswer(
|
||||
[
|
||||
'📄 Aquí encontras las documentación recuerda que puedes mejorarla',
|
||||
'https://bot-whatsapp.netlify.app/',
|
||||
@@ -64,11 +53,7 @@ const flowGracias = addKeyword(['gracias', 'grac']).addAnswer(
|
||||
)
|
||||
|
||||
const flowDiscord = addKeyword(['discord']).addAnswer(
|
||||
[
|
||||
'🤪 Únete al discord',
|
||||
'https://link.codigoencasa.com/DISCORD',
|
||||
'\n*2* Para siguiente paso.',
|
||||
],
|
||||
['🤪 Únete al discord', 'https://link.codigoencasa.com/DISCORD', '\n*2* Para siguiente paso.'],
|
||||
null,
|
||||
null,
|
||||
[flowSecundario]
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
const { createBot, createProvider, createFlow, addKeyword } = require('@bot-whatsapp/bot')
|
||||
|
||||
const MetaProvider = require('@bot-whatsapp/provider/meta')
|
||||
const MockAdapter = require('@bot-whatsapp/database/mock')
|
||||
@@ -20,15 +15,9 @@ const MockAdapter = require('@bot-whatsapp/database/mock')
|
||||
* Primero declaras los submenus 1.1 y 2.1, luego el 1 y 2 y al final el principal.
|
||||
*/
|
||||
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer([
|
||||
'📄 Aquí tenemos el flujo secundario',
|
||||
])
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer(['📄 Aquí tenemos el flujo secundario'])
|
||||
|
||||
const flowDocs = addKeyword([
|
||||
'doc',
|
||||
'documentacion',
|
||||
'documentación',
|
||||
]).addAnswer(
|
||||
const flowDocs = addKeyword(['doc', 'documentacion', 'documentación']).addAnswer(
|
||||
[
|
||||
'📄 Aquí encontras las documentación recuerda que puedes mejorarla',
|
||||
'https://bot-whatsapp.netlify.app/',
|
||||
@@ -64,11 +53,7 @@ const flowGracias = addKeyword(['gracias', 'grac']).addAnswer(
|
||||
)
|
||||
|
||||
const flowDiscord = addKeyword(['discord']).addAnswer(
|
||||
[
|
||||
'🤪 Únete al discord',
|
||||
'https://link.codigoencasa.com/DISCORD',
|
||||
'\n*2* Para siguiente paso.',
|
||||
],
|
||||
['🤪 Únete al discord', 'https://link.codigoencasa.com/DISCORD', '\n*2* Para siguiente paso.'],
|
||||
null,
|
||||
null,
|
||||
[flowSecundario]
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
const { createBot, createProvider, createFlow, addKeyword } = require('@bot-whatsapp/bot')
|
||||
|
||||
const MetaProvider = require('@bot-whatsapp/provider/meta')
|
||||
const MongoAdapter = require('@bot-whatsapp/database/mongo')
|
||||
@@ -27,15 +22,9 @@ const MONGO_DB_NAME = 'db_bot'
|
||||
* Primero declaras los submenus 1.1 y 2.1, luego el 1 y 2 y al final el principal.
|
||||
*/
|
||||
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer([
|
||||
'📄 Aquí tenemos el flujo secundario',
|
||||
])
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer(['📄 Aquí tenemos el flujo secundario'])
|
||||
|
||||
const flowDocs = addKeyword([
|
||||
'doc',
|
||||
'documentacion',
|
||||
'documentación',
|
||||
]).addAnswer(
|
||||
const flowDocs = addKeyword(['doc', 'documentacion', 'documentación']).addAnswer(
|
||||
[
|
||||
'📄 Aquí encontras las documentación recuerda que puedes mejorarla',
|
||||
'https://bot-whatsapp.netlify.app/',
|
||||
@@ -71,11 +60,7 @@ const flowGracias = addKeyword(['gracias', 'grac']).addAnswer(
|
||||
)
|
||||
|
||||
const flowDiscord = addKeyword(['discord']).addAnswer(
|
||||
[
|
||||
'🤪 Únete al discord',
|
||||
'https://link.codigoencasa.com/DISCORD',
|
||||
'\n*2* Para siguiente paso.',
|
||||
],
|
||||
['🤪 Únete al discord', 'https://link.codigoencasa.com/DISCORD', '\n*2* Para siguiente paso.'],
|
||||
null,
|
||||
null,
|
||||
[flowSecundario]
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
const { createBot, createProvider, createFlow, addKeyword } = require('@bot-whatsapp/bot')
|
||||
|
||||
const MetaProvider = require('@bot-whatsapp/provider/meta')
|
||||
const MySQLAdapter = require('@bot-whatsapp/database/mysql')
|
||||
@@ -28,15 +23,9 @@ const MYSQL_DB_NAME = 'bot'
|
||||
* Primero declaras los submenus 1.1 y 2.1, luego el 1 y 2 y al final el principal.
|
||||
*/
|
||||
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer([
|
||||
'📄 Aquí tenemos el flujo secundario',
|
||||
])
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer(['📄 Aquí tenemos el flujo secundario'])
|
||||
|
||||
const flowDocs = addKeyword([
|
||||
'doc',
|
||||
'documentacion',
|
||||
'documentación',
|
||||
]).addAnswer(
|
||||
const flowDocs = addKeyword(['doc', 'documentacion', 'documentación']).addAnswer(
|
||||
[
|
||||
'📄 Aquí encontras las documentación recuerda que puedes mejorarla',
|
||||
'https://bot-whatsapp.netlify.app/',
|
||||
@@ -72,11 +61,7 @@ const flowGracias = addKeyword(['gracias', 'grac']).addAnswer(
|
||||
)
|
||||
|
||||
const flowDiscord = addKeyword(['discord']).addAnswer(
|
||||
[
|
||||
'🤪 Únete al discord',
|
||||
'https://link.codigoencasa.com/DISCORD',
|
||||
'\n*2* Para siguiente paso.',
|
||||
],
|
||||
['🤪 Únete al discord', 'https://link.codigoencasa.com/DISCORD', '\n*2* Para siguiente paso.'],
|
||||
null,
|
||||
null,
|
||||
[flowSecundario]
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
const { createBot, createProvider, createFlow, addKeyword } = require('@bot-whatsapp/bot')
|
||||
|
||||
const TwilioProvider = require('@bot-whatsapp/provider/twilio')
|
||||
const JsonFileAdapter = require('@bot-whatsapp/database/json')
|
||||
@@ -20,15 +15,9 @@ const JsonFileAdapter = require('@bot-whatsapp/database/json')
|
||||
* Primero declaras los submenus 1.1 y 2.1, luego el 1 y 2 y al final el principal.
|
||||
*/
|
||||
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer([
|
||||
'📄 Aquí tenemos el flujo secundario',
|
||||
])
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer(['📄 Aquí tenemos el flujo secundario'])
|
||||
|
||||
const flowDocs = addKeyword([
|
||||
'doc',
|
||||
'documentacion',
|
||||
'documentación',
|
||||
]).addAnswer(
|
||||
const flowDocs = addKeyword(['doc', 'documentacion', 'documentación']).addAnswer(
|
||||
[
|
||||
'📄 Aquí encontras las documentación recuerda que puedes mejorarla',
|
||||
'https://bot-whatsapp.netlify.app/',
|
||||
@@ -64,11 +53,7 @@ const flowGracias = addKeyword(['gracias', 'grac']).addAnswer(
|
||||
)
|
||||
|
||||
const flowDiscord = addKeyword(['discord']).addAnswer(
|
||||
[
|
||||
'🤪 Únete al discord',
|
||||
'https://link.codigoencasa.com/DISCORD',
|
||||
'\n*2* Para siguiente paso.',
|
||||
],
|
||||
['🤪 Únete al discord', 'https://link.codigoencasa.com/DISCORD', '\n*2* Para siguiente paso.'],
|
||||
null,
|
||||
null,
|
||||
[flowSecundario]
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
const { createBot, createProvider, createFlow, addKeyword } = require('@bot-whatsapp/bot')
|
||||
|
||||
const TwilioProvider = require('@bot-whatsapp/provider/twilio')
|
||||
const MockAdapter = require('@bot-whatsapp/database/mock')
|
||||
@@ -20,15 +15,9 @@ const MockAdapter = require('@bot-whatsapp/database/mock')
|
||||
* Primero declaras los submenus 1.1 y 2.1, luego el 1 y 2 y al final el principal.
|
||||
*/
|
||||
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer([
|
||||
'📄 Aquí tenemos el flujo secundario',
|
||||
])
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer(['📄 Aquí tenemos el flujo secundario'])
|
||||
|
||||
const flowDocs = addKeyword([
|
||||
'doc',
|
||||
'documentacion',
|
||||
'documentación',
|
||||
]).addAnswer(
|
||||
const flowDocs = addKeyword(['doc', 'documentacion', 'documentación']).addAnswer(
|
||||
[
|
||||
'📄 Aquí encontras las documentación recuerda que puedes mejorarla',
|
||||
'https://bot-whatsapp.netlify.app/',
|
||||
@@ -64,11 +53,7 @@ const flowGracias = addKeyword(['gracias', 'grac']).addAnswer(
|
||||
)
|
||||
|
||||
const flowDiscord = addKeyword(['discord']).addAnswer(
|
||||
[
|
||||
'🤪 Únete al discord',
|
||||
'https://link.codigoencasa.com/DISCORD',
|
||||
'\n*2* Para siguiente paso.',
|
||||
],
|
||||
['🤪 Únete al discord', 'https://link.codigoencasa.com/DISCORD', '\n*2* Para siguiente paso.'],
|
||||
null,
|
||||
null,
|
||||
[flowSecundario]
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
const { createBot, createProvider, createFlow, addKeyword } = require('@bot-whatsapp/bot')
|
||||
|
||||
const TwilioProvider = require('@bot-whatsapp/provider/twilio')
|
||||
const MongoAdapter = require('@bot-whatsapp/database/mongo')
|
||||
@@ -27,15 +22,9 @@ const MONGO_DB_NAME = 'db_bot'
|
||||
* Primero declaras los submenus 1.1 y 2.1, luego el 1 y 2 y al final el principal.
|
||||
*/
|
||||
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer([
|
||||
'📄 Aquí tenemos el flujo secundario',
|
||||
])
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer(['📄 Aquí tenemos el flujo secundario'])
|
||||
|
||||
const flowDocs = addKeyword([
|
||||
'doc',
|
||||
'documentacion',
|
||||
'documentación',
|
||||
]).addAnswer(
|
||||
const flowDocs = addKeyword(['doc', 'documentacion', 'documentación']).addAnswer(
|
||||
[
|
||||
'📄 Aquí encontras las documentación recuerda que puedes mejorarla',
|
||||
'https://bot-whatsapp.netlify.app/',
|
||||
@@ -71,11 +60,7 @@ const flowGracias = addKeyword(['gracias', 'grac']).addAnswer(
|
||||
)
|
||||
|
||||
const flowDiscord = addKeyword(['discord']).addAnswer(
|
||||
[
|
||||
'🤪 Únete al discord',
|
||||
'https://link.codigoencasa.com/DISCORD',
|
||||
'\n*2* Para siguiente paso.',
|
||||
],
|
||||
['🤪 Únete al discord', 'https://link.codigoencasa.com/DISCORD', '\n*2* Para siguiente paso.'],
|
||||
null,
|
||||
null,
|
||||
[flowSecundario]
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
const { createBot, createProvider, createFlow, addKeyword } = require('@bot-whatsapp/bot')
|
||||
|
||||
const TwilioProvider = require('@bot-whatsapp/provider/twilio')
|
||||
const MySQLAdapter = require('@bot-whatsapp/database/mysql')
|
||||
@@ -29,15 +24,9 @@ const MYSQL_DB_NAME = 'bot'
|
||||
* Primero declaras los submenus 1.1 y 2.1, luego el 1 y 2 y al final el principal.
|
||||
*/
|
||||
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer([
|
||||
'📄 Aquí tenemos el flujo secundario',
|
||||
])
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer(['📄 Aquí tenemos el flujo secundario'])
|
||||
|
||||
const flowDocs = addKeyword([
|
||||
'doc',
|
||||
'documentacion',
|
||||
'documentación',
|
||||
]).addAnswer(
|
||||
const flowDocs = addKeyword(['doc', 'documentacion', 'documentación']).addAnswer(
|
||||
[
|
||||
'📄 Aquí encontras las documentación recuerda que puedes mejorarla',
|
||||
'https://bot-whatsapp.netlify.app/',
|
||||
@@ -73,11 +62,7 @@ const flowGracias = addKeyword(['gracias', 'grac']).addAnswer(
|
||||
)
|
||||
|
||||
const flowDiscord = addKeyword(['discord']).addAnswer(
|
||||
[
|
||||
'🤪 Únete al discord',
|
||||
'https://link.codigoencasa.com/DISCORD',
|
||||
'\n*2* Para siguiente paso.',
|
||||
],
|
||||
['🤪 Únete al discord', 'https://link.codigoencasa.com/DISCORD', '\n*2* Para siguiente paso.'],
|
||||
null,
|
||||
null,
|
||||
[flowSecundario]
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
const { createBot, createProvider, createFlow, addKeyword } = require('@bot-whatsapp/bot')
|
||||
|
||||
const QRPortalWeb = require('@bot-whatsapp/portal')
|
||||
const VenomProvider = require('@bot-whatsapp/provider/venom')
|
||||
@@ -21,15 +16,9 @@ const JsonFileAdapter = require('@bot-whatsapp/database/json')
|
||||
* Primero declaras los submenus 1.1 y 2.1, luego el 1 y 2 y al final el principal.
|
||||
*/
|
||||
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer([
|
||||
'📄 Aquí tenemos el flujo secundario',
|
||||
])
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer(['📄 Aquí tenemos el flujo secundario'])
|
||||
|
||||
const flowDocs = addKeyword([
|
||||
'doc',
|
||||
'documentacion',
|
||||
'documentación',
|
||||
]).addAnswer(
|
||||
const flowDocs = addKeyword(['doc', 'documentacion', 'documentación']).addAnswer(
|
||||
[
|
||||
'📄 Aquí encontras las documentación recuerda que puedes mejorarla',
|
||||
'https://bot-whatsapp.netlify.app/',
|
||||
@@ -65,11 +54,7 @@ const flowGracias = addKeyword(['gracias', 'grac']).addAnswer(
|
||||
)
|
||||
|
||||
const flowDiscord = addKeyword(['discord']).addAnswer(
|
||||
[
|
||||
'🤪 Únete al discord',
|
||||
'https://link.codigoencasa.com/DISCORD',
|
||||
'\n*2* Para siguiente paso.',
|
||||
],
|
||||
['🤪 Únete al discord', 'https://link.codigoencasa.com/DISCORD', '\n*2* Para siguiente paso.'],
|
||||
null,
|
||||
null,
|
||||
[flowSecundario]
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
const { createBot, createProvider, createFlow, addKeyword } = require('@bot-whatsapp/bot')
|
||||
|
||||
const QRPortalWeb = require('@bot-whatsapp/portal')
|
||||
const VenomProvider = require('@bot-whatsapp/provider/venom')
|
||||
@@ -21,15 +16,9 @@ const MockAdapter = require('@bot-whatsapp/database/mock')
|
||||
* Primero declaras los submenus 1.1 y 2.1, luego el 1 y 2 y al final el principal.
|
||||
*/
|
||||
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer([
|
||||
'📄 Aquí tenemos el flujo secundario',
|
||||
])
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer(['📄 Aquí tenemos el flujo secundario'])
|
||||
|
||||
const flowDocs = addKeyword([
|
||||
'doc',
|
||||
'documentacion',
|
||||
'documentación',
|
||||
]).addAnswer(
|
||||
const flowDocs = addKeyword(['doc', 'documentacion', 'documentación']).addAnswer(
|
||||
[
|
||||
'📄 Aquí encontras las documentación recuerda que puedes mejorarla',
|
||||
'https://bot-whatsapp.netlify.app/',
|
||||
@@ -65,11 +54,7 @@ const flowGracias = addKeyword(['gracias', 'grac']).addAnswer(
|
||||
)
|
||||
|
||||
const flowDiscord = addKeyword(['discord']).addAnswer(
|
||||
[
|
||||
'🤪 Únete al discord',
|
||||
'https://link.codigoencasa.com/DISCORD',
|
||||
'\n*2* Para siguiente paso.',
|
||||
],
|
||||
['🤪 Únete al discord', 'https://link.codigoencasa.com/DISCORD', '\n*2* Para siguiente paso.'],
|
||||
null,
|
||||
null,
|
||||
[flowSecundario]
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
const { createBot, createProvider, createFlow, addKeyword } = require('@bot-whatsapp/bot')
|
||||
|
||||
const QRPortalWeb = require('@bot-whatsapp/portal')
|
||||
const VenomProvider = require('@bot-whatsapp/provider/venom')
|
||||
@@ -28,15 +23,9 @@ const MONGO_DB_NAME = 'db_bot'
|
||||
* Primero declaras los submenus 1.1 y 2.1, luego el 1 y 2 y al final el principal.
|
||||
*/
|
||||
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer([
|
||||
'📄 Aquí tenemos el flujo secundario',
|
||||
])
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer(['📄 Aquí tenemos el flujo secundario'])
|
||||
|
||||
const flowDocs = addKeyword([
|
||||
'doc',
|
||||
'documentacion',
|
||||
'documentación',
|
||||
]).addAnswer(
|
||||
const flowDocs = addKeyword(['doc', 'documentacion', 'documentación']).addAnswer(
|
||||
[
|
||||
'📄 Aquí encontras las documentación recuerda que puedes mejorarla',
|
||||
'https://bot-whatsapp.netlify.app/',
|
||||
@@ -72,11 +61,7 @@ const flowGracias = addKeyword(['gracias', 'grac']).addAnswer(
|
||||
)
|
||||
|
||||
const flowDiscord = addKeyword(['discord']).addAnswer(
|
||||
[
|
||||
'🤪 Únete al discord',
|
||||
'https://link.codigoencasa.com/DISCORD',
|
||||
'\n*2* Para siguiente paso.',
|
||||
],
|
||||
['🤪 Únete al discord', 'https://link.codigoencasa.com/DISCORD', '\n*2* Para siguiente paso.'],
|
||||
null,
|
||||
null,
|
||||
[flowSecundario]
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
const { createBot, createProvider, createFlow, addKeyword } = require('@bot-whatsapp/bot')
|
||||
|
||||
const QRPortalWeb = require('@bot-whatsapp/portal')
|
||||
const VenomProvider = require('@bot-whatsapp/provider/venom')
|
||||
@@ -30,15 +25,9 @@ const MYSQL_DB_NAME = 'bot'
|
||||
* Primero declaras los submenus 1.1 y 2.1, luego el 1 y 2 y al final el principal.
|
||||
*/
|
||||
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer([
|
||||
'📄 Aquí tenemos el flujo secundario',
|
||||
])
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer(['📄 Aquí tenemos el flujo secundario'])
|
||||
|
||||
const flowDocs = addKeyword([
|
||||
'doc',
|
||||
'documentacion',
|
||||
'documentación',
|
||||
]).addAnswer(
|
||||
const flowDocs = addKeyword(['doc', 'documentacion', 'documentación']).addAnswer(
|
||||
[
|
||||
'📄 Aquí encontras las documentación recuerda que puedes mejorarla',
|
||||
'https://bot-whatsapp.netlify.app/',
|
||||
@@ -74,11 +63,7 @@ const flowGracias = addKeyword(['gracias', 'grac']).addAnswer(
|
||||
)
|
||||
|
||||
const flowDiscord = addKeyword(['discord']).addAnswer(
|
||||
[
|
||||
'🤪 Únete al discord',
|
||||
'https://link.codigoencasa.com/DISCORD',
|
||||
'\n*2* Para siguiente paso.',
|
||||
],
|
||||
['🤪 Únete al discord', 'https://link.codigoencasa.com/DISCORD', '\n*2* Para siguiente paso.'],
|
||||
null,
|
||||
null,
|
||||
[flowSecundario]
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
const { createBot, createProvider, createFlow, addKeyword } = require('@bot-whatsapp/bot')
|
||||
|
||||
const QRPortalWeb = require('@bot-whatsapp/portal')
|
||||
const WebWhatsappProvider = require('@bot-whatsapp/provider/web-whatsapp')
|
||||
@@ -21,15 +16,9 @@ const JsonFileAdapter = require('@bot-whatsapp/database/json')
|
||||
* Primero declaras los submenus 1.1 y 2.1, luego el 1 y 2 y al final el principal.
|
||||
*/
|
||||
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer([
|
||||
'📄 Aquí tenemos el flujo secundario',
|
||||
])
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer(['📄 Aquí tenemos el flujo secundario'])
|
||||
|
||||
const flowDocs = addKeyword([
|
||||
'doc',
|
||||
'documentacion',
|
||||
'documentación',
|
||||
]).addAnswer(
|
||||
const flowDocs = addKeyword(['doc', 'documentacion', 'documentación']).addAnswer(
|
||||
[
|
||||
'📄 Aquí encontras las documentación recuerda que puedes mejorarla',
|
||||
'https://bot-whatsapp.netlify.app/',
|
||||
@@ -65,11 +54,7 @@ const flowGracias = addKeyword(['gracias', 'grac']).addAnswer(
|
||||
)
|
||||
|
||||
const flowDiscord = addKeyword(['discord']).addAnswer(
|
||||
[
|
||||
'🤪 Únete al discord',
|
||||
'https://link.codigoencasa.com/DISCORD',
|
||||
'\n*2* Para siguiente paso.',
|
||||
],
|
||||
['🤪 Únete al discord', 'https://link.codigoencasa.com/DISCORD', '\n*2* Para siguiente paso.'],
|
||||
null,
|
||||
null,
|
||||
[flowSecundario]
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
const { createBot, createProvider, createFlow, addKeyword } = require('@bot-whatsapp/bot')
|
||||
|
||||
const QRPortalWeb = require('@bot-whatsapp/portal')
|
||||
const WebWhatsappProvider = require('@bot-whatsapp/provider/web-whatsapp')
|
||||
@@ -21,15 +16,9 @@ const MockAdapter = require('@bot-whatsapp/database/mock')
|
||||
* Primero declaras los submenus 1.1 y 2.1, luego el 1 y 2 y al final el principal.
|
||||
*/
|
||||
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer([
|
||||
'📄 Aquí tenemos el flujo secundario',
|
||||
])
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer(['📄 Aquí tenemos el flujo secundario'])
|
||||
|
||||
const flowDocs = addKeyword([
|
||||
'doc',
|
||||
'documentacion',
|
||||
'documentación',
|
||||
]).addAnswer(
|
||||
const flowDocs = addKeyword(['doc', 'documentacion', 'documentación']).addAnswer(
|
||||
[
|
||||
'📄 Aquí encontras las documentación recuerda que puedes mejorarla',
|
||||
'https://bot-whatsapp.netlify.app/',
|
||||
@@ -65,11 +54,7 @@ const flowGracias = addKeyword(['gracias', 'grac']).addAnswer(
|
||||
)
|
||||
|
||||
const flowDiscord = addKeyword(['discord']).addAnswer(
|
||||
[
|
||||
'🤪 Únete al discord',
|
||||
'https://link.codigoencasa.com/DISCORD',
|
||||
'\n*2* Para siguiente paso.',
|
||||
],
|
||||
['🤪 Únete al discord', 'https://link.codigoencasa.com/DISCORD', '\n*2* Para siguiente paso.'],
|
||||
null,
|
||||
null,
|
||||
[flowSecundario]
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
const { createBot, createProvider, createFlow, addKeyword } = require('@bot-whatsapp/bot')
|
||||
|
||||
const QRPortalWeb = require('@bot-whatsapp/portal')
|
||||
const WebWhatsappProvider = require('@bot-whatsapp/provider/web-whatsapp')
|
||||
@@ -28,15 +23,9 @@ const MONGO_DB_NAME = 'db_bot'
|
||||
* Primero declaras los submenus 1.1 y 2.1, luego el 1 y 2 y al final el principal.
|
||||
*/
|
||||
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer([
|
||||
'📄 Aquí tenemos el flujo secundario',
|
||||
])
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer(['📄 Aquí tenemos el flujo secundario'])
|
||||
|
||||
const flowDocs = addKeyword([
|
||||
'doc',
|
||||
'documentacion',
|
||||
'documentación',
|
||||
]).addAnswer(
|
||||
const flowDocs = addKeyword(['doc', 'documentacion', 'documentación']).addAnswer(
|
||||
[
|
||||
'📄 Aquí encontras las documentación recuerda que puedes mejorarla',
|
||||
'https://bot-whatsapp.netlify.app/',
|
||||
@@ -72,11 +61,7 @@ const flowGracias = addKeyword(['gracias', 'grac']).addAnswer(
|
||||
)
|
||||
|
||||
const flowDiscord = addKeyword(['discord']).addAnswer(
|
||||
[
|
||||
'🤪 Únete al discord',
|
||||
'https://link.codigoencasa.com/DISCORD',
|
||||
'\n*2* Para siguiente paso.',
|
||||
],
|
||||
['🤪 Únete al discord', 'https://link.codigoencasa.com/DISCORD', '\n*2* Para siguiente paso.'],
|
||||
null,
|
||||
null,
|
||||
[flowSecundario]
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
const { createBot, createProvider, createFlow, addKeyword } = require('@bot-whatsapp/bot')
|
||||
|
||||
const QRPortalWeb = require('@bot-whatsapp/portal')
|
||||
const WebWhatsappProvider = require('@bot-whatsapp/provider/web-whatsapp')
|
||||
@@ -30,15 +25,9 @@ const MYSQL_DB_NAME = 'bot'
|
||||
* Primero declaras los submenus 1.1 y 2.1, luego el 1 y 2 y al final el principal.
|
||||
*/
|
||||
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer([
|
||||
'📄 Aquí tenemos el flujo secundario',
|
||||
])
|
||||
const flowSecundario = addKeyword(['2', 'siguiente']).addAnswer(['📄 Aquí tenemos el flujo secundario'])
|
||||
|
||||
const flowDocs = addKeyword([
|
||||
'doc',
|
||||
'documentacion',
|
||||
'documentación',
|
||||
]).addAnswer(
|
||||
const flowDocs = addKeyword(['doc', 'documentacion', 'documentación']).addAnswer(
|
||||
[
|
||||
'📄 Aquí encontras las documentación recuerda que puedes mejorarla',
|
||||
'https://bot-whatsapp.netlify.app/',
|
||||
@@ -74,11 +63,7 @@ const flowGracias = addKeyword(['gracias', 'grac']).addAnswer(
|
||||
)
|
||||
|
||||
const flowDiscord = addKeyword(['discord']).addAnswer(
|
||||
[
|
||||
'🤪 Únete al discord',
|
||||
'https://link.codigoencasa.com/DISCORD',
|
||||
'\n*2* Para siguiente paso.',
|
||||
],
|
||||
['🤪 Únete al discord', 'https://link.codigoencasa.com/DISCORD', '\n*2* Para siguiente paso.'],
|
||||
null,
|
||||
null,
|
||||
[flowSecundario]
|
||||
|
||||
Reference in New Issue
Block a user