PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, November 18, 2022

[FIXED] How long would a message take to say

 November 18, 2022     twilio, twilio-api, twilio-php, twilio-twiml     No comments   

Issue

In the twilio API is it possible to figure out how long a message is going to take?

My Requst come from that I need to figure out if a verbal message has been said.

a API endpoint to get the time of a special Twiml or asking on a call if it did all the say would be the best option.

We are logging length of call etc but we still need to see if they have heard all of message or hang up before it is all done.


Solution

Twilio developer evangelist here.

There's no way to know how long a message will take, but I have another idea.

If you set up your <Say> message with a <Redirect> after it, then the user will have heard all the message if the <Redirect> url receives a request.

<Response>
  <Say>This is an important message.</Say>
  <Redirect method="POST">https://example.com/results/success</Redirect>
</Response>

Let me know if that helps at all.

Update

So, the above didn't exactly work as Twilio seems to read ahead and load the <Redirect> URL before the <Say> has completed. However, we can still use this to help.

In the response to the <Redirect> URL, we can make Twilio call to another URL somehow. For example, the following TwiML will call out to a URL to fetch a file to <Play> to the user. Rather than call directly to an mp3 file you can make this call to a server that notes the call got this far and then returns a short, maybe silent, mp3 file. Then we can hangup because we've done what we needed to do.

<Response>
  <Play>https://example.com/record_call_complete_and_return_mp3</Play>
  <Hangup/>
</Response>

This is a bit of a hack, but it seems to work as the <Play> URL is only requested when Twilio starts the response to the <Redirect>.



Answered By - philnash
Answer Checked By - Pedro (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing