0

When a user starts a conversation with my WhatsApp bot, it will initiate a new studio flow execution.

The first widget is to call a function built in the Twilio serverless functions.

The function executes just fine and the WhatsApp quick-reply template message (created via the Twilio content API) is delivered successfully. However, there is no send and wait functionality when executing a function.

Has anyone been able to get around this?

I am basically trying to achieve the following:

  1. User starts a conversation using WhatsApp which initiates a studio flow execution
  2. Incoming message triggers a function which sends a WhatsApp quick reply template message
  3. User then selects one of the buttons in the template message
  4. Based on selection, the studio flow is split into two different journeys.

Every time the user selects a button on the quick reply template, it is treated as a new conversation, and does not continue in the same flow.

Gavz22
  • 1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Aug 28 '23 at 05:56

1 Answers1

0

have you tried: const twilio = require('twilio');

exports.handler = function(context, event, callback) { const client = twilio(context.ACCOUNT_SID, context.AUTH_TOKEN);

const message = {
    to: event.to, // Recipient's WhatsApp number
    from: event.from, // Your Twilio WhatsApp number
    body: event.body // Content of the message
};

client.messages.create(message)
    .then(result => {
        console.log('Message sent:', result.sid);
        callback(null, 'Message sent');
    })
    .catch(error => {
        console.error('Error sending message:', error);
        callback(error);
    });

};