import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: 'My API Key',
});
const response = await client.messsages.rcs({
agent_id: 'Agent007',
agent_message: {},
messaging_profile_id: 'messaging_profile_id',
to: '+13125551234',
});
console.log(response.data);{
"data": {
"record_type": "message",
"direction": "outbound",
"id": "4031938e-60e4-4235-a8dd-0b1c55a23e7a",
"type": "RCS",
"organization_id": "9f61d8e1-7687-4d6d-9cae-9ff682985983",
"messaging_profile_id": "4001781e-626f-4a41-a914-b1b682150f94",
"from": {
"agent_id": "Agent007",
"carrier": "Telnyx",
"agent_name": "Test Agent"
},
"to": [
{
"phone_number": "+13125551234",
"status": "queued",
"carrier": "Verizon Wireless",
"line_type": "Wireless"
}
],
"body": {
"content_message": {
"suggestions": [
{
"reply": {
"text": "<string>",
"postback_data": "<string>"
},
"action": {
"text": "Hello world",
"postback_data": "<string>",
"fallback_url": "<string>",
"dial_action": {
"phone_number": "+13125551234"
},
"view_location_action": {
"lat_long": {
"latitude": 41.8,
"longitude": -87.6
},
"label": "<string>",
"query": "<string>"
},
"create_calendar_event_action": {
"start_time": "2024-10-02T15:01:23Z",
"end_time": "2024-10-02T15:02:31Z",
"title": "<string>",
"description": "<string>"
},
"open_url_action": {
"url": "http://example.com",
"application": "BROWSER",
"webview_view_mode": "HALF",
"description": "<string>"
},
"share_location_action": {}
}
}
],
"text": "Hello world!",
"rich_card": {
"carousel_card": {
"card_width": "SMALL",
"card_contents": [
{
"title": "Elephant",
"description": "<string>",
"media": {
"height": "MEDIUM",
"content_info": {
"file_url": "https://example.com/elephant.jpg",
"thumbnail_url": "<string>",
"force_refresh": true
}
},
"suggestions": [
{
"reply": {
"text": "<string>",
"postback_data": "<string>"
},
"action": {
"text": "Hello world",
"postback_data": "<string>",
"fallback_url": "<string>",
"dial_action": {
"phone_number": "+13125551234"
},
"view_location_action": {
"lat_long": {
"latitude": 41.8,
"longitude": -87.6
},
"label": "<string>",
"query": "<string>"
},
"create_calendar_event_action": {
"start_time": "2024-10-02T15:01:23Z",
"end_time": "2024-10-02T15:02:31Z",
"title": "<string>",
"description": "<string>"
},
"open_url_action": {
"url": "http://example.com",
"application": "BROWSER",
"webview_view_mode": "HALF",
"description": "<string>"
},
"share_location_action": {}
}
}
]
}
]
},
"standalone_card": {
"card_orientation": "HORIZONTAL",
"thumbnail_image_alignment": "LEFT",
"card_content": {
"title": "Elephant",
"description": "<string>",
"media": {
"height": "MEDIUM",
"content_info": {
"file_url": "https://example.com/elephant.jpg",
"thumbnail_url": "<string>",
"force_refresh": true
}
},
"suggestions": [
{
"reply": {
"text": "<string>",
"postback_data": "<string>"
},
"action": {
"text": "Hello world",
"postback_data": "<string>",
"fallback_url": "<string>",
"dial_action": {
"phone_number": "+13125551234"
},
"view_location_action": {
"lat_long": {
"latitude": 41.8,
"longitude": -87.6
},
"label": "<string>",
"query": "<string>"
},
"create_calendar_event_action": {
"start_time": "2024-10-02T15:01:23Z",
"end_time": "2024-10-02T15:02:31Z",
"title": "<string>",
"description": "<string>"
},
"open_url_action": {
"url": "http://example.com",
"application": "BROWSER",
"webview_view_mode": "HALF",
"description": "<string>"
},
"share_location_action": {}
}
}
]
}
}
},
"content_info": {
"file_url": "https://example.com/elephant.jpg",
"thumbnail_url": "<string>",
"force_refresh": true
}
},
"event": {
"event_type": "IS_TYPING"
},
"expire_time": "2024-10-02T15:01:23Z",
"ttl": "10.5s"
},
"encoding": "utf-8",
"received_at": "2023-11-07T05:31:56Z"
}
}import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: 'My API Key',
});
const response = await client.messsages.rcs({
agent_id: 'Agent007',
agent_message: {},
messaging_profile_id: 'messaging_profile_id',
to: '+13125551234',
});
console.log(response.data);{
"data": {
"record_type": "message",
"direction": "outbound",
"id": "4031938e-60e4-4235-a8dd-0b1c55a23e7a",
"type": "RCS",
"organization_id": "9f61d8e1-7687-4d6d-9cae-9ff682985983",
"messaging_profile_id": "4001781e-626f-4a41-a914-b1b682150f94",
"from": {
"agent_id": "Agent007",
"carrier": "Telnyx",
"agent_name": "Test Agent"
},
"to": [
{
"phone_number": "+13125551234",
"status": "queued",
"carrier": "Verizon Wireless",
"line_type": "Wireless"
}
],
"body": {
"content_message": {
"suggestions": [
{
"reply": {
"text": "<string>",
"postback_data": "<string>"
},
"action": {
"text": "Hello world",
"postback_data": "<string>",
"fallback_url": "<string>",
"dial_action": {
"phone_number": "+13125551234"
},
"view_location_action": {
"lat_long": {
"latitude": 41.8,
"longitude": -87.6
},
"label": "<string>",
"query": "<string>"
},
"create_calendar_event_action": {
"start_time": "2024-10-02T15:01:23Z",
"end_time": "2024-10-02T15:02:31Z",
"title": "<string>",
"description": "<string>"
},
"open_url_action": {
"url": "http://example.com",
"application": "BROWSER",
"webview_view_mode": "HALF",
"description": "<string>"
},
"share_location_action": {}
}
}
],
"text": "Hello world!",
"rich_card": {
"carousel_card": {
"card_width": "SMALL",
"card_contents": [
{
"title": "Elephant",
"description": "<string>",
"media": {
"height": "MEDIUM",
"content_info": {
"file_url": "https://example.com/elephant.jpg",
"thumbnail_url": "<string>",
"force_refresh": true
}
},
"suggestions": [
{
"reply": {
"text": "<string>",
"postback_data": "<string>"
},
"action": {
"text": "Hello world",
"postback_data": "<string>",
"fallback_url": "<string>",
"dial_action": {
"phone_number": "+13125551234"
},
"view_location_action": {
"lat_long": {
"latitude": 41.8,
"longitude": -87.6
},
"label": "<string>",
"query": "<string>"
},
"create_calendar_event_action": {
"start_time": "2024-10-02T15:01:23Z",
"end_time": "2024-10-02T15:02:31Z",
"title": "<string>",
"description": "<string>"
},
"open_url_action": {
"url": "http://example.com",
"application": "BROWSER",
"webview_view_mode": "HALF",
"description": "<string>"
},
"share_location_action": {}
}
}
]
}
]
},
"standalone_card": {
"card_orientation": "HORIZONTAL",
"thumbnail_image_alignment": "LEFT",
"card_content": {
"title": "Elephant",
"description": "<string>",
"media": {
"height": "MEDIUM",
"content_info": {
"file_url": "https://example.com/elephant.jpg",
"thumbnail_url": "<string>",
"force_refresh": true
}
},
"suggestions": [
{
"reply": {
"text": "<string>",
"postback_data": "<string>"
},
"action": {
"text": "Hello world",
"postback_data": "<string>",
"fallback_url": "<string>",
"dial_action": {
"phone_number": "+13125551234"
},
"view_location_action": {
"lat_long": {
"latitude": 41.8,
"longitude": -87.6
},
"label": "<string>",
"query": "<string>"
},
"create_calendar_event_action": {
"start_time": "2024-10-02T15:01:23Z",
"end_time": "2024-10-02T15:02:31Z",
"title": "<string>",
"description": "<string>"
},
"open_url_action": {
"url": "http://example.com",
"application": "BROWSER",
"webview_view_mode": "HALF",
"description": "<string>"
},
"share_location_action": {}
}
}
]
}
}
},
"content_info": {
"file_url": "https://example.com/elephant.jpg",
"thumbnail_url": "<string>",
"force_refresh": true
}
},
"event": {
"event_type": "IS_TYPING"
},
"expire_time": "2024-10-02T15:01:23Z",
"ttl": "10.5s"
},
"encoding": "utf-8",
"received_at": "2023-11-07T05:31:56Z"
}
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
RCS message body
RCS Agent ID
"Agent007"
Phone number in +E.164 format
"+13125551234"
A valid messaging profile ID
Show child attributes
Show child attributes
List of suggested actions and replies
Show child attributes
Show child attributes
Text that is shown in the suggested reply (maximum 25 characters)
Payload (base64 encoded) that will be sent to the agent in the user event that results when the user taps the suggested action. Maximum 2048 characters.
When tapped, initiates the corresponding native action on the device.
Show child attributes
Text that is shown in the suggested action. Maximum 25 characters.
"Hello world"
Payload (base64 encoded) that will be sent to the agent in the user event that results when the user taps the suggested action. Maximum 2048 characters.
Fallback URL to use if a client doesn't support a suggested action. Fallback URLs open in new browser windows. Maximum 2048 characters.
Opens the user's default dialer app with the agent-specified phone number filled in.
Show child attributes
Phone number in +E.164 format
"+13125551234"
Opens the user's default map app and selects the agent-specified location.
Show child attributes
Show child attributes
The latitude in degrees. It must be in the range [-90.0, +90.0].
41.8
The longitude in degrees. It must be in the range [-180.0, +180.0].
-87.6
The label of the pin dropped
query string (Android only)
Opens the user's default calendar app and starts the new calendar event flow with the agent-specified event data pre-filled.
Show child attributes
"2024-10-02T15:01:23Z"
"2024-10-02T15:02:31Z"
Event title. Maximum 100 characters.
Event description. Maximum 500 characters.
Opens the user's default web browser app to the specified URL.
Show child attributes
"http://example.com"
URL open application, browser or webview.
OPEN_URL_APPLICATION_UNSPECIFIED, BROWSER, WEBVIEW "BROWSER"
WEBVIEW_VIEW_MODE_UNSPECIFIED, FULL, HALF, TALL "HALF"
Accessbility description for webview.
Opens the RCS app's location chooser so the user can pick a location to send back to the agent.
Text (maximum 3072 characters)
"Hello world!"
Show child attributes
Carousel of cards.
Show child attributes
The width of the cards in the carousel.
CARD_WIDTH_UNSPECIFIED, SMALL, MEDIUM "SMALL"
The list of contents for each card in the carousel. A carousel can have a minimum of 2 cards and a maximum 10 cards.
Show child attributes
Title of the card (at most 200 characters)
"Elephant"
Description of the card (at most 2000 characters)
A media file within a rich card.
Show child attributes
The height of the media within a rich card with a vertical layout. For a standalone card with horizontal layout, height is not customizable, and this field is ignored.
HEIGHT_UNSPECIFIED, SHORT, MEDIUM, TALL "MEDIUM"
Show child attributes
Publicly reachable URL of the file.
"https://example.com/elephant.jpg"
Publicly reachable URL of the thumbnail. Maximum size of 100 kB.
If set the URL content will not be cached.
List of suggestions to include in the card. Maximum 10 suggestions.
Show child attributes
Show child attributes
Text that is shown in the suggested reply (maximum 25 characters)
Payload (base64 encoded) that will be sent to the agent in the user event that results when the user taps the suggested action. Maximum 2048 characters.
When tapped, initiates the corresponding native action on the device.
Show child attributes
Text that is shown in the suggested action. Maximum 25 characters.
"Hello world"
Payload (base64 encoded) that will be sent to the agent in the user event that results when the user taps the suggested action. Maximum 2048 characters.
Fallback URL to use if a client doesn't support a suggested action. Fallback URLs open in new browser windows. Maximum 2048 characters.
Opens the user's default dialer app with the agent-specified phone number filled in.
Show child attributes
Phone number in +E.164 format
"+13125551234"
Opens the user's default map app and selects the agent-specified location.
Show child attributes
Show child attributes
The latitude in degrees. It must be in the range [-90.0, +90.0].
41.8
The longitude in degrees. It must be in the range [-180.0, +180.0].
-87.6
The label of the pin dropped
query string (Android only)
Opens the user's default calendar app and starts the new calendar event flow with the agent-specified event data pre-filled.
Show child attributes
"2024-10-02T15:01:23Z"
"2024-10-02T15:02:31Z"
Event title. Maximum 100 characters.
Event description. Maximum 500 characters.
Opens the user's default web browser app to the specified URL.
Show child attributes
"http://example.com"
URL open application, browser or webview.
OPEN_URL_APPLICATION_UNSPECIFIED, BROWSER, WEBVIEW "BROWSER"
WEBVIEW_VIEW_MODE_UNSPECIFIED, FULL, HALF, TALL "HALF"
Accessbility description for webview.
Opens the RCS app's location chooser so the user can pick a location to send back to the agent.
Standalone card
Show child attributes
Orientation of the card.
CARD_ORIENTATION_UNSPECIFIED, HORIZONTAL, VERTICAL "HORIZONTAL"
Image preview alignment for standalone cards with horizontal layout.
THUMBNAIL_IMAGE_ALIGNMENT_UNSPECIFIED, LEFT, RIGHT "LEFT"
Show child attributes
Title of the card (at most 200 characters)
"Elephant"
Description of the card (at most 2000 characters)
A media file within a rich card.
Show child attributes
The height of the media within a rich card with a vertical layout. For a standalone card with horizontal layout, height is not customizable, and this field is ignored.
HEIGHT_UNSPECIFIED, SHORT, MEDIUM, TALL "MEDIUM"
Show child attributes
Publicly reachable URL of the file.
"https://example.com/elephant.jpg"
Publicly reachable URL of the thumbnail. Maximum size of 100 kB.
If set the URL content will not be cached.
List of suggestions to include in the card. Maximum 10 suggestions.
Show child attributes
Show child attributes
Text that is shown in the suggested reply (maximum 25 characters)
Payload (base64 encoded) that will be sent to the agent in the user event that results when the user taps the suggested action. Maximum 2048 characters.
When tapped, initiates the corresponding native action on the device.
Show child attributes
Text that is shown in the suggested action. Maximum 25 characters.
"Hello world"
Payload (base64 encoded) that will be sent to the agent in the user event that results when the user taps the suggested action. Maximum 2048 characters.
Fallback URL to use if a client doesn't support a suggested action. Fallback URLs open in new browser windows. Maximum 2048 characters.
Opens the user's default dialer app with the agent-specified phone number filled in.
Show child attributes
Phone number in +E.164 format
"+13125551234"
Opens the user's default map app and selects the agent-specified location.
Show child attributes
Show child attributes
The latitude in degrees. It must be in the range [-90.0, +90.0].
41.8
The longitude in degrees. It must be in the range [-180.0, +180.0].
-87.6
The label of the pin dropped
query string (Android only)
Opens the user's default calendar app and starts the new calendar event flow with the agent-specified event data pre-filled.
Show child attributes
"2024-10-02T15:01:23Z"
"2024-10-02T15:02:31Z"
Event title. Maximum 100 characters.
Event description. Maximum 500 characters.
Opens the user's default web browser app to the specified URL.
Show child attributes
"http://example.com"
URL open application, browser or webview.
OPEN_URL_APPLICATION_UNSPECIFIED, BROWSER, WEBVIEW "BROWSER"
WEBVIEW_VIEW_MODE_UNSPECIFIED, FULL, HALF, TALL "HALF"
Accessbility description for webview.
Opens the RCS app's location chooser so the user can pick a location to send back to the agent.
Show child attributes
Publicly reachable URL of the file.
"https://example.com/elephant.jpg"
Publicly reachable URL of the thumbnail. Maximum size of 100 kB.
If set the URL content will not be cached.
Timestamp in UTC of when this message is considered expired
"2024-10-02T15:01:23Z"
Duration in seconds ending with 's'
"10.5s"
Message type - must be set to "RCS"
RCS "RCS"
The URL where webhooks related to this message will be sent.
Successful operation
Show child attributes
"message"
"outbound"
message ID
"4031938e-60e4-4235-a8dd-0b1c55a23e7a"
"RCS"
"9f61d8e1-7687-4d6d-9cae-9ff682985983"
"4001781e-626f-4a41-a914-b1b682150f94"
Show child attributes
Show child attributes
List of suggested actions and replies
Show child attributes
Show child attributes
Text that is shown in the suggested reply (maximum 25 characters)
Payload (base64 encoded) that will be sent to the agent in the user event that results when the user taps the suggested action. Maximum 2048 characters.
When tapped, initiates the corresponding native action on the device.
Show child attributes
Text that is shown in the suggested action. Maximum 25 characters.
"Hello world"
Payload (base64 encoded) that will be sent to the agent in the user event that results when the user taps the suggested action. Maximum 2048 characters.
Fallback URL to use if a client doesn't support a suggested action. Fallback URLs open in new browser windows. Maximum 2048 characters.
Opens the user's default dialer app with the agent-specified phone number filled in.
Show child attributes
Phone number in +E.164 format
"+13125551234"
Opens the user's default map app and selects the agent-specified location.
Show child attributes
Show child attributes
The latitude in degrees. It must be in the range [-90.0, +90.0].
41.8
The longitude in degrees. It must be in the range [-180.0, +180.0].
-87.6
The label of the pin dropped
query string (Android only)
Opens the user's default calendar app and starts the new calendar event flow with the agent-specified event data pre-filled.
Show child attributes
"2024-10-02T15:01:23Z"
"2024-10-02T15:02:31Z"
Event title. Maximum 100 characters.
Event description. Maximum 500 characters.
Opens the user's default web browser app to the specified URL.
Show child attributes
"http://example.com"
URL open application, browser or webview.
OPEN_URL_APPLICATION_UNSPECIFIED, BROWSER, WEBVIEW "BROWSER"
WEBVIEW_VIEW_MODE_UNSPECIFIED, FULL, HALF, TALL "HALF"
Accessbility description for webview.
Opens the RCS app's location chooser so the user can pick a location to send back to the agent.
Text (maximum 3072 characters)
"Hello world!"
Show child attributes
Carousel of cards.
Show child attributes
The width of the cards in the carousel.
CARD_WIDTH_UNSPECIFIED, SMALL, MEDIUM "SMALL"
The list of contents for each card in the carousel. A carousel can have a minimum of 2 cards and a maximum 10 cards.
Show child attributes
Title of the card (at most 200 characters)
"Elephant"
Description of the card (at most 2000 characters)
A media file within a rich card.
Show child attributes
The height of the media within a rich card with a vertical layout. For a standalone card with horizontal layout, height is not customizable, and this field is ignored.
HEIGHT_UNSPECIFIED, SHORT, MEDIUM, TALL "MEDIUM"
Show child attributes
Publicly reachable URL of the file.
"https://example.com/elephant.jpg"
Publicly reachable URL of the thumbnail. Maximum size of 100 kB.
If set the URL content will not be cached.
List of suggestions to include in the card. Maximum 10 suggestions.
Show child attributes
Show child attributes
Text that is shown in the suggested reply (maximum 25 characters)
Payload (base64 encoded) that will be sent to the agent in the user event that results when the user taps the suggested action. Maximum 2048 characters.
When tapped, initiates the corresponding native action on the device.
Show child attributes
Text that is shown in the suggested action. Maximum 25 characters.
"Hello world"
Payload (base64 encoded) that will be sent to the agent in the user event that results when the user taps the suggested action. Maximum 2048 characters.
Fallback URL to use if a client doesn't support a suggested action. Fallback URLs open in new browser windows. Maximum 2048 characters.
Opens the user's default dialer app with the agent-specified phone number filled in.
Show child attributes
Phone number in +E.164 format
"+13125551234"
Opens the user's default map app and selects the agent-specified location.
Show child attributes
Show child attributes
The latitude in degrees. It must be in the range [-90.0, +90.0].
41.8
The longitude in degrees. It must be in the range [-180.0, +180.0].
-87.6
The label of the pin dropped
query string (Android only)
Opens the user's default calendar app and starts the new calendar event flow with the agent-specified event data pre-filled.
Show child attributes
"2024-10-02T15:01:23Z"
"2024-10-02T15:02:31Z"
Event title. Maximum 100 characters.
Event description. Maximum 500 characters.
Opens the user's default web browser app to the specified URL.
Show child attributes
"http://example.com"
URL open application, browser or webview.
OPEN_URL_APPLICATION_UNSPECIFIED, BROWSER, WEBVIEW "BROWSER"
WEBVIEW_VIEW_MODE_UNSPECIFIED, FULL, HALF, TALL "HALF"
Accessbility description for webview.
Opens the RCS app's location chooser so the user can pick a location to send back to the agent.
Standalone card
Show child attributes
Orientation of the card.
CARD_ORIENTATION_UNSPECIFIED, HORIZONTAL, VERTICAL "HORIZONTAL"
Image preview alignment for standalone cards with horizontal layout.
THUMBNAIL_IMAGE_ALIGNMENT_UNSPECIFIED, LEFT, RIGHT "LEFT"
Show child attributes
Title of the card (at most 200 characters)
"Elephant"
Description of the card (at most 2000 characters)
A media file within a rich card.
Show child attributes
The height of the media within a rich card with a vertical layout. For a standalone card with horizontal layout, height is not customizable, and this field is ignored.
HEIGHT_UNSPECIFIED, SHORT, MEDIUM, TALL "MEDIUM"
Show child attributes
Publicly reachable URL of the file.
"https://example.com/elephant.jpg"
Publicly reachable URL of the thumbnail. Maximum size of 100 kB.
If set the URL content will not be cached.
List of suggestions to include in the card. Maximum 10 suggestions.
Show child attributes
Show child attributes
Text that is shown in the suggested reply (maximum 25 characters)
Payload (base64 encoded) that will be sent to the agent in the user event that results when the user taps the suggested action. Maximum 2048 characters.
When tapped, initiates the corresponding native action on the device.
Show child attributes
Text that is shown in the suggested action. Maximum 25 characters.
"Hello world"
Payload (base64 encoded) that will be sent to the agent in the user event that results when the user taps the suggested action. Maximum 2048 characters.
Fallback URL to use if a client doesn't support a suggested action. Fallback URLs open in new browser windows. Maximum 2048 characters.
Opens the user's default dialer app with the agent-specified phone number filled in.
Show child attributes
Phone number in +E.164 format
"+13125551234"
Opens the user's default map app and selects the agent-specified location.
Show child attributes
Show child attributes
The latitude in degrees. It must be in the range [-90.0, +90.0].
41.8
The longitude in degrees. It must be in the range [-180.0, +180.0].
-87.6
The label of the pin dropped
query string (Android only)
Opens the user's default calendar app and starts the new calendar event flow with the agent-specified event data pre-filled.
Show child attributes
"2024-10-02T15:01:23Z"
"2024-10-02T15:02:31Z"
Event title. Maximum 100 characters.
Event description. Maximum 500 characters.
Opens the user's default web browser app to the specified URL.
Show child attributes
"http://example.com"
URL open application, browser or webview.
OPEN_URL_APPLICATION_UNSPECIFIED, BROWSER, WEBVIEW "BROWSER"
WEBVIEW_VIEW_MODE_UNSPECIFIED, FULL, HALF, TALL "HALF"
Accessbility description for webview.
Opens the RCS app's location chooser so the user can pick a location to send back to the agent.
Show child attributes
Publicly reachable URL of the file.
"https://example.com/elephant.jpg"
Publicly reachable URL of the thumbnail. Maximum size of 100 kB.
If set the URL content will not be cached.
Timestamp in UTC of when this message is considered expired
"2024-10-02T15:01:23Z"
Duration in seconds ending with 's'
"10.5s"
"utf-8"
Was this page helpful?