Call Creation Examples
From SwitchvoxExtendAPI
Contents |
Example Admin Requests and Responses
Extension to Extension
(admin authentication)
Call extension 101 and when they pickup connect them to extension 301 and use account 1106's call rules.
Request
<request method="switchvox.call"> <parameters> <dial_first>101</dial_first> <dial_second>301</dial_second> <dial_as_account_id>1106</dial_as_account_id> </parameters> </request>
Response
<response method="switchvox.call"> <result> <call_info dialed_first="101" dialed_second="301" > <variables></variables> </call_info> </result> </response>
Extension to External Number
(admin authentication)
Call extension 101 and when they answer connect them to external number 15554578299 and use account 1106's call rules and api settings.
In the response you will notice the actual number dialed as 915554578299, because account 1106's call api settings prefixed a 9 on the number automatically.
Request
<request method="switchvox.call"> <parameters> <dial_first>101</dial_first> <dial_second>15554578299</dial_second> <dial_as_account_id>1106</dial_as_account_id> </parameters> </request>
Response
<response method="switchvox.call"> <result> <call_info dialed_first="101" dialed_second="915554578299" > <variables> </variables> </call_info> </result> </response>
Extension to External Number (setting caller ID)
(admin authentication)
Call extension 101 and when they answer connect them to external number 915554578299 and use account 1106's call rules and api settings and set the caller id name displayed to 101 as "AutoDialer"
We added the parameter "ignore_user_api_settings=1" because the number already has a 9 prefix on it.
Request
<request method="switchvox.call"> <parameters> <dial_first>101</dial_first> <dial_second>915554578299</dial_second> <dial_as_account_id>1106</dial_as_account_id> <caller_id_name>Autodialer</caller_id_name> <ignore_user_api_settings>1</ignore_user_api_settings> </parameters> </request>
Response
<response method="switchvox.call"> <result> <call_info dialed_first="101" dialed_second="915554578299" > <variables></variables> </call_info> </result> </response>
External Number to External Number
(admin authentication)
Call external number 1-555-754-9928 and when they answer connect them to external number 1-555-457-8299 and use account 1106's call rules and api settings.
In the response you will notice that both numbers dialed have a 9 prefixed. This is because account 1106's call api settings are defined to prefix a 9 on the number automatically.
Request
<request method="switchvox.call"> <parameters> <dial_first>15557549928</dial_first> <dial_second>15554578299</dial_second> <dial_as_account_id>1106</dial_as_account_id> </parameters> </request>
Response
<response method="switchvox.call"> <result> <call_info dialed_first="915557549928" dialed_second="915554578299" > <variables></variables> </call_info> </result> </response>
External Number to IVR (set IVR variables)
(admin authentication)
Call external number 555-457-8299 and when they answer connect them to extension 805 (custom IVR) and set the value of the IVR variable "balance" to the value of "450". The IVR can then read this variable ("balance") back to the caller.
Request
<request method="switchvox.call"> <parameters> <dial_first>15554578299</dial_first> <dial_second>805</dial_second> <dial_as_account_id>1106</dial_as_account_id> <variables> <variable>balance=450</variable> </variables> </parameters> </request>
Response
<response method="switchvox.call"> <result> <call_info dialed_first="915554578299" dialed_second="800" > <variables> <ivr_variable id="3" name="balance" status="exists" /> </variables> </call_info> </result> </response>
Example User Requests and Responses
User requests are very similar to admin requests, but users requests use the account_id to determine which outgoing rules and call api settings to use instead of dial_as_account_id like the admin.
Request
<request method="switchvox.users.call"> <parameters> <account_id>1106</account_id> <dial_first>101</dial_first> <dial_second>800</dial_second> </parameters> </request>
Response
<response method="switchvox.users.call"> <result> <call_info dialed_first="101" dialed_second="800" > <variables> </variables> </call_info> </result> </response>
Bad Requests
Invalid Numbers
Trying to pass in letters instead of numbers
Request
<request method="switchvox.call"> <parameters> <dial_first>abc</dial_first> <dial_second>def</dial_second> <dial_as_account_id>1106</dial_as_account_id> </parameters> </request>
Response
<response method="switchvox.call"> <errors> <error code="54222" message="Invalid phone number or extension for parameter dial_second. Number must only contain digits,*,or #." /> <error code="54222" message="Invalid phone number or extension for parameter dial_first. Number must only contain digits,*,or #." /> </errors> </response>
Dial First Never Picks Up
Changed the timeout to 10 seconds, and extension 301 didn't answer the call in time so the call failed.
Request
<request method="switchvox.call"> <parameters> <dial_first>301</dial_first> <dial_second>800</dial_second> <dial_as_account_id>1106</dial_as_account_id> <timeout>10</timeout> </parameters> </request>
Response
<response method="switchvox.call"> <errors> <error code="41591" message="Your call failed to connect (Originate failed)." /> </errors> </response>