Merge branch 'codigoencasa:dev' into dev

This commit is contained in:
2023-01-07 17:03:27 -06:00
committed by GitHub
8 changed files with 32 additions and 22 deletions

View File

@@ -123,7 +123,7 @@ class CoreClass {
// 📄 [options: callback]: Si se tiene un callback se ejecuta // 📄 [options: callback]: Si se tiene un callback se ejecuta
if (!fallBackFlag) { if (!fallBackFlag) {
if (refToContinue?.options?.capture) cbEveryCtx(refToContinue?.ref) if (prevMsg?.options?.capture) cbEveryCtx(prevMsg?.ref)
for (const ite of this.flowClass.find(body)) { for (const ite of this.flowClass.find(body)) {
if (!ite?.options?.capture) cbEveryCtx(ite?.ref) if (!ite?.options?.capture) cbEveryCtx(ite?.ref)
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "@bot-whatsapp/bot", "name": "@bot-whatsapp/bot",
"version": "0.0.42-alpha.0", "version": "0.0.45-alpha.0",
"description": "", "description": "",
"main": "./lib/bundle.bot.cjs", "main": "./lib/bundle.bot.cjs",
"scripts": { "scripts": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@bot-whatsapp/cli", "name": "@bot-whatsapp/cli",
"version": "0.0.49-alpha.0", "version": "0.0.52-alpha.0",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"devDependencies": { "devDependencies": {

View File

@@ -97,13 +97,21 @@ class DialogFlowContext extends CoreClass {
}) })
customPayload = { customPayload = {
options: {
media: fields?.media?.stringValue, media: fields?.media?.stringValue,
buttons: mapButtons, buttons: mapButtons,
} },
} }
const ctxFromDX = { const ctxFromDX = {
...customPayload, ...customPayload,
answer: fields?.answer?.stringValue,
}
this.sendFlow([ctxFromDX], from)
return
}
const ctxFromDX = {
answer: queryResult?.fulfillmentText, answer: queryResult?.fulfillmentText,
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "create-bot-whatsapp", "name": "create-bot-whatsapp",
"version": "0.0.60-alpha.0", "version": "0.0.63-alpha.0",
"description": "", "description": "",
"main": "./lib/bundle.create-bot-whatsapp.cjs", "main": "./lib/bundle.create-bot-whatsapp.cjs",
"files": [ "files": [

View File

@@ -1,6 +1,6 @@
{ {
"name": "@bot-whatsapp/database", "name": "@bot-whatsapp/database",
"version": "0.0.41-alpha.0", "version": "0.0.44-alpha.0",
"description": "Esto es el conector a mysql, pg, mongo", "description": "Esto es el conector a mysql, pg, mongo",
"main": "./lib/mock/index.cjs", "main": "./lib/mock/index.cjs",
"keywords": [], "keywords": [],

View File

@@ -1,6 +1,6 @@
{ {
"name": "@bot-whatsapp/provider", "name": "@bot-whatsapp/provider",
"version": "0.0.47-alpha.0", "version": "0.0.50-alpha.0",
"description": "Esto es el conector a Twilio, Meta, etc...", "description": "Esto es el conector a Twilio, Meta, etc...",
"main": "./lib/mock/index.cjs", "main": "./lib/mock/index.cjs",
"keywords": [], "keywords": [],

View File

@@ -4,7 +4,7 @@ const pino = require('pino')
const rimraf = require('rimraf') const rimraf = require('rimraf')
const mime = require('mime-types') const mime = require('mime-types')
const { join } = require('path') const { join } = require('path')
const { existsSync, createWriteStream } = require('fs') const { existsSync, createWriteStream, readFileSync } = require('fs')
const { Console } = require('console') const { Console } = require('console')
const { const {
@@ -137,7 +137,7 @@ class BaileysProvider extends ProviderClass {
} }
const btnCtx = const btnCtx =
payload?.message?.templateButtonReplyMessage payload?.message?.buttonsResponseMessage
?.selectedDisplayText ?.selectedDisplayText
if (btnCtx) payload.body = btnCtx if (btnCtx) payload.body = btnCtx
@@ -167,8 +167,8 @@ class BaileysProvider extends ProviderClass {
sendMedia = async (number, imageUrl, text) => { sendMedia = async (number, imageUrl, text) => {
const fileDownloaded = await baileyDownloadMedia(imageUrl) const fileDownloaded = await baileyDownloadMedia(imageUrl)
return this.vendor.sendMessage(number, { return this.vendor.sendMessage(number, {
image: { url: fileDownloaded }, image: readFileSync(fileDownloaded),
text, caption: text,
}) })
} }
@@ -229,20 +229,22 @@ class BaileysProvider extends ProviderClass {
*/ */
sendButtons = async (number, text, buttons) => { sendButtons = async (number, text, buttons) => {
const numberClean = number.replace('+', '') const numberClean = baileyCleanNumber(number)
const templateButtons = buttons.map((btn, i) => ({ const templateButtons = buttons.map((btn, i) => ({
index: `${i}`, buttonId: `id-btn-${i}`,
quickReplyButton: { buttonText: { displayText: btn.body },
displayText: btn.body, type: 1,
id: `id-btn-${i}`,
},
})) }))
return this.vendor.sendMessage(`${numberClean}@c.us`, { const buttonMessage = {
text, text,
footer: '', footer: '',
templateButtons: templateButtons, buttons: templateButtons,
}) headerType: 1,
}
return this.vendor.sendMessage(numberClean, buttonMessage)
} }
/** /**