Class: Reservation

Reservation

A Reservation correlates a Task and a Worker


Properties:
Name Type Description
accountSid string

The sid of the Twilio account

dateCreated Date

The date the Reservation was created

dateUpdated Date

The date the Reservation was last updated

sid string

The sid of the Reservation

status string

The current state of the Reservation. Options: ['pending', 'accepted', 'rejected', 'timeout', 'canceled', 'rescinded', 'wrapping', 'completed'].

task Task

The Task tied to the Reservation

timeout int

The number of seconds until the Task times out

workerSid string

The sid of the Worker

workspaceSid string

The sid of the Workspace owning this Reservation

Fires:

Methods


accept()

Accept the Reservation

Returns:
  • Rejected if unable to issue Accept instruction on the Reservation
Type
Promise.<this>

call(from, url [, options])

Issue a Call to a Worker

Parameters:
Name Type Argument Description
from string

The caller id for the call to a Worker

url string

A valid TwiML URI that is executed on the answering Worker's leg

options Reservation.CallOptions <optional>
Returns:
  • Rejected if unable to issue Call instruction on the Reservation
Type
Promise.<this>

complete()

Complete the Reservation

Returns:
  • Rejected if unable to issue Complete instruction on the Reservation
Type
Promise.<this>

conference( [options])

Conference the active Call tied to this Reservation to the Worker

Parameters:
Name Type Argument Description
options Reservation.ConferenceOptions <optional>
Returns:
  • Rejected if unable to issue Conference instruction on the link Reservation
Type
Promise.<this>

dequeue( [options])

Dequeue the Reservation to the Worker. This will perform telephony to dequeue a Task that was enqueued using the Enqueue TwiML verb. A contact_uri must exist in the Worker's attributes for this call to go through.

Parameters:
Name Type Argument Description
options Reservation.DequeueOptions <optional>
Returns:
  • Rejected if unable to issue Dequeue instruction on the Reservation
Type
Promise.<this>

redirect(callSid, url [, options])

Redirect the active Call tied to this Reservation

Parameters:
Name Type Argument Description
callSid string

The sid of the Call to redirect

url string

A valid TwiML URI that is executed on the Caller's leg upon redirecting

options Reservation.RedirectOptions <optional>
Returns:
  • Rejected if unable to issue Redirect instruction on the Reservation
Type
Promise.<this>

reject( [options])

Reject the Reservation

Parameters:
Name Type Argument Description
options Reservation.RejectOptions <optional>
Returns:
  • Rejected if unable to issue Reject instruction on the Reservation
Type
Promise.<this>

updateParticipant( [options])

Update the Worker's leg in the Conference associated to this Reservation

Parameters:
Name Type Argument Description
options Reservation.ParticipantOptions <optional>
Returns:
  • Rejected if unable to update the Worker's leg in the Conference tied to the Reservation
Type
Promise.<this>

wrap()

Wrap the Reservation

Returns:
  • Rejected if unable to issue Wrap instruction on the Reservation
Type
Promise.<this>

Type Definitions


CallOptions

Type:
  • Object
Properties:
Name Type Argument Default Description
accept boolean <optional>
false

Represents whether the Task should be accepted before initiating the call

record string <optional>
'do-not-record'

To record the call or not

statusCallbackUrl string <optional>
null

A valid status status callback url

to string <optional>
null

The number or endpoint that should be called. If not provided, the contact_uri defined in the Worker attributes will be used

timeout number <optional>
60

The integer number of seconds Twilio should allow the phone associated to "contact_uri" to ring


ConferenceOptions

Type:
  • Object
Properties:
Name Type Argument Default Description
to string <optional>
null

The contact uri of the Worker; can be a phone number or a client ID. Required, if no contact_uri on the Worker's attributes.

from string <optional>
null

The caller id for the call to the Worker. Must be a verified Twilio number.

timeout int <optional>
60

The integer number of seconds that Twilio should allow the call to ring before assuming there is no answer.

statusCallback string <optional>
null

The URL endpoint to receive call status events of the Worker leg.

statusCallbackMethod string <optional>
'POST'

The HTTP method for the Status Callback URL.

statusCallbackEvent string <optional>
'completed'

A comma separated list of events to subscribe to. The possible list of events are: ['initiated', 'ringing', 'answered', 'completed'].

record string <optional>
'do-not-record'

Whether to record the Worker leg of the Conference.

muted boolean <optional>
false

Whether the Worker leg of the Conference is muted.

beep string | boolean <optional>
true

Whether the Worker leg should be when entering the Conference. The options for beep are: [true, false, 'onEnter', 'onExit'].

startConferenceOnEnter boolean <optional>
true

Whether the Conference should start when the Worker leg enters.

endConferenceOnExit boolean <optional>
false

Whether the Conference should end when the Worker leg exits.

endConferenceOnCustomerExit boolean <optional>
false

Whether the Conference should end when the customer leg exits.

beepOnCustomerEntrance boolean <optional>
true

Whether the Conference should beep when the customer leg enters.

waitUrl string <optional>
default Twilio hold music

The URL endpoint to play when waiting for the Conference to begin.

waitMethod string <optional>
'POST'

The HTTP method for the Wait URL.

earlyMedia boolean <optional>
true

Whether Twilio should feed early media to be played directly into a Conference.

maxParticipants int <optional>
10

The number of max participants allowed in a Conference.

conferenceStatusCallback string <optional>
null

The URL endpoint to receive Conference status events.

conferenceStatusCallbackMethod string <optional>
'POST'

The HTTP method for the Conference Status Callback URL.

conferenceStatusCallbackEvent string <optional>
'start,end'

A comma separated list of Conference events to subscribe to. The possible list of events are: ['start', 'end', 'join', 'leave', 'mute', 'hold', 'speaker'].

conferenceRecord string | boolean <optional>
false

Whether the entire Conference should be recorded. The possible options for conferenceRecord are: [true, false, 'record-from-start', 'do-not-record'].

conferenceTrim string <optional>
'trim-silence'

Whether to trim the Conference recording. The options for conferenceTrim are: ['trim-silence', 'do-not-trim'].

recordingChannels string <optional>
'mono'

Which channel of the Conference to record. The options are: ['mono', 'dual'].

recordingStatusCallback string <optional>
null

The URL endpoint to receive recording status events.

recordingStatusCallbackMethod string <optional>
'POST'

The HTTP method for the Recording Status Callback URL.

conferenceRecordingStatusCallback string <optional>
null

The URl endpoint to receive Conference events.

conferenceRecordingStatusCallbackMethod string <optional>
'POST'

The HTTP method of the Conference Recording Status Callback.

region string <optional>
null

The specific region. The options for region are: ['us1', 'ie1', 'sg1', 'br1', 'au1', 'jp1'].

sipAuthUsername string <optional>
null

The SIP auth username to use.

sipAuthPassword string <optional>
null

The SIP auth password to use.


DequeueOptions

Type:
  • Object
Properties:
Name Type Argument Default Description
from string <optional>
null

The caller id for the call to the Worker. Must be a verified Twilio number.

to string <optional>
null

The contact uri of the Worker; can be a phone number or a client ID. Required, if no contact_uri on the Worker's attributes.

postWorkActivitySid string <optional>
null

The activitySid to update the Worker to after dequeuing the Reservation.

record string <optional>
'do-not-record'

Defines which legs of the call should be recorded.

timeout int <optional>
60

The integer number of seconds that Twilio should allow the call to ring before assuming there is no answer.

statusCallbackUrl string <optional>
null

A URL that Twilio will send asynchronous webhook this._request. to on a completed call event.

statusCallbackEvents string <optional>
null

A comma separated string of the events to subscribe to


ParticipantOptions

Type:
  • Object
Properties:
Name Type Argument Default Description
endConferenceOnExit boolean <optional>
null

Whether the Conference should end when this Worker participant leaves the Conference

mute boolean <optional>
null

Mute or unmute this Worker participant

beepOnExit boolean <optional>
null

Whether there should be a beep sound when this Worker participant leaves the Conference


RedirectOptions

Type:
  • Object
Properties:
Name Type Argument Default Description
accept boolean <optional>
false

Represents whether the Task should be accepted before initiating the call


RejectOptions

Type:
  • Object
Properties:
Name Type Description
activitySid string

The sid of the Activity to update the worker to upon rejecting the Reservation

Events


accepted

Fired when a Reservation has been accepted for this Worker

Parameters:
Name Type Description
reservation Reservation

The accepted Reservation


canceled

Fired when a Reservation has been canceled for this Worker

Parameters:
Name Type Description
reservation Reservation

The canceled Reservation


completed

Fired when an accepted Reservation has been completed for this Worker

Parameters:
Name Type Description
reservation Reservation

The completed Reservation


rejected

Fired when a Reservation has been rejected for this Worker

Parameters:
Name Type Description
reservation Reservation

The rejected Reservation


rescinded

Fired when a Reservation has been rescinded for the Worker

Parameters:
Name Type Description
reservation Reservation

The rescinded Reservation


timeout

Fired when a Reservation has been timed out for this Worker

Parameters:
Name Type Description
reservation Reservation

The timed out Reservation


wrapup

Fired when a Reservation has been wrapped up for the Worker

Parameters:
Name Type Description
reservation Reservation

The wrapped up Reservation