call inbound serviceΒΆ

class UASCallChannel
call_inbound_service(call_to, call_from='', seconds_timeout=120, codecs=None)

Make a call to an inbound service name.

Required argument:
  • call_to

    the name of the inbound service, as entered on your inbound services page.

Optional arguments:
  • call_from

    the origin of this call.

  • seconds_timeout

    time allocated to make the call. Default is 120. None means no timeout.

  • codecs

    list of codecs to use on this call. Default is None (use the default).

This is the function used to place an outbound call to one of your existing inbound services. call_to must be a valid inbound service name; for example MyVoicemailRecorder.

An originating address call_from may be supplied. Setting this parameter to an empty string will result in a default value being used.

If seconds_timeout is not None, a timeout will apply for making the call. The call is abandoned if the timeout is reached and the call has not been made. The default is 120 seconds.

codecs is an optional parameter to specify a semi-colon delimited list (in priority order) of codecs to offer for the call; for example, g711a;g711u.

This function will block until the call has been answered, the timeout has been reached, or the call state has returned to IDLE.

This function should be called when the call state is IDLE; otherwise, it will raise an Error exception.

This function will return the current call state.

Usage example:

state = channel.call_inbound_service('MyVoicemailRecorder', call_from='bob@1234')
if state != channel.State.ANSWERED:
    # check whether the call was rejected due to BUSY
    cause = channel.cause()
    if cause == channel.Cause.BUSY:
        # do something here for busy calls
        pass
else:
    # the call has been answered, carry on
    pass