Method: Vonage::Voice#create

Defined in:
lib/vonage/voice.rb

#create(params) ⇒ Response

Create an outbound Call.

Examples:

response = client.voice.create({
  to: [{type: 'phone', number: '14843331234'}],
  from: {type: 'phone', number: '14843335555'},
  answer_url: ['https://example.com/answer']
})

Parameters:

  • params (Hash)

Options Hash (params):

  • :to (required, Array<Hash>)

    Connect to a Phone (PSTN) number, SIP Endpoint, Websocket, or VBC extension. The to Hash can contain a number of different properties depending on the type. See the API reference for specific details.

  • :from (Hash)

    Connect to a Phone (PSTN) number. Should not be set if :random_from_number is true If not set, then :random_from_number will automatically be set to true

  • :random_from_number (Boolean)

    Set to true to use random phone number as from. The number will be selected from the list of the numbers assigned to the current application. random_from_number: true cannot be used together with :from.

  • :ncco (Array<String>)

    The Vonage Call Control Object to use for this call. Required unless :answer_url is provided.

  • :answer_url (Array<String>)

    The webhook endpoint where you provide the Vonage Call Control Object that governs this call. Required unless :ncco is provided.

  • :answer_method (String)

    The HTTP method used to send event information to answer_url.

  • :event_url (required, Array<String>)

    The webhook endpoint where call progress events are sent to.

  • :event_method (String)

    The HTTP method used to send event information to event_url.

  • :machine_detection (String)

    Configure the behavior when Vonage detects that the call is answered by voicemail.

  • :advanced_machine_detection (Hash)

    Configure the behavior of Vonage's advanced machine detection. Overrides machine_detection if both are set. Hash with three possible properties:

    • :behavior [String]: Must be one of continue or hangup. When hangup is used, the call will be terminated if a machine is detected. When continue is used, the call will continue even if a machine is detected.
    • :mode [String]: Must be one of detect or detect_beep. Detect if machine answered and sends a human or machine status in the webhook payload. When set to detect_beep, the system also attempts to detect voice mail beep and sends an additional parameter sub_state in the webhook with the value beep_start.
    • :beep_timeout [Integer]: Min: 45, Max: 120. Maximum time in seconds Vonage should wait for a machine beep to be detected. A machine event with sub_state set to beep_timeout will be sent if the timeout is exceeded.
  • :length_timer (Integer)

    Set the number of seconds that elapse before Vonage hangs up after the call state changes to in_progress.

  • :ringing_timer (Integer)

    Set the number of seconds that elapse before Vonage hangs up after the call state changes to ringing.

Returns:

See Also:



76
77
78
79
80
81
82
83
84
85
86
# File 'lib/vonage/voice.rb', line 76

def create(params)
  if params.key?(:from) && params[:random_from_number] == true
    raise ClientError.new("`from` should not be set if `random_from_number` is `true`")
  end

  if params && !params.key?(:from)
    params.merge!(random_from_number: true)
  end

  request('/v1/calls', params: params, type: Post)
end