Digital Assistant and Mobile

Get Involved. Join the Conversation.

Topic

    Sharath Chandra Gavini
    Add delay to consecutive messages
    Topic posted May 15, 2019 by Sharath Chandra GaviniBlue Ribbon: 750+ Points, last edited May 15, 2019, tagged Bots, Conversational AI 
    14 Views, 4 Comments
    Title:
    Add delay to consecutive messages
    Summary:
    How to add a delay to the messages sent from the custom components
    Content:

    Hi all, 
    I have a component where I am sending multiple text responses one after the other. All the messages appear at once and it doesn't give a good chat experience. I want to add delay to the messages so that it appears more realistic. I tried adding timeouts and promises but that didn't work. Is there any way of achieving this?
    Thanks in advance,
    Sharath Chandra Gavini.

    Comment

     

    • Rohit Dhamija

      Hi Sharath,

       

      An enhancement request is logged for the same. However in mean time the purpose can be served by building a custom component to add the desired delay.

      Just created a custom component for POC purpose , please find the code here 

      https://github.com/rohitdhamija/slowwme

      The code contains sample skill, custom component code . Please try the same and let know if it helps.

      Thanks!

       

      • Sharath Chandra Gavini

        Thanks a lot Mr. Rohit for the answer. I really appreciate it. I checked the code out and I found it is a component that needs to be invoked everytime there needs to be a delay.
        My usecase is a different one. I want to add a delay to the messages that are sent from the same component using the conversation.reply() method.

        Is there any way of achieving that?

        Regards, 
        Sharath Gavini

    • Rohit Dhamija

      Hi Sharath,

      Thanks for your reply,

      How about adding

      conversation.reply(`I slept for ~${diff} milliseconds`);  

      after the delay, I updated the code, can you please check if it serves your purpose?

      Thanks!

      • Sharath Chandra Gavini

        Thanks a lot for the quick reply.
        But that doesn't solve my problem.
        My requirement is:

        ->conversation.reply('message1');
        
        waitForTimeout(timeout);
        
        ->conversation.reply('message2');
        
        waitForTimeout(timeout);
        
        ->conversation.reply('message3');
        
        done();
        
        

        All these should happen inside a single custom component. What I observed is that all the messages sent using the reply() method are being queued up until done is called and then are sent all at once. Is there any way to alter this behavior of the SDK?

        Thanks,
        Sharath Gavini.