How can i add pause to Twilio studio Say/Play widget

前端 未结 3 1653
渐次进展
渐次进展 2021-01-14 05:06

I have a say widget

> \"Hello ... Thanks\"

I\'ve tried add a pause string like twilML to that element like so

> \"He         


        
3条回答
  •  花落未央
    2021-01-14 05:43

    Really somebody at Twilio should create a PAUSE widget for Studio.

    Until then if you're happy using an ugly hack... here it is:

    Since you can add a function widget in the flow, create a Twilio "Runtime Function" (I called it "Pause")


        exports.handler = function(context, event, callback) {
    
            const duration = event.duration || 1500; 
    
            setTimeout(
                function() {
                    // console.log(duration);
                    callback();          
                } , duration);
    
        };
    

    then, replace one "Say" widget with "Say" widget + "Pause" function widget + "Say" widget.

    When you add the "Pause" widget configure it with parameters, add a duration parameter with a value that is no more than about 3000 to 4000 (I don't know exactly how to explain why but functions will 'runtime timeout' if the function takes more than 5 seconds to execute).

    When you add parameters, make sure they are in fact added..., I had some trouble until I figured out that you need to click on "Add Parameter" link after you fill the "Key", "Value" fields, instead I was clicking on the big "Save" button.

    Since you are looking for a 10 seconds pause, you might try to cascade 3 "Pause" widgets with duration parameter (3000, 3000, 4000), between your "Say" widgets.

    I've tested this and I was able to make a pause between 2 "Say" widgets of 7 seconds by inserting one 3000 pause and one 4000 pause functions.

    I hope it helps.

提交回复
热议问题