mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-17 19:26:23 +00:00
chore(bot): ⚡ added new fallback option
This commit is contained in:
9
TODO.md
9
TODO.md
@@ -4,7 +4,7 @@
|
||||
- [ ] __(doc)__ Video explicacion de github action
|
||||
|
||||
### @bot-whatsapp/bot
|
||||
- [ ] agregar export package
|
||||
- [X] agregar export package
|
||||
- [X] Posibilidad de en el capture meter todo un nuevo CTX de FLOW .addAnswer('Marca la opcion',{capture:true, join:CTX})
|
||||
- [X] .addKeyword('1') no funciona con 1 caracter
|
||||
- [X] sensitivy viene activado por defecto
|
||||
@@ -12,6 +12,7 @@
|
||||
- [ ] colocar mensaje esperando conectando whatsapp (provider)
|
||||
- [ ] Cuando Envian Sticket devuelve mensaje raro
|
||||
- [ ] createDatabase validar implementacion de funciones
|
||||
- [ ] limitar caracteres de mensajes
|
||||
|
||||
### @bot-whatsapp/database
|
||||
- [X] agregar export package
|
||||
@@ -29,4 +30,8 @@
|
||||
- [ ] Meta adapter
|
||||
|
||||
### @bot-whatsapp/cli
|
||||
- [ ] Hacer comando para crear `example-app`
|
||||
- [X] Hacer comando para crear `example-app`
|
||||
|
||||
|
||||
### @bot-whatsapp/create-bot
|
||||
- [ ]
|
||||
@@ -67,13 +67,13 @@ class CoreClass {
|
||||
this.databaseClass.save(ctxByNumber)
|
||||
}
|
||||
|
||||
//Si se tiene un callback se ejecuta
|
||||
// 📄 [options: callback]: Si se tiene un callback se ejecuta
|
||||
if (refToContinue && prevMsg?.options?.callback) {
|
||||
const indexFlow = this.flowClass.findIndexByRef(refToContinue?.ref)
|
||||
this.flowClass.allCallbacks[indexFlow].callback(messageInComming)
|
||||
}
|
||||
|
||||
//Si se tiene anidaciones de flows, si tienes anidados obligatoriamente capture:true
|
||||
// 📄🤘(tiene return) [options: nested(array)]: Si se tiene flujos hijos los implementa
|
||||
if (prevMsg?.options?.nested?.length) {
|
||||
const nestedRef = prevMsg.options.nested
|
||||
const flowStandalone = nestedRef.map((f) => ({
|
||||
@@ -85,13 +85,19 @@ class CoreClass {
|
||||
return
|
||||
}
|
||||
|
||||
//Consultamos si se espera respuesta por parte de cliente "Ejemplo: Dime tu nombre"
|
||||
if (!prevMsg?.options?.nested?.length && prevMsg?.options?.capture) {
|
||||
msgToSend = this.flowClass.find(refToContinue?.ref, true) || []
|
||||
} else {
|
||||
msgToSend = this.flowClass.find(body) || []
|
||||
// 📄🤘(tiene return) [options: capture (boolean)]: Si se tiene option boolean
|
||||
if (!prevMsg?.options?.nested?.length) {
|
||||
const typeCapture = typeof prevMsg?.options?.capture
|
||||
const valueCapture = prevMsg?.options?.capture
|
||||
|
||||
if (['string', 'boolean'].includes(typeCapture) && valueCapture) {
|
||||
msgToSend = this.flowClass.find(refToContinue?.ref, true) || []
|
||||
this.sendFlow(msgToSend, from)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
msgToSend = this.flowClass.find(body) || []
|
||||
this.sendFlow(msgToSend, from)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
const { generateRef } = require('../../utils/hash')
|
||||
const { toJson } = require('./toJson')
|
||||
const { toSerialize } = require('./toSerialize')
|
||||
/**
|
||||
*
|
||||
* @param answer string
|
||||
@@ -79,6 +78,7 @@ const addAnswer =
|
||||
}
|
||||
}
|
||||
|
||||
/// Retornar contexto no colocar nada más abajo de esto
|
||||
const ctx = ctxAnswer()
|
||||
|
||||
return {
|
||||
|
||||
@@ -5,11 +5,6 @@ const {
|
||||
addKeyword,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
|
||||
/**
|
||||
* ATENCION: Si vas a usar el provider whatsapp-web.js
|
||||
* recuerda ejecutar npm i whatsapp-web.js@latest
|
||||
*/
|
||||
|
||||
const WebWhatsappProvider = require('@bot-whatsapp/provider/web-whatsapp')
|
||||
const MockAdapter = require('@bot-whatsapp/database/mock')
|
||||
|
||||
|
||||
@@ -6,11 +6,6 @@ const {
|
||||
addChild,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
|
||||
/**
|
||||
* ATENCION: Si vas a usar el provider whatsapp-web.js
|
||||
* recuerda ejecutar npm i whatsapp-web.js@latest
|
||||
*/
|
||||
|
||||
const WebWhatsappProvider = require('@bot-whatsapp/provider/web-whatsapp')
|
||||
const MockAdapter = require('@bot-whatsapp/database/mock')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user