When working with Twilio Python SDK, there is a simple way handle an incoming call to forward it to using the <Dial>
verb. However, you can also forward the call to multiple numbers at the same time for a Simulring
funcationality.
from twilio.twiml.voice_response import VoiceResponse
response = VoiceReponse()
response.dial('+18125553333')
This should give us the Twiml output below which will instruct Twilio to dial the number.
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial>812-555-3333</Dial>
</Response>
Okay, so we got the basic call fowarding functionality now, but what if we want to forward the call to multiple numbers and let the first to answer take the call? This is called Simulring.
from twilio.twiml.voice_response import VoiceResponse
response = VoiceReponse()
with response as resp:
with resp.dial(timeout=40) as d:
d.number("+13151234567")
d.number("+18121234568")
d.number("+15021234569")
This will give use a Simulring Twiml output to dial multiple numbers at the same time and connect the first person who answers the call.
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial timeout="40">
<Number>315-123-4567</Number>
<Number>812-123-4568</Number>
<Number>502-123-4569</Number>
</Dial>
</Response>
If you’re looking for more examples of what you can do with Twiml on the Twilio API, have a look at Twimlets.