feat(bot): flowDynamic buttons, media

This commit is contained in:
Leifer Mendez
2023-01-23 11:52:49 +01:00
parent 79cc31a96f
commit 3c4b1c0fc4
2 changed files with 12 additions and 5 deletions

View File

@@ -117,6 +117,7 @@ class CoreClass {
// 📄 [options: flowDynamic]: esta funcion se encarga de responder un array de respuesta esta limitado a 5 mensajes
// para evitar bloque de whatsapp
const flowDynamic = async (
listMsg = [],
optListMsg = { limit: 5, fallback: false }
@@ -126,15 +127,21 @@ class CoreClass {
fallBackFlag = optListMsg.fallback
const parseListMsg = listMsg
.map(({ body }, index) =>
toCtx({
.map((opt, index) => {
const body = typeof opt === 'string' ? opt : opt.body
const media = opt?.media ?? null
const buttons = opt?.buttons ?? []
return toCtx({
body,
from,
keyword: null,
index,
options: { media, buttons },
})
)
})
.slice(0, optListMsg.limit)
for (const msg of parseListMsg) {
await this.sendProviderAndSave(from, msg)
}