skip to Main Content

I’m building a Microsoft Bot Framework v4 bot for SMS (Twillio channel, Node.js) and I need to control message delays, particularly when I’m sending images–otherwise things have a high probability of arriving to the user out of order.

In v3 bot framework, this could be easily achieved through using, for example, Session.delay(3000);

Is there an equivalent for v4?

2

Answers


  1. Chosen as BEST ANSWER

    OK, here's how I'm handling delays: in this scenario, I'm essentially adding an extra step to the waterfall that simply serves as a delay step after a HeroCard. Feels like there could be a better way?

    const timeout = ms => new Promise(resolve => setTimeout(resolve, ms));
    

    Then, in the waterfall:

    async thisIsAtextStep(step) {
                await step.context.sendActivity(
                    `I am some text for the user`
                );
                return step.next();
            }
    
    async thisIsAnimageStep(step) {
                const tocCard = CardFactory.heroCard(
                    'This is an image',
                    CardFactory.images([
                        'https://...someImage.png'
                    ])
                );
                await step.context.sendActivity({
                    attachments: [tocCard]
                });
                return step.next();
                }
    
     async addDelayStep(step) {
            console.log('timer start--let's wait');
            await timeout(13000);
            console.log('timer end--let's move to next step');
            return step.beginDialog(SOME_OTHER_DIALOG);
        }
    

  2. Did u try the following?

    await context.sendActivities([{ type: 'delay', value: 13000 }]);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search