howdyai / botkit

Botkit is an open source developer tool for building chat bots, apps and custom integrations for major messaging platforms.
MIT License
11.48k stars 2.28k forks source link

Twilio-sms not waiting for reply #1721

Closed riteshtk closed 5 years ago

riteshtk commented 5 years ago

Please suggest to us. we are stuck here.

Twilio-SMS bot not waiting for a reply when I'm triggering dialog using bot.beginDialog() and using API and the same code is working

When I created a function to start a conversation with a user like below and then it triggering the first message but not waiting for a reply for the same message as I did in my code

controller.webserver.get('/test', async function (req, res, next) {
        // console.log(req.params.id)
        let bot = await controller.spawn();
        await bot.startConversationWithUser(process.env.GOOGLE_NUMBER);
        // console.log(bot);
        await bot.beginDialog('workflow_id');
        res.send({data: 'special'});
    });

Added convo dialog like this

const MY_CONVO = 'workflow_id';
    let convo = new BotkitConversation(MY_CONVO, controller);
    convo.ask('What is your name?',[], {key: 'name'});
    convo.ask('What is your age?', [], 'age');
    convo.ask('What is your favorite color?', [], 'color');
    convo.after(async (results, bot) => {

        // handle results.name, results.age, results.color
        console.log(results.name + results.age + results.color);

    });
    controller.addDialog(convo);

same added dialog code is working fine when I'm starting conversations with like below just sending SMS to bot number workflow .

controller.hears('workflow', 'message', async (bot, message) => {
        await bot.beginDialog('workflow_id');
    });
benbrown commented 5 years ago

This was due to a configuration problem.

The phone number provided to Twilio must be in the form +1XXXYYYZZZZ