Recording a voicemail while in a Twilio Queue

后端 未结 2 1184
灰色年华
灰色年华 2021-01-03 07:41

I\'m writing a call centre app using Twilio, and I\'ve run into a problem. The calls are received and put into a queue, while we find an agent to answer the call. Whilst t

相关标签:
2条回答
  • 2021-01-03 08:18

    I found a solution to this which doesn't mean anyone dropping out of the queue goes to voicemail, and it's to use the REST API to change the relevant call, dropping it from the queue and forwarding to another TWiML document which records your message.

    0 讨论(0)
  • 2021-01-03 08:20

    Twilio developer evangelist here.

    This behaviour is by design. The <Enqueue> documentation provides you the verbs that can be used within the waitUrl TwiML. However, this does not mean that you are out of luck, we can still create this feature.

    Instead of going from <Gather> to <Say/><Record/> you can use <Leave> to have the user leave the queue. The call won't hang up, rather it will try to carry on from after the original <Enqueue>. Add your <Say/><Record/> in that original TwiML and it will play when the user decides to leave the queue and record a message.

    So, you initial TwiML will now be:

    <Response>
      <Say voice="alice" language="en-AU">
        Thanks for calling, please note all calls may be recorded for security and training purposes. We'll answer your call very shortly.
      </Say>
      <Enqueue waitUrl="http://ngrok.com/holdMusic">1COVERAUS</Enqueue>
      <Say voice="alice" language="en-AU">
        Please record your message after the tone.
      </Say>
      <Record action="http://ngrok.com/handleVoicemailRecording"></Record>
    </Response>
    

    Your waitUrl TwiML stays the same:

    <Response>
      <Gather numDigits="1" action="http://ngrok.com/leaveVoicemail">
        <Say>
          Thanks for waiting, you're 1 in the queue. Press 1 at any time to leave a message.</Say>
        <Play>https://s3-ap-southeast-2.amazonaws.com/somemusic.mp3</Play>
      </Gather>
    </Response>
    

    And the Gather action simply becomes:

    <Response>
      <Leave/>
    </Response>
    

    Let me know if that helps at all.

    0 讨论(0)
提交回复
热议问题