Loading...
Loading...
Make and receive calls, transfer, bridge, and manage call lifecycle with Call Control. Includes application management and call events. This skill provides Ruby SDK examples.
npx skill4agent add team-telnyx/telnyx-ext-agent-skills telnyx-voice-rubygem install telnyxrequire "telnyx"
client = Telnyx::Client.new(
api_key: ENV["TELNYX_API_KEY"], # This is the default and can be omitted
)clientPOST /calls/{call_control_id}/actions/answerbilling_group_idclient_statecommand_idcustom_headerspreferred_codecsrecordrecord_channelsrecord_custom_file_namerecord_formatrecord_max_lengthrecord_timeout_secsrecord_trackrecord_trimsend_silence_when_idlesip_headerssound_modificationsstream_bidirectional_codecstream_bidirectional_modestream_bidirectional_target_legsstream_codecstream_trackstream_urltranscriptiontranscription_configwebhook_urlwebhook_url_methodresponse = client.calls.actions.answer("call_control_id")
puts(response)POST /calls/{call_control_id}/actions/bridgecall_control_idclient_statecommand_idmute_dtmfpark_after_unbridgeplay_ringtonequeuerecordrecord_channelsrecord_custom_file_namerecord_formatrecord_max_lengthrecord_timeout_secsrecord_trackrecord_trimringtonevideo_room_contextvideo_room_idresponse = client.calls.actions.bridge(
"call_control_id",
call_control_id_to_bridge_with: "v3:MdI91X4lWFEs7IgbBEOT9M4AigoY08M0WWZFISt1Yw2axZ_IiE4pqg"
)
puts(response)POST /callsconnection_idtofromanswering_machine_detectionanswering_machine_detection_configaudio_urlbilling_group_idbridge_intentbridge_on_answerclient_statecommand_idconference_configcustom_headersdialogflow_configenable_dialogflowfrom_display_namelink_tomedia_encryptionmedia_namepark_after_unbridgepreferred_codecsrecordrecord_channelsrecord_custom_file_namerecord_formatrecord_max_lengthrecord_timeout_secsrecord_trackrecord_trimsend_silence_when_idlesip_auth_passwordsip_auth_usernamesip_headerssip_regionsip_transport_protocolsound_modificationsstream_auth_tokenstream_bidirectional_codecstream_bidirectional_modestream_bidirectional_sampling_ratestream_bidirectional_target_legsstream_codecstream_establish_before_call_originatestream_trackstream_urlsupervise_call_control_idsupervisor_roletime_limit_secstimeout_secstranscriptiontranscription_configwebhook_urlwebhook_url_methodresponse = client.calls.dial(
connection_id: "7267xxxxxxxxxxxxxx",
from: "+18005550101",
to: "+18005550100"
)
puts(response)POST /calls/{call_control_id}/actions/hangupclient_statecommand_idresponse = client.calls.actions.hangup("call_control_id")
puts(response)POST /calls/{call_control_id}/actions/transfertoanswering_machine_detectionanswering_machine_detection_configaudio_urlclient_statecommand_idcustom_headersearly_mediafromfrom_display_namemedia_encryptionmedia_namemute_dtmfpark_after_unbridgepreferred_codecsrecordrecord_channelsrecord_custom_file_namerecord_formatrecord_max_lengthrecord_timeout_secsrecord_trackrecord_trimsip_auth_passwordsip_auth_usernamesip_headerssip_regionsip_transport_protocolsound_modificationstarget_leg_client_statetime_limit_secstimeout_secswebhook_retries_policieswebhook_urlwebhook_url_methodwebhook_urlswebhook_urls_methodresponse = client.calls.actions.transfer("call_control_id", to: "+18005550100")
puts(response)GET /connections/{connection_id}/active_callspage = client.connections.list_active_calls("1293384261075731461")
puts(page)GET /call_control_applicationspage = client.call_control_applications.list
puts(page)POST /call_control_applicationsapplication_namewebhook_event_urlactiveanchorsite_overridecall_cost_in_webhooksdtmf_typefirst_command_timeoutfirst_command_timeout_secsinboundoutboundredact_dtmf_debug_loggingwebhook_api_versionwebhook_event_failover_urlwebhook_timeout_secscall_control_application = client.call_control_applications.create(
application_name: "call-router",
webhook_event_url: "https://example.com"
)
puts(call_control_application)GET /call_control_applications/{id}call_control_application = client.call_control_applications.retrieve("1293384261075731499")
puts(call_control_application)PATCH /call_control_applications/{id}application_namewebhook_event_urlactiveanchorsite_overridecall_cost_in_webhooksdtmf_typefirst_command_timeoutfirst_command_timeout_secsinboundoutboundredact_dtmf_debug_loggingtagswebhook_api_versionwebhook_event_failover_urlwebhook_timeout_secscall_control_application = client.call_control_applications.update(
"1293384261075731499",
application_name: "call-router",
webhook_event_url: "https://example.com"
)
puts(call_control_application)DELETE /call_control_applications/{id}call_control_application = client.call_control_applications.delete("1293384261075731499")
puts(call_control_application)GET /call_eventspage = client.call_events.list
puts(page)telnyx-timestamptelnyx-signature-ed25519| Event | Description |
|---|---|
| Call Answered |
| Call Streaming Started |
| Call Streaming Stopped |
| Call Streaming Failed |
| Call Bridged |
| Call Initiated |
| Call Hangup |
| Call Recording Saved |
| Call Machine Detection Ended |
| Call Machine Greeting Ended |
| Call Machine Premium Detection Ended |
| Call Machine Premium Greeting Ended |
callAnswered| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| array[object] | Custom headers set on answer command |
| array[object] | User-to-User and Diversion headers from sip invite. |
| string | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
| date-time | ISO 8601 datetime of when the call started. |
| enum | State received from a command. |
| array[string] | Array of tags associated to number. |
callStreamingStarted| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | Destination WebSocket address where the stream is going to be delivered. |
callStreamingStopped| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | Destination WebSocket address where the stream is going to be delivered. |
callStreamingFailed| Field | Type | Description |
|---|---|---|
| enum | Identifies the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | A short description explaning why the media streaming failed. |
| uuid | Identifies the streaming. |
| enum | The type of stream connection the stream is performing. |
callBridged| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
callInitiated| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | The list of comma-separated codecs enabled for the connection. |
| string | The list of comma-separated codecs offered by caller. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| array[object] | Custom headers from sip invite |
| array[object] | User-to-User and Diversion headers from sip invite. |
| string | SHAKEN/STIR attestation level. |
| boolean | Whether attestation was successfully validated or not. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | Caller id. |
| string | Call screening result. |
| string | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
| enum | Whether the call is |
| enum | State received from a command. |
| date-time | ISO 8601 datetime of when the call started. |
| array[string] | Array of tags associated to number. |
callHangup| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| array[object] | Custom headers set on answer command |
| array[object] | User-to-User and Diversion headers from sip invite. |
| string | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
| date-time | ISO 8601 datetime of when the call started. |
| enum | State received from a command. |
| array[string] | Array of tags associated to number. |
| enum | The reason the call was ended ( |
| enum | The party who ended the call ( |
| string | The reason the call was ended (SIP response code). |
| ['object', 'null'] | Call quality statistics aggregated from the CHANNEL_HANGUP_COMPLETE event. |
callRecordingSaved| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | State received from a command. |
| date-time | ISO 8601 datetime of when recording started. |
| date-time | ISO 8601 datetime of when recording ended. |
| enum | Whether recording was recorded in |
callMachineDetectionEnded| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
| enum | Answering machine detection result. |
callMachineGreetingEnded| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
| enum | Answering machine greeting ended result. |
callMachinePremiumDetectionEnded| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
| enum | Premium Answering Machine Detection result. |
callMachinePremiumGreetingEnded| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
| enum | Premium Answering Machine Greeting Ended result. |