twilio.twiml package

Submodules

twilio.twiml.fax_response module

This code was generated by / _ _ _| _ _

(_)/(_)(_|/| |(/_ v1.0.0 / /

System Message: WARNING/2 (/twilio/repos/twilio-python/twilio/twiml/fax_response.py:docstring of twilio.twiml.fax_response, line 3); backlink

Inline substitution_reference start-string without end-string.
class twilio.twiml.fax_response.FaxResponse(**kwargs)[source]

Bases: twilio.twiml.TwiML

<Response> TwiML for Faxes

receive(action=None, method=None, media_type=None, page_size=None, store_media=None, **kwargs)[source]

Create a <Receive> element

Parameters:
  • action – Receive action URL
  • method – Receive action URL method
  • media_type – The media type used to store media in the fax media store
  • page_size – What size to interpret received pages as
  • store_media – Whether or not to store received media in the fax media store
  • kwargs – additional attributes
Returns:

<Receive> element

class twilio.twiml.fax_response.Receive(**kwargs)[source]

Bases: twilio.twiml.TwiML

<Receive> TwiML Verb

twilio.twiml.messaging_response module

This code was generated by / _ _ _| _ _

(_)/(_)(_|/| |(/_ v1.0.0 / /

System Message: WARNING/2 (/twilio/repos/twilio-python/twilio/twiml/messaging_response.py:docstring of twilio.twiml.messaging_response, line 3); backlink

Inline substitution_reference start-string without end-string.
class twilio.twiml.messaging_response.Body(message, **kwargs)[source]

Bases: twilio.twiml.TwiML

<Body> TwiML Noun

class twilio.twiml.messaging_response.Media(url, **kwargs)[source]

Bases: twilio.twiml.TwiML

<Media> TwiML Noun

class twilio.twiml.messaging_response.Message(body=None, **kwargs)[source]

Bases: twilio.twiml.TwiML

<Message> TwiML Verb

body(message, **kwargs)[source]

Create a <Body> element

Parameters:
  • message – Message Body
  • kwargs – additional attributes
Returns:

<Body> element

media(url, **kwargs)[source]

Create a <Media> element

Parameters:
  • url – Media URL
  • kwargs – additional attributes
Returns:

<Media> element

class twilio.twiml.messaging_response.MessagingResponse(**kwargs)[source]

Bases: twilio.twiml.TwiML

<Response> TwiML for Messages

message(body=None, to=None, from_=None, action=None, method=None, status_callback=None, **kwargs)[source]

Create a <Message> element

Parameters:
  • body – Message Body
  • to – Phone Number to send Message to
  • from – Phone Number to send Message from
  • action – Action URL
  • method – Action URL Method
  • status_callback – Status callback URL. Deprecated in favor of action.
  • kwargs – additional attributes
Returns:

<Message> element

redirect(url, method=None, **kwargs)[source]

Create a <Redirect> element

Parameters:
  • url – Redirect URL
  • method – Redirect URL method
  • kwargs – additional attributes
Returns:

<Redirect> element

class twilio.twiml.messaging_response.Redirect(url, **kwargs)[source]

Bases: twilio.twiml.TwiML

<Redirect> TwiML Verb

twilio.twiml.voice_response module

This code was generated by / _ _ _| _ _

(_)/(_)(_|/| |(/_ v1.0.0 / /

System Message: WARNING/2 (/twilio/repos/twilio-python/twilio/twiml/voice_response.py:docstring of twilio.twiml.voice_response, line 3); backlink

Inline substitution_reference start-string without end-string.
class twilio.twiml.voice_response.Autopilot(name, **kwargs)[source]

Bases: twilio.twiml.TwiML

<Autopilot> TwiML Noun

class twilio.twiml.voice_response.Client(identity=None, **kwargs)[source]

Bases: twilio.twiml.TwiML

<Client> TwiML Noun

identity(client_identity, **kwargs)[source]

Create a <Identity> element

Parameters:
  • client_identity – Identity of the client to dial
  • kwargs – additional attributes
Returns:

<Identity> element

parameter(name=None, value=None, **kwargs)[source]

Create a <Parameter> element

Parameters:
  • name – The name of the custom parameter
  • value – The value of the custom parameter
  • kwargs – additional attributes
Returns:

<Parameter> element

class twilio.twiml.voice_response.Conference(name, **kwargs)[source]

Bases: twilio.twiml.TwiML

<Conference> TwiML Noun

class twilio.twiml.voice_response.Connect(**kwargs)[source]

Bases: twilio.twiml.TwiML

<Connect> TwiML Verb

autopilot(name, **kwargs)[source]

Create a <Autopilot> element

Parameters:
  • name – Autopilot assistant sid or unique name
  • kwargs – additional attributes
Returns:

<Autopilot> element

room(name, participant_identity=None, **kwargs)[source]

Create a <Room> element

Parameters:
  • name – Room name
  • participant_identity – Participant identity when connecting to the Room
  • kwargs – additional attributes
Returns:

<Room> element

stream(name=None, connector_name=None, url=None, track=None, status_callback=None, status_callback_method=None, **kwargs)[source]

Create a <Stream> element

Parameters:
  • name – Friendly name given to the Stream
  • connector_name – Unique name for Stream Connector
  • url – URL of the remote service where the Stream is routed
  • track – Track to be streamed to remote service
  • status_callback – Status Callback URL
  • status_callback_method – Status Callback URL method
  • kwargs – additional attributes
Returns:

<Stream> element

virtual_agent(connector_name=None, language=None, sentiment_analysis=None, status_callback=None, **kwargs)[source]

Create a <VirtualAgent> element

Parameters:
  • connector_name – Defines the conversation profile Dialogflow needs to use
  • language – Language to be used by Dialogflow to transcribe speech
  • sentiment_analysis – Whether sentiment analysis needs to be enabled or not
  • status_callback – URL to post status callbacks from Twilio
  • kwargs – additional attributes
Returns:

<VirtualAgent> element

class twilio.twiml.voice_response.Dial(number=None, **kwargs)[source]

Bases: twilio.twiml.TwiML

<Dial> TwiML Verb

client(identity=None, url=None, method=None, status_callback_event=None, status_callback=None, status_callback_method=None, **kwargs)[source]

Create a <Client> element

Parameters:
  • identity – Client identity
  • url – Client URL
  • method – Client URL Method
  • status_callback_event – Events to trigger status callback
  • status_callback – Status Callback URL
  • status_callback_method – Status Callback URL Method
  • kwargs – additional attributes
Returns:

<Client> element

conference(name, muted=None, beep=None, start_conference_on_enter=None, end_conference_on_exit=None, wait_url=None, wait_method=None, max_participants=None, record=None, region=None, coach=None, trim=None, status_callback_event=None, status_callback=None, status_callback_method=None, recording_status_callback=None, recording_status_callback_method=None, recording_status_callback_event=None, event_callback_url=None, jitter_buffer_size=None, participant_label=None, **kwargs)[source]

Create a <Conference> element

Parameters:
  • name – Conference name
  • muted – Join the conference muted
  • beep – Play beep when joining
  • start_conference_on_enter – Start the conference on enter
  • end_conference_on_exit – End the conferenceon exit
  • wait_url – Wait URL
  • wait_method – Wait URL method
  • max_participants – Maximum number of participants
  • record – Record the conference
  • region – Conference region
  • coach – Call coach
  • trim – Trim the conference recording
  • status_callback_event – Events to call status callback URL
  • status_callback – Status callback URL
  • status_callback_method – Status callback URL method
  • recording_status_callback – Recording status callback URL
  • recording_status_callback_method – Recording status callback URL method
  • recording_status_callback_event – Recording status callback events
  • event_callback_url – Event callback URL
  • jitter_buffer_size – Size of jitter buffer for participant
  • participant_label – A label for participant
  • kwargs – additional attributes
Returns:

<Conference> element

number(phone_number, send_digits=None, url=None, method=None, status_callback_event=None, status_callback=None, status_callback_method=None, byoc=None, **kwargs)[source]

Create a <Number> element

Parameters:
  • phone_number – Phone Number to dial
  • send_digits – DTMF tones to play when the call is answered
  • url – TwiML URL
  • method – TwiML URL method
  • status_callback_event – Events to call status callback
  • status_callback – Status callback URL
  • status_callback_method – Status callback URL method
  • byoc – BYOC trunk SID (Beta)
  • kwargs – additional attributes
Returns:

<Number> element

queue(name, url=None, method=None, reservation_sid=None, post_work_activity_sid=None, **kwargs)[source]

Create a <Queue> element

Parameters:
  • name – Queue name
  • url – Action URL
  • method – Action URL method
  • reservation_sid – TaskRouter Reservation SID
  • post_work_activity_sid – TaskRouter Activity SID
  • kwargs – additional attributes
Returns:

<Queue> element

sim(sim_sid, **kwargs)[source]

Create a <Sim> element

Parameters:
  • sim_sid – SIM SID
  • kwargs – additional attributes
Returns:

<Sim> element

sip(sip_url, username=None, password=None, url=None, method=None, status_callback_event=None, status_callback=None, status_callback_method=None, **kwargs)[source]

Create a <Sip> element

Parameters:
  • sip_url – SIP URL
  • username – SIP Username
  • password – SIP Password
  • url – Action URL
  • method – Action URL method
  • status_callback_event – Status callback events
  • status_callback – Status callback URL
  • status_callback_method – Status callback URL method
  • kwargs – additional attributes
Returns:

<Sip> element

class twilio.twiml.voice_response.Echo(**kwargs)[source]

Bases: twilio.twiml.TwiML

<Echo> TwiML Verb

class twilio.twiml.voice_response.Enqueue(name=None, **kwargs)[source]

Bases: twilio.twiml.TwiML

<Enqueue> TwiML Noun

task(body, priority=None, timeout=None, **kwargs)[source]

Create a <Task> element

Parameters:
  • body – TaskRouter task attributes
  • priority – Task priority
  • timeout – Timeout associated with task
  • kwargs – additional attributes
Returns:

<Task> element

class twilio.twiml.voice_response.Gather(**kwargs)[source]

Bases: twilio.twiml.TwiML

<Gather> TwiML Verb

pause(length=None, **kwargs)[source]

Create a <Pause> element

Parameters:
  • length – Length in seconds to pause
  • kwargs – additional attributes
Returns:

<Pause> element

play(url=None, loop=None, digits=None, **kwargs)[source]

Create a <Play> element

Parameters:
  • url – Media URL
  • loop – Times to loop media
  • digits – Play DTMF tones for digits
  • kwargs – additional attributes
Returns:

<Play> element

say(message=None, voice=None, loop=None, language=None, **kwargs)[source]

Create a <Say> element

Parameters:
  • message – Message to say
  • voice – Voice to use
  • loop – Times to loop message
  • language – Message langauge
  • kwargs – additional attributes
Returns:

<Say> element

class twilio.twiml.voice_response.Hangup(**kwargs)[source]

Bases: twilio.twiml.TwiML

<Hangup> TwiML Verb

class twilio.twiml.voice_response.Identity(client_identity, **kwargs)[source]

Bases: twilio.twiml.TwiML

<Identity> TwiML Noun

class twilio.twiml.voice_response.Leave(**kwargs)[source]

Bases: twilio.twiml.TwiML

<Leave> TwiML Verb

class twilio.twiml.voice_response.Number(phone_number, **kwargs)[source]

Bases: twilio.twiml.TwiML

<Number> TwiML Noun

class twilio.twiml.voice_response.Parameter(**kwargs)[source]

Bases: twilio.twiml.TwiML

<Parameter> TwiML Noun

class twilio.twiml.voice_response.Pause(**kwargs)[source]

Bases: twilio.twiml.TwiML

<Pause> TwiML Verb

class twilio.twiml.voice_response.Pay(**kwargs)[source]

Bases: twilio.twiml.TwiML

<Pay> Twiml Verb

parameter(name=None, value=None, **kwargs)[source]

Create a <Parameter> element

Parameters:
  • name – The name of the custom parameter
  • value – The value of the custom parameter
  • kwargs – additional attributes
Returns:

<Parameter> element

prompt(for_=None, error_type=None, card_type=None, attempt=None, **kwargs)[source]

Create a <Prompt> element

Parameters:
  • for – Name of the payment source data element
  • error_type – Type of error
  • card_type – Type of the credit card
  • attempt – Current attempt count
  • kwargs – additional attributes
Returns:

<Prompt> element

class twilio.twiml.voice_response.Play(url=None, **kwargs)[source]

Bases: twilio.twiml.TwiML

<Play> TwiML Verb

class twilio.twiml.voice_response.Prompt(**kwargs)[source]

Bases: twilio.twiml.TwiML

<Prompt> Twiml Verb

pause(length=None, **kwargs)[source]

Create a <Pause> element

Parameters:
  • length – Length in seconds to pause
  • kwargs – additional attributes
Returns:

<Pause> element

play(url=None, loop=None, digits=None, **kwargs)[source]

Create a <Play> element

Parameters:
  • url – Media URL
  • loop – Times to loop media
  • digits – Play DTMF tones for digits
  • kwargs – additional attributes
Returns:

<Play> element

say(message=None, voice=None, loop=None, language=None, **kwargs)[source]

Create a <Say> element

Parameters:
  • message – Message to say
  • voice – Voice to use
  • loop – Times to loop message
  • language – Message langauge
  • kwargs – additional attributes
Returns:

<Say> element

class twilio.twiml.voice_response.Queue(name, **kwargs)[source]

Bases: twilio.twiml.TwiML

<Queue> TwiML Noun

class twilio.twiml.voice_response.Record(**kwargs)[source]

Bases: twilio.twiml.TwiML

<Record> TwiML Verb

class twilio.twiml.voice_response.Redirect(url, **kwargs)[source]

Bases: twilio.twiml.TwiML

<Redirect> TwiML Verb

class twilio.twiml.voice_response.Refer(**kwargs)[source]

Bases: twilio.twiml.TwiML

<Refer> TwiML Verb

refer_sip(sip_url, **kwargs)[source]

Create a <Sip> element

Parameters:
  • sip_url – SIP URL
  • kwargs – additional attributes
Returns:

<Sip> element

sip(sip_url, **kwargs)[source]

Create a <Sip> element

Parameters:
  • sip_url – SIP URL
  • kwargs – additional attributes
Returns:

<Sip> element

class twilio.twiml.voice_response.ReferSip(sip_url, **kwargs)[source]

Bases: twilio.twiml.TwiML

<Sip> TwiML Noun used in <Refer>

class twilio.twiml.voice_response.Reject(**kwargs)[source]

Bases: twilio.twiml.TwiML

<Reject> TwiML Verb

class twilio.twiml.voice_response.Room(name, **kwargs)[source]

Bases: twilio.twiml.TwiML

<Room> TwiML Noun

class twilio.twiml.voice_response.Say(message=None, **kwargs)[source]

Bases: twilio.twiml.TwiML

<Say> TwiML Verb

break_(strength=None, time=None, **kwargs)[source]

Create a <Break> element

Parameters:
  • strength – Set a pause based on strength
  • time – Set a pause to a specific length of time in seconds or milliseconds, available values: [number]s, [number]ms
  • kwargs – additional attributes
Returns:

<Break> element

emphasis(words, level=None, **kwargs)[source]

Create a <Emphasis> element

Parameters:
  • words – Words to emphasize
  • level – Specify the degree of emphasis
  • kwargs – additional attributes
Returns:

<Emphasis> element

lang(words, xml_lang=None, **kwargs)[source]

Create a <Lang> element

Parameters:
  • words – Words to speak
  • xml:lang – Specify the language
  • kwargs – additional attributes
Returns:

<Lang> element

p(words, **kwargs)[source]

Create a <P> element

Parameters:
  • words – Words to speak
  • kwargs – additional attributes
Returns:

<P> element

phoneme(words, alphabet=None, ph=None, **kwargs)[source]

Create a <Phoneme> element

Parameters:
  • words – Words to speak
  • alphabet – Specify the phonetic alphabet
  • ph – Specifiy the phonetic symbols for pronunciation
  • kwargs – additional attributes
Returns:

<Phoneme> element

prosody(words, volume=None, rate=None, pitch=None, **kwargs)[source]

Create a <Prosody> element

Parameters:
  • words – Words to speak
  • volume – Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, +ndB, -ndB
  • rate – Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n%
  • pitch – Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n%
  • kwargs – additional attributes
Returns:

<Prosody> element

s(words, **kwargs)[source]

Create a <S> element

Parameters:
  • words – Words to speak
  • kwargs – additional attributes
Returns:

<S> element

say_as(words, interpret_as=None, role=None, **kwargs)[source]

Create a <Say-As> element

Parameters:
  • words – Words to be interpreted
  • interpret-as – Specify the type of words are spoken
  • role – Specify the format of the date when interpret-as is set to date
  • kwargs – additional attributes
Returns:

<Say-As> element

ssml_break(strength=None, time=None, **kwargs)[source]

Create a <Break> element

Parameters:
  • strength – Set a pause based on strength
  • time – Set a pause to a specific length of time in seconds or milliseconds, available values: [number]s, [number]ms
  • kwargs – additional attributes
Returns:

<Break> element

ssml_emphasis(words, level=None, **kwargs)[source]

Create a <Emphasis> element

Parameters:
  • words – Words to emphasize
  • level – Specify the degree of emphasis
  • kwargs – additional attributes
Returns:

<Emphasis> element

ssml_lang(words, xml_lang=None, **kwargs)[source]

Create a <Lang> element

Parameters:
  • words – Words to speak
  • xml:lang – Specify the language
  • kwargs – additional attributes
Returns:

<Lang> element

ssml_p(words, **kwargs)[source]

Create a <P> element

Parameters:
  • words – Words to speak
  • kwargs – additional attributes
Returns:

<P> element

ssml_phoneme(words, alphabet=None, ph=None, **kwargs)[source]

Create a <Phoneme> element

Parameters:
  • words – Words to speak
  • alphabet – Specify the phonetic alphabet
  • ph – Specifiy the phonetic symbols for pronunciation
  • kwargs – additional attributes
Returns:

<Phoneme> element

ssml_prosody(words, volume=None, rate=None, pitch=None, **kwargs)[source]

Create a <Prosody> element

Parameters:
  • words – Words to speak
  • volume – Specify the volume, available values: default, silent, x-soft, soft, medium, loud, x-loud, +ndB, -ndB
  • rate – Specify the rate, available values: x-slow, slow, medium, fast, x-fast, n%
  • pitch – Specify the pitch, available values: default, x-low, low, medium, high, x-high, +n%, -n%
  • kwargs – additional attributes
Returns:

<Prosody> element

ssml_s(words, **kwargs)[source]

Create a <S> element

Parameters:
  • words – Words to speak
  • kwargs – additional attributes
Returns:

<S> element

ssml_say_as(words, interpret_as=None, role=None, **kwargs)[source]

Create a <Say-As> element

Parameters:
  • words – Words to be interpreted
  • interpret-as – Specify the type of words are spoken
  • role – Specify the format of the date when interpret-as is set to date
  • kwargs – additional attributes
Returns:

<Say-As> element

ssml_sub(words, alias=None, **kwargs)[source]

Create a <Sub> element

Parameters:
  • words – Words to be substituted
  • alias – Substitute a different word (or pronunciation) for selected text such as an acronym or abbreviation
  • kwargs – additional attributes
Returns:

<Sub> element

ssml_w(words, role=None, **kwargs)[source]

Create a <W> element

Parameters:
  • words – Words to speak
  • role – Customize the pronunciation of words by specifying the word’s part of speech or alternate meaning
  • kwargs – additional attributes
Returns:

<W> element

sub(words, alias=None, **kwargs)[source]

Create a <Sub> element

Parameters:
  • words – Words to be substituted
  • alias – Substitute a different word (or pronunciation) for selected text such as an acronym or abbreviation
  • kwargs – additional attributes
Returns:

<Sub> element

w(words, role=None, **kwargs)[source]

Create a <W> element

Parameters:
  • words – Words to speak
  • role – Customize the pronunciation of words by specifying the word’s part of speech or alternate meaning
  • kwargs – additional attributes
Returns:

<W> element

class twilio.twiml.voice_response.Sim(sim_sid, **kwargs)[source]

Bases: twilio.twiml.TwiML

<Sim> TwiML Noun

class twilio.twiml.voice_response.Sip(sip_url, **kwargs)[source]

Bases: twilio.twiml.TwiML

<Sip> TwiML Noun

class twilio.twiml.voice_response.Siprec(**kwargs)[source]

Bases: twilio.twiml.TwiML

<Siprec> TwiML Noun

parameter(name=None, value=None, **kwargs)[source]

Create a <Parameter> element

Parameters:
  • name – The name of the custom parameter
  • value – The value of the custom parameter
  • kwargs – additional attributes
Returns:

<Parameter> element

class twilio.twiml.voice_response.Sms(message, **kwargs)[source]

Bases: twilio.twiml.TwiML

<Sms> TwiML Noun

class twilio.twiml.voice_response.SsmlBreak(**kwargs)[source]

Bases: twilio.twiml.TwiML

Adding a Pause in <Say>

class twilio.twiml.voice_response.SsmlEmphasis(words, **kwargs)[source]

Bases: twilio.twiml.TwiML

Emphasizing Words in <Say>

class twilio.twiml.voice_response.SsmlLang(words, **kwargs)[source]

Bases: twilio.twiml.TwiML

Specifying Another Language for Specific Words in <Say>

class twilio.twiml.voice_response.SsmlP(words, **kwargs)[source]

Bases: twilio.twiml.TwiML

Adding a Pause Between Paragraphs in <Say>

class twilio.twiml.voice_response.SsmlPhoneme(words, **kwargs)[source]

Bases: twilio.twiml.TwiML

Using Phonetic Pronunciation in <Say>

class twilio.twiml.voice_response.SsmlProsody(words, **kwargs)[source]

Bases: twilio.twiml.TwiML

Controling Volume, Speaking Rate, and Pitch in <Say>

class twilio.twiml.voice_response.SsmlS(words, **kwargs)[source]

Bases: twilio.twiml.TwiML

Adding A Pause Between Sentences in <Say>

class twilio.twiml.voice_response.SsmlSayAs(words, **kwargs)[source]

Bases: twilio.twiml.TwiML

Controlling How Special Types of Words Are Spoken in <Say>

class twilio.twiml.voice_response.SsmlSub(words, **kwargs)[source]

Bases: twilio.twiml.TwiML

Pronouncing Acronyms and Abbreviations in <Say>

class twilio.twiml.voice_response.SsmlW(words, **kwargs)[source]

Bases: twilio.twiml.TwiML

Improving Pronunciation by Specifying Parts of Speech in <Say>

class twilio.twiml.voice_response.Start(**kwargs)[source]

Bases: twilio.twiml.TwiML

<Start> TwiML Verb

siprec(name=None, connector_name=None, track=None, **kwargs)[source]

Create a <Siprec> element

Parameters:
  • name – Friendly name given to SIPREC
  • connector_name – Unique name for Connector
  • track – Track to be streamed to remote service
  • kwargs – additional attributes
Returns:

<Siprec> element

stream(name=None, connector_name=None, url=None, track=None, status_callback=None, status_callback_method=None, **kwargs)[source]

Create a <Stream> element

Parameters:
  • name – Friendly name given to the Stream
  • connector_name – Unique name for Stream Connector
  • url – URL of the remote service where the Stream is routed
  • track – Track to be streamed to remote service
  • status_callback – Status Callback URL
  • status_callback_method – Status Callback URL method
  • kwargs – additional attributes
Returns:

<Stream> element

class twilio.twiml.voice_response.Stop(**kwargs)[source]

Bases: twilio.twiml.TwiML

<Stop> TwiML Verb

siprec(name=None, connector_name=None, track=None, **kwargs)[source]

Create a <Siprec> element

Parameters:
  • name – Friendly name given to SIPREC
  • connector_name – Unique name for Connector
  • track – Track to be streamed to remote service
  • kwargs – additional attributes
Returns:

<Siprec> element

stream(name=None, connector_name=None, url=None, track=None, status_callback=None, status_callback_method=None, **kwargs)[source]

Create a <Stream> element

Parameters:
  • name – Friendly name given to the Stream
  • connector_name – Unique name for Stream Connector
  • url – URL of the remote service where the Stream is routed
  • track – Track to be streamed to remote service
  • status_callback – Status Callback URL
  • status_callback_method – Status Callback URL method
  • kwargs – additional attributes
Returns:

<Stream> element

class twilio.twiml.voice_response.Stream(**kwargs)[source]

Bases: twilio.twiml.TwiML

<Stream> TwiML Noun

parameter(name=None, value=None, **kwargs)[source]

Create a <Parameter> element

Parameters:
  • name – The name of the custom parameter
  • value – The value of the custom parameter
  • kwargs – additional attributes
Returns:

<Parameter> element

class twilio.twiml.voice_response.Task(body, **kwargs)[source]

Bases: twilio.twiml.TwiML

<Task> TwiML Noun

class twilio.twiml.voice_response.VirtualAgent(**kwargs)[source]

Bases: twilio.twiml.TwiML

<VirtualAgent> TwiML Noun

class twilio.twiml.voice_response.VoiceResponse(**kwargs)[source]

Bases: twilio.twiml.TwiML

<Response> TwiML for Voice

connect(action=None, method=None, **kwargs)[source]

Create a <Connect> element

Parameters:
  • action – Action URL
  • method – Action URL method
  • kwargs – additional attributes
Returns:

<Connect> element

dial(number=None, action=None, method=None, timeout=None, hangup_on_star=None, time_limit=None, caller_id=None, record=None, trim=None, recording_status_callback=None, recording_status_callback_method=None, recording_status_callback_event=None, answer_on_bridge=None, ring_tone=None, recording_track=None, sequential=None, refer_url=None, refer_method=None, **kwargs)[source]

Create a <Dial> element

Parameters:
  • number – Phone number to dial
  • action – Action URL
  • method – Action URL method
  • timeout – Time to wait for answer
  • hangup_on_star – Hangup call on star press
  • time_limit – Max time length
  • caller_id – Caller ID to display
  • record – Record the call
  • trim – Trim the recording
  • recording_status_callback – Recording status callback URL
  • recording_status_callback_method – Recording status callback URL method
  • recording_status_callback_event – Recording status callback events
  • answer_on_bridge – Preserve the ringing behavior of the inbound call until the Dialed call picks up
  • ring_tone – Ringtone allows you to override the ringback tone that Twilio will play back to the caller while executing the Dial
  • recording_track – To indicate which audio track should be recorded
  • sequential – Used to determine if child TwiML nouns should be dialed in order, one after the other (sequential) or dial all at once (parallel). Default is false, parallel
  • refer_url – Webhook that will receive future SIP REFER requests
  • refer_method – The HTTP method to use for the refer Webhook
  • kwargs – additional attributes
Returns:

<Dial> element

echo(**kwargs)[source]

Create a <Echo> element

Parameters:kwargs – additional attributes
Returns:<Echo> element
enqueue(name=None, action=None, method=None, wait_url=None, wait_url_method=None, workflow_sid=None, **kwargs)[source]

Create a <Enqueue> element

Parameters:
  • name – Friendly name
  • action – Action URL
  • method – Action URL method
  • wait_url – Wait URL
  • wait_url_method – Wait URL method
  • workflow_sid – TaskRouter Workflow SID
  • kwargs – additional attributes
Returns:

<Enqueue> element

gather(input=None, action=None, method=None, timeout=None, speech_timeout=None, max_speech_time=None, profanity_filter=None, finish_on_key=None, num_digits=None, partial_result_callback=None, partial_result_callback_method=None, language=None, hints=None, barge_in=None, debug=None, action_on_empty_result=None, speech_model=None, enhanced=None, **kwargs)[source]

Create a <Gather> element

Parameters:
  • input – Input type Twilio should accept
  • action – Action URL
  • method – Action URL method
  • timeout – Time to wait to gather input
  • speech_timeout – Time to wait to gather speech input and it should be either auto or a positive integer.
  • max_speech_time – Max allowed time for speech input
  • profanity_filter – Profanity Filter on speech
  • finish_on_key – Finish gather on key
  • num_digits – Number of digits to collect
  • partial_result_callback – Partial result callback URL
  • partial_result_callback_method – Partial result callback URL method
  • language – Language to use
  • hints – Speech recognition hints
  • barge_in – Stop playing media upon speech
  • debug – Allow debug for gather
  • action_on_empty_result – Force webhook to the action URL event if there is no input
  • speech_model – Specify the model that is best suited for your use case
  • enhanced – Use enhanced speech model
  • kwargs – additional attributes
Returns:

<Gather> element

hangup(**kwargs)[source]

Create a <Hangup> element

Parameters:kwargs – additional attributes
Returns:<Hangup> element
leave(**kwargs)[source]

Create a <Leave> element

Parameters:kwargs – additional attributes
Returns:<Leave> element
pause(length=None, **kwargs)[source]

Create a <Pause> element

Parameters:
  • length – Length in seconds to pause
  • kwargs – additional attributes
Returns:

<Pause> element

pay(input=None, action=None, bank_account_type=None, status_callback=None, status_callback_method=None, timeout=None, max_attempts=None, security_code=None, postal_code=None, min_postal_code_length=None, payment_connector=None, payment_method=None, token_type=None, charge_amount=None, currency=None, description=None, valid_card_types=None, language=None, **kwargs)[source]

Create a <Pay> element

Parameters:
  • input – Input type Twilio should accept
  • action – Action URL
  • bank_account_type – Bank account type for ach transactions. If set, payment method attribute must be provided and value should be set to ach-debit. defaults to consumer-checking
  • status_callback – Status callback URL
  • status_callback_method – Status callback method
  • timeout – Time to wait to gather input
  • max_attempts – Maximum number of allowed retries when gathering input
  • security_code – Prompt for security code
  • postal_code – Prompt for postal code and it should be true/false or default postal code
  • min_postal_code_length – Prompt for minimum postal code length
  • payment_connector – Unique name for payment connector
  • payment_method – Payment method to be used. defaults to credit-card
  • token_type – Type of token
  • charge_amount – Amount to process. If value is greater than 0 then make the payment else create a payment token
  • currency – Currency of the amount attribute
  • description – Details regarding the payment
  • valid_card_types – Comma separated accepted card types
  • language – Language to use
  • kwargs – additional attributes
Returns:

<Pay> element

play(url=None, loop=None, digits=None, **kwargs)[source]

Create a <Play> element

Parameters:
  • url – Media URL
  • loop – Times to loop media
  • digits – Play DTMF tones for digits
  • kwargs – additional attributes
Returns:

<Play> element

prompt(for_=None, error_type=None, card_type=None, attempt=None, **kwargs)[source]

Create a <Prompt> element

Parameters:
  • for – Name of the payment source data element
  • error_type – Type of error
  • card_type – Type of the credit card
  • attempt – Current attempt count
  • kwargs – additional attributes
Returns:

<Prompt> element

queue(name, url=None, method=None, reservation_sid=None, post_work_activity_sid=None, **kwargs)[source]

Create a <Queue> element

Parameters:
  • name – Queue name
  • url – Action URL
  • method – Action URL method
  • reservation_sid – TaskRouter Reservation SID
  • post_work_activity_sid – TaskRouter Activity SID
  • kwargs – additional attributes
Returns:

<Queue> element

record(action=None, method=None, timeout=None, finish_on_key=None, max_length=None, play_beep=None, trim=None, recording_status_callback=None, recording_status_callback_method=None, recording_status_callback_event=None, transcribe=None, transcribe_callback=None, **kwargs)[source]

Create a <Record> element

Parameters:
  • action – Action URL
  • method – Action URL method
  • timeout – Timeout to begin recording
  • finish_on_key – Finish recording on key
  • max_length – Max time to record in seconds
  • play_beep – Play beep
  • trim – Trim the recording
  • recording_status_callback – Status callback URL
  • recording_status_callback_method – Status callback URL method
  • recording_status_callback_event – Recording status callback events
  • transcribe – Transcribe the recording
  • transcribe_callback – Transcribe callback URL
  • kwargs – additional attributes
Returns:

<Record> element

redirect(url, method=None, **kwargs)[source]

Create a <Redirect> element

Parameters:
  • url – Redirect URL
  • method – Redirect URL method
  • kwargs – additional attributes
Returns:

<Redirect> element

refer(action=None, method=None, **kwargs)[source]

Create a <Refer> element

Parameters:
  • action – Action URL
  • method – Action URL method
  • kwargs – additional attributes
Returns:

<Refer> element

reject(reason=None, **kwargs)[source]

Create a <Reject> element

Parameters:
  • reason – Rejection reason
  • kwargs – additional attributes
Returns:

<Reject> element

say(message=None, voice=None, loop=None, language=None, **kwargs)[source]

Create a <Say> element

Parameters:
  • message – Message to say
  • voice – Voice to use
  • loop – Times to loop message
  • language – Message langauge
  • kwargs – additional attributes
Returns:

<Say> element

sms(message, to=None, from_=None, action=None, method=None, status_callback=None, **kwargs)[source]

Create a <Sms> element

Parameters:
  • message – Message body
  • to – Number to send message to
  • from – Number to send message from
  • action – Action URL
  • method – Action URL method
  • status_callback – Status callback URL
  • kwargs – additional attributes
Returns:

<Sms> element

start(action=None, method=None, **kwargs)[source]

Create a <Start> element

Parameters:
  • action – Action URL
  • method – Action URL method
  • kwargs – additional attributes
Returns:

<Start> element

stop(**kwargs)[source]

Create a <Stop> element

Parameters:kwargs – additional attributes
Returns:<Stop> element

Module contents

class twilio.twiml.GenericNode(name, value, **kwargs)[source]

Bases: twilio.twiml.TwiML

class twilio.twiml.TwiML(**kwargs)[source]

Bases: object

MAP = {'break_': 'break', 'for_': 'for', 'from_': 'from', 'interpret_as': 'interpret-as', 'xml_lang': 'xml:lang'}
add_child(name, value=None, **kwargs)[source]
append(verb)[source]

Add a TwiML doc

Parameters:verb – TwiML Document
Returns:self
nest(verb)[source]

Add a TwiML doc. Unlike append(), this returns the created verb.

Parameters:verb – TwiML Document
Returns:the TwiML verb
to_xml(xml_declaration=True)[source]

Return the contents of this verb as an XML string

Parameters:xml_declaration (bool) – Include the XML declaration. Defaults to True
xml()[source]
exception twilio.twiml.TwiMLException[source]

Bases: Exception

twilio.twiml.format_language(language)[source]

Attempt to format language parameter as ‘ww-WW’.

Parameters:language (string) – language parameter
twilio.twiml.lower_camel(string)[source]