0
votes

I am hanging up a call like this(java):

            Call.updater('somesid').setStatus(Call.UpdateStatus.COMPLETED).update();

I would like to play a message(not via some audio file, but via the twilio 'say' verb) before this call is ended.

How do I do it if its possible?

1

1 Answers

1
votes

Twilio developer evangelist here.

Instead of just completing the call with the API request, you can redirect the call to some new TwiML instead. To do so, you need a new URL to send the call to and you update it like this:

Call.updater(callSid)
        .setMethod(HttpMethod.POST)
        .setUrl(URI.create(newUrl))
        .update();

The new URL should then return TwiML that <Say>s the message you want and then hangs up with <Hangup/>. Like this:

<Response>
  <Say voice="alice">Sorry, I have to hang up now.</Say>
  <Hangup/>
</Response>