Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: (✏️) added documentation for idle feature #880

Merged
merged 2 commits into from
Oct 9, 2023

Conversation

william-monroy
Copy link
Contributor

added idle docs and example

Que tipo de Pull Request es?

  • Mejoras
  • Bug
  • Docs / tests

Descripción

Se añadió documentación para idle

Captura de pantalla 2023-10-09 a la(s) 12 02 56 a m

@leifermendez
Copy link
Member

@william-monroy creo que tienes un conflicto

@william-monroy
Copy link
Contributor Author

@leifermendez el conflicto esta resuelto :octocat:

@leifermendez leifermendez merged commit 6677522 into codigoencasa:main Oct 9, 2023
2 checks passed
@jorgechavarriaga
Copy link
Collaborator

Idle no funciona cuando hay un fallBack..

Si el usuario no entra nada en 2 segundo el flujo vuelve y se ejecuta..si el usuario entra un numero "1" es enviado al flujo final y termina.. pero si el usuario entra cualquier otra cadena... el flujo vuelve a ejecutarse pero ya no tiene efecto el idle.. se queda por siempre esperando la respuesta del usuario...

si el fallBack lo llamo asi fallBack('Valor no valido)... igual se queda en ese mensaje pero nuevamente no tiene efecto el idel

const { createBot, createProvider, createFlow, addKeyword, EVENTS, media } = 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 flujoFinal = addKeyword(EVENTS.ACTION).addAnswer('Se cancelo por inactividad')

const flujoPrincipal = addKeyword(['hola'])
.addAnswer(
'Debes de responder con el numero 1 antes de que trascurrand 2 segundos',
{capture: true, idle: 2000 },
async (ctx, {gotoFlow, flowDynamic, fallBack})=>{
if(ctx?.idleFallBack){
return gotoFlow(flujoPrincipal)
}
if(ctx.body === "1"){
return flowDynamic('Respondiste antes de 2 segundos!')
} else {
return fallBack()
}
}
)

const main = async () => {
const adapterDB = new MockAdapter();
const adapterFlow = createFlow([ flujoPrincipal, flujoFinal ])
const adapterProvider = createProvider(BaileysProvider);
createBot({ flow: adapterFlow, provider: adapterProvider, database: adapterDB });
QRPortalWeb({port:3001});
};

main();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants