Loading...
Loading...
Send and receive SMS/MMS messages, manage messaging-enabled phone numbers, and handle opt-outs. Use when building messaging applications, implementing 2FA, or sending notifications. This skill provides Ruby SDK examples.
npx skill4agent add team-telnyx/telnyx-ext-agent-skills telnyx-messaging-rubygem install telnyxrequire "telnyx"
client = Telnyx::Client.new(
api_key: ENV["TELNYX_API_KEY"], # This is the default and can be omitted
)clientPOST /messagestoauto_detectencodingfrommedia_urlsmessaging_profile_idsend_atsubjecttexttypeuse_profile_webhookswebhook_failover_urlwebhook_urlresponse = client.messages.send_(to: "+18445550001")
puts(response)GET /messages/{id}message = client.messages.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(message)DELETE /messages/{id}response = client.messages.cancel_scheduled("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(response)POST /messages/whatsappfromtowhatsapp_messagetypewebhook_urlresponse = client.messages.send_whatsapp(from: "+13125551234", to: "+13125551234", whatsapp_message: {})
puts(response)POST /messages/group_mmsfromtomedia_urlssubjecttextuse_profile_webhookswebhook_failover_urlwebhook_urlresponse = client.messages.send_group_mms(from: "+13125551234", to: ["+18655551234", "+14155551234"])
puts(response)POST /messages/long_codefromtoauto_detectencodingmedia_urlssubjecttexttypeuse_profile_webhookswebhook_failover_urlwebhook_urlresponse = client.messages.send_long_code(from: "+18445550001", to: "+13125550002")
puts(response)POST /messages/number_pooltomessaging_profile_idauto_detectencodingmedia_urlssubjecttexttypeuse_profile_webhookswebhook_failover_urlwebhook_urlresponse = client.messages.send_number_pool(
messaging_profile_id: "abc85f64-5717-4562-b3fc-2c9600000000",
to: "+13125550002"
)
puts(response)POST /messages/scheduletoauto_detectfrommedia_urlsmessaging_profile_idsend_atsubjecttexttypeuse_profile_webhookswebhook_failover_urlwebhook_urlresponse = client.messages.schedule(to: "+18445550001")
puts(response)POST /messages/short_codefromtoauto_detectencodingmedia_urlssubjecttexttypeuse_profile_webhookswebhook_failover_urlwebhook_urlresponse = client.messages.send_short_code(from: "+18445550001", to: "+18445550001")
puts(response)GET /messaging_optoutspage = client.messaging_optouts.list
puts(page)GET /phone_numbers/{id}/messagingmessaging = client.phone_numbers.messaging.retrieve("id")
puts(messaging)PATCH /phone_numbers/{id}/messagingmessaging_productmessaging_profile_idtagsmessaging = client.phone_numbers.messaging.update("id")
puts(messaging)GET /phone_numbers/messagingpage = client.phone_numbers.messaging.list
puts(page)GET /mobile_phone_numbers/{id}/messagingmessaging = client.mobile_phone_numbers.messaging.retrieve("id")
puts(messaging)GET /mobile_phone_numbers/messagingpage = client.mobile_phone_numbers.messaging.list
puts(page)POST /messaging_numbers/bulk_updatesmessaging_profile_idnumbersassign_onlymessaging_numbers_bulk_update = client.messaging_numbers_bulk_updates.create(
messaging_profile_id: "00000000-0000-0000-0000-000000000000",
numbers: ["+18880000000", "+18880000001", "+18880000002"]
)
puts(messaging_numbers_bulk_update)GET /messaging_numbers/bulk_updates/{order_id}messaging_numbers_bulk_update = client.messaging_numbers_bulk_updates.retrieve("order_id")
puts(messaging_numbers_bulk_update)telnyx-timestamptelnyx-signature-ed25519| Event | Description |
|---|---|
| Delivery Update |
| Inbound Message |
| Replaced Link Click |
deliveryUpdate| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| uuid | Identifies the type of resource. |
| enum | The type of event being delivered. |
| date-time | ISO 8601 formatted date indicating when the resource was created. |
| enum | Identifies the type of the resource. |
| enum | The direction of the message. |
| uuid | Identifies the type of resource. |
| enum | The type of message. |
| string | Unique identifier for a messaging profile. |
| uuid | The id of the organization the messaging profile belongs to. |
| array[object] | |
| array[object] | |
| string | Message body (i.e., content) as a non-empty string. |
| ['string', 'null'] | Subject of multimedia message |
| array[object] | |
| url | The URL where webhooks related to this message will be sent. |
| url | The failover URL where webhooks related to this message will be sent if sending to the primary URL fails. |
| string | Encoding scheme used for the message body. |
| integer | Number of parts into which the message's body must be split. |
| array[string] | Tags associated with the resource. |
| ['object', 'null'] | |
| ['object', 'null'] | Detailed breakdown of the message cost components. |
| ['string', 'null'] | The Campaign Registry (TCR) campaign ID associated with the message. |
| boolean | Indicates whether the TCR campaign is billable. |
| ['string', 'null'] | The registration status of the TCR campaign. |
| date-time | ISO 8601 formatted date indicating when the message request was received. |
| date-time | ISO 8601 formatted date indicating when the message was sent. |
| date-time | ISO 8601 formatted date indicating when the message was finalized. |
| date-time | Message must be out of the queue by this time or else it will be discarded and marked as 'sending_failed'. |
| array[object] | These errors may point at addressees when referring to unsuccessful/unconfirmed delivery statuses. |
| boolean | Indicates whether smart encoding was applied to this message. |
| integer | Number of attempts to deliver the webhook event. |
| url | The webhook URL the event was delivered to. |
inboundMessage| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| uuid | Identifies the type of resource. |
| enum | The type of event being delivered. |
| date-time | ISO 8601 formatted date indicating when the resource was created. |
| enum | Identifies the type of the resource. |
| enum | The direction of the message. |
| uuid | Identifies the type of resource. |
| enum | The type of message. |
| string | Unique identifier for a messaging profile. |
| string | Unique identifier for a messaging profile. |
| array[object] | |
| array[object] | |
| string | Message body (i.e., content) as a non-empty string. |
| ['string', 'null'] | Message subject. |
| array[object] | |
| url | The URL where webhooks related to this message will be sent. |
| url | The failover URL where webhooks related to this message will be sent if sending to the primary URL fails. |
| string | Encoding scheme used for the message body. |
| integer | Number of parts into which the message's body must be split. |
| array[string] | Tags associated with the resource. |
| ['object', 'null'] | |
| ['object', 'null'] | Detailed breakdown of the message cost components. |
| ['string', 'null'] | The Campaign Registry (TCR) campaign ID associated with the message. |
| boolean | Indicates whether the TCR campaign is billable. |
| ['string', 'null'] | The registration status of the TCR campaign. |
| date-time | ISO 8601 formatted date indicating when the message request was received. |
| date-time | Not used for inbound messages. |
| date-time | Not used for inbound messages. |
| date-time | Not used for inbound messages. |
| array[object] | These errors may point at addressees when referring to unsuccessful/unconfirmed delivery statuses. |
replacedLinkClick| Field | Type | Description |
|---|---|---|
| string | Identifies the type of the resource. |
| string | The original link that was sent in the message. |
| string | Sending address (+E.164 formatted phone number, alphanumeric sender ID, or short code). |
| uuid | The message ID associated with the clicked link. |
| date-time | ISO 8601 formatted date indicating when the message request was received. |