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

fix: arreglando dir y varios mensajes en dialog flow essential #556

Merged
merged 3 commits into from
Feb 10, 2023

Conversation

DiegoAlonso27
Copy link
Contributor

Que tipo de Pull Request es?

  • [ x] Mejoras
  • [ x] Bug
  • Docs / tests

Descripción

Por favor agrega una descripción de tu aporte para tener más contexto y poder avanzar más rápido. Si es de ayuda puedes usar plataformar como https://www.loom.com/ para grabar un video.

Al inicio salia ese error cuando intentaba ejecutar un entorno de prueba

> base-bailey-memory@1.0.0 start
> node app.js

dir undefined
    throw new TypeError('root path required')
    ^

TypeError: root path required
    at serveStatic (E:\TS-PROJECTS\bot-whatsapp-1\node_modules\serve-static\index.js:40:11)
    at Object.<anonymous> (E:\TS-PROJECTS\bot-whatsapp-1\base-baileys-memory\node_modules\@bot-whatsapp\portal\lib\portal.http.cjs:29:15)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)                                                                )
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (E:\TS-PROJECTS\bot-whatsapp-1\base-baileys-memory\app.js:5:21)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)

Node.js v18.12.1

Asi que cambie

/* const dir = [join(__dirname, 'dist'), join(__dirname, '..', 'dist')].find((i) =>
    existsSync(i)
) */
const dir = join(__dirname, 'dist')

Luego lo que yo quería es que cuando agregabas una respuesta con varios mensajes en dialogflow se envíen todos los mensajes y no solo el primero así que analice el array que manda dialogflow y lo convertí en el estándar que utilizan para enviar los mensajes 👍🏻


        /* const ctxFromDX = {
            answer: queryResult?.fulfillmentText,
        } */

        const arrayMsg = queryResult['fulfillmentMessages']
            .map((a) => {
                if (a.message === 'text') {
                    return { answer: a.text.text[0] }
                }
            })
            .filter((e) => e)

        this.sendFlowSimple(arrayMsg, from)

Forma parte de este proyecto.

@leifermendez leifermendez changed the base branch from main to dev February 9, 2023 16:27
@leifermendez
Copy link
Member

tienes un conflicto puedes revisarlo para aceptar el PR

@leifermendez leifermendez merged commit bd90939 into codigoencasa:dev Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants