how do i make my bot functional and UX friendly bot?

This is the documentation: https://bot-whatsapp.netlify.app/docs/essential/

**This are my problems: **

  1. I need users to access bot functions without starting flowInicio over and over again.
  2. I need users to select multiple menuFlow options without restarting the bot using “DATAVENGER”. Also, option 0 doesnt work at all.
  3. And flowCurso dies when I get to flowCurso 2 and can’t finish whats its supossed to be a conceptual course about fake news, missinformation, etc.

How do i solve em all?

This is my code:

const { createBot, createProvider, createFlow, addKeyword, EVENTS } = 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 path = require("path");
const fs = require("fs");

const mensajesDir = path.join(__dirname, "mensajes");

const readMessage = (fileName) => {
    const filePath = path.join(mensajesDir, fileName);
    return fs.readFileSync(filePath, "utf8");
};

const menuPath = path.join(mensajesDir, "Republica.txt");
const menu = fs.readFileSync(menuPath, "utf8");

const flowInicio = addKeyword(['datavenger', 'Datavenger', 'DATAVENGER', 'DataAvenger'])
    .addAnswer('???? ¡Hola! Bienvenido al *Datavenger* ????????‍♀????????‍♂ de la *República TV*', { delay: 1000 })
    .addAnswer('Nuestro objetivo es garantizar el *libre*, *verídico* y *confiable* acceso a la información ✅', { delay: 1000 })
    .addAnswer('➡ Será posible *enviar esos datos que te tienen dudando*, y nuestro equipo _verificará si son ciertos_ o _te quieren ver la cara_ ????', { delay: 1000 })
    .addAnswer('➡ Podrás sugerirnos temas que quieres que investiguemos', { delay: 1000 })
    .addAnswer('➡ Y tendrás la oportunidad de hacer nuestro *curso exprés* para que estés preparado para *combatir la desinformación* y seas un *#HeroeXLaInformación* ????????‍♂????????‍♀', { delay: 1000 })
    .addAnswer('???? ¿En qué podemos ayudarte? Escribe *República* para ver las opciones', { delay: 1000, capture: true }, async (ctx, { gotoFlow }) => {
        if (['republica', 'república', 'República', 'Republica', 'REPÚBLICA', 'rEPÚBLICA', 'rEPUBLICA', 'REPUBLICA'].includes(ctx.body.toLowerCase())) {
            return gotoFlow(flowMenu);
        }
    });

const flowMenu = addKeyword(EVENTS.ACTION).addAnswer(
    menu,
    { capture: true, delay: 2500 },
    async (ctx, { gotoFlow, flowDynamic }) => {
        switch (ctx.body) {
            case "1":
                return gotoFlow(flowCurso);
            case "2":
                return gotoFlow(flowInvestiga);
            case "3":
                return gotoFlow(flowBoletin);
            case "4":
                return gotoFlow(flowRedes);
            case "0":
                await flowDynamic("Saliendo... Puedes volver a acceder a este menú escribiendo *República*");
                return;
            default:
                await flowDynamic("Respuesta no válida, por favor selecciona una de las opciones.");
                return gotoFlow(flowMenu);
        }
    }
);



const flowInvestiga = addKeyword(EVENTS.ACTION)
    .addAnswer('prueba investiga', { capture: false }, async (ctx, { gotoFlow }) => {
        return gotoFlow(flowMenu);
    });

const flowBoletin = addKeyword(EVENTS.ACTION)
    .addAnswer('¡Únete a nuestro *canal de difusión* para estar al tanto de lo que sucede! ???????? https://shorturl.at/hQntC', { capture: false }, async (ctx, { gotoFlow }) => {
        return gotoFlow(flowMenu);
    });

const flowRedes = addKeyword(EVENTS.ACTION)
    .addAnswer('prueba redes', { capture: false }, async (ctx, { gotoFlow }) => {
        return gotoFlow(flowMenu);
    });


const flowCierre = addKeyword(EVENTS.ACTION)
    .addAnswer('prueba ¡chao!', { capture: true }, async (ctx, { gotoFlow }) => {
        if (['republica', 'República'].includes(ctx.body.toLowerCase())) {
            return gotoFlow(flowMenu);
        }
    });

const flowCurso = addKeyword(EVENTS.ACTION)
    .addAnswer(readMessage('Test1.txt'), { capture: true }, async (ctx, { gotoFlow, flowDynamic }) => {
        if (isValidResponse(ctx.body)) {
            if (isYesResponse(ctx.body)) {
                return gotoFlow(flowCurso2);
            } else if (isNoResponse(ctx.body)) {
                return await flowDynamic('*Datavenger: Ok acá estaré esperándote*', flowMenu);
            }
        } else {
            return await flowDynamic('Respuesta no válida. Por favor selecciona "Sí", "No", "1" o "2".', flowCurso);
        }
    });

const flowCurso2 = addKeyword(EVENTS.ACTION)
    .addAnswer(readMessage('Test2.txt'), { capture: true }, async (ctx, { gotoFlow, flowDynamic }) => {
        if (isValidResponse(ctx.body)) {
            if (isYesResponse(ctx.body)) {
                return gotoFlow(flowCurso3);
            } else if (isNoResponse(ctx.body)) {
                return await flowDynamic('Vale, quizás necesitas un café para volver con más energía ☕⚡', flowMenu);
            }
        } else {
            return await flowDynamic('Respuesta no válida. Por favor selecciona "Sí", "No", "1" o "2".', flowCurso2);
        }
    });

function isValidResponse(response) {
    const validResponses = ['sí', 'Sí', 'SI', 'SÍ', 'si', 'Si', 'no', 'NO', 'No', '1', '2'];
    return validResponses.includes(response);
}

function isYesResponse(response) {
    const yesResponses = ['sí', 'Sí', 'SI', 'SÍ', 'si', 'Si', '1'];
    return yesResponses.includes(response);
}

function isNoResponse(response) {
    const noResponses = ['no', 'NO', 'No', '2'];
    return noResponses.includes(response);
}


const flowCurso3 = addKeyword(EVENTS.ACTION)
    .addAnswer(readMessage('Test3.txt'), { capture: true }, async (ctx, { flowDynamic, gotoFlow }) => {
        if (ctx.body.toLowerCase() === 'a') {
            await flowDynamic('¡Correcto! Toda información falsa presentada como verdadera es desinformación.*');
        } else {
            await flowDynamic('Incorrecto. La respuesta correcta es A.');
        }
        return gotoFlow(flowCurso4);
    });

const flowCurso4 = addKeyword(EVENTS.ACTION)
    .addAnswer(readMessage('Test4.txt'), { capture: true }, async (ctx, { flowDynamic, gotoFlow }) => {
        if (ctx.body.toLowerCase() === 'b') {
            await flowDynamic('¡Correcto! Recuerda que es importante verificar la fuente.');
        } else {
            await flowDynamic('Incorrecto. Recuerda verificar la fuente.');
        }
        return gotoFlow(flowCurso5);
    });

const flowCurso5 = addKeyword(EVENTS.ACTION)
    .addAnswer(readMessage('Test5.txt'), { capture: true }, async (ctx, { flowDynamic, gotoFlow }) => {
        if (ctx.body.toLowerCase() === 'c') {
            await flowDynamic('¡Correcto! Los memes son formatos creativos para presentar hechos.');
        } else {
            await flowDynamic('Incorrecto. Algunos memes pueden ayudar a informar.');
        }
        return gotoFlow(flowCurso6);
    });

const flowCurso6 = addKeyword(EVENTS.ACTION)
    .addAnswer(readMessage('Test6.txt'), { capture: true }, async (ctx, { flowDynamic, gotoFlow }) => {
        if (ctx.body.toLowerCase() === 'a') {
            await flowDynamic('¡Correcto! Todos debemos verificar la información.');
        } else {
            await flowDynamic('Incorrecto. La respuesta correcta es A.');
        }
        return gotoFlow(flowCurso7);
    });

const flowCurso7 = addKeyword(EVENTS.ACTION)
    .addAnswer(readMessage('Test7.txt'), { capture: true }, async (ctx, { flowDynamic }) => {
        if (ctx.body.toLowerCase() === 'b') {
            await flowDynamic('¡Correcto! Verifica la autenticidad de una imagen o video.');
        } else {
            await flowDynamic('Incorrecto. Usa Google Imágenes y TinEye para verificar imágenes y videos.');
        }
        return gotoFlow(flowCursoFinal);
    });

const flowCursoFinal = addKeyword(EVENTS.ACTION)
    .addAnswer(readMessage('Testfinal.txt'), { capture: false }, async (ctx, { flowDynamic, gotoFlow }) => {
        await flowDynamic('¡Gracias por participar en el test! Aquí tienes algunas herramientas para combatir la desinformación:*nn1. *Verifica siempre la fuente*: Asegúrate de que la información proviene de una fuente confiable. Puedes usar sitios como La TV Calle y sus canales de noticias (link)nn2. *Usa la búsqueda inversa de imágenes*: Herramientas como [Google Imágenes](https://images.google.com/) y [TinEye](https://tineye.com/) pueden ayudarte a verificar la autenticidad de fotos y videos.nn3. *Educa a otros*: Comparte información verificada y ayuda a tus amigos y familiares a identificar desinformación. Puedes encontrar recursos educativos en [Cazadores de Fake News](https://cazadoresdefakenews.info/) y [Probox](https://probox.com.ve/).nn4. *Se escéptico con los titulares sensacionalistas*: Investiga más antes de compartir.nn5. *Utiliza memes con responsabilidad*: Los memes pueden ser una herramienta poderosa para educar y combatir la desinformación de manera efectiva y atractiva. Aquí tienes una guía sobre cómo crear memes informativos en [Crehana](https://www.crehana.com/co/blog/diseno-grafico/como-crear-memes/).');
        return gotoFlow(flowMenu);
    });

const main = async () => {
    const adapterDB = new MockAdapter();
    const adapterFlow = createFlow([flowInicio, flowMenu, flowCurso, flowInvestiga, flowBoletin, flowRedes, flowCierre]);
    const adapterProvider = createProvider(BaileysProvider);

    createBot({
        flow: adapterFlow,
        provider: adapterProvider,
        database: adapterDB,
    });

    QRPortalWeb();
};

main();

I tried to keep the menuFlow alive but now its always re-rendering in the chat.

I cant finish the course

I need ¨experienced” users with the bot to get straight to what they want without starting the app from scratch

New contributor

Andrés Torres is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật