View a markdown version of this page

发送 RCS 消息 - AWS 最终用户消息 SMS

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

发送 RCS 消息

AWS 最终用户消息传送使用相同SendTextMessage的 API 进行 RCS 和 SMS 传送。该服务如何路由您的消息取决于您在请求中指定的发件身份。您可以通过电话池(推荐)、账户级别或直接通过 AWS RCS 代理 ARN 发送消息。

本节介绍三种发送模式、如何解释送货收据,并提供代码示例。有关粘性发送、发起身份优先顺序和自动短信回退的详细信息,请参阅。使用电话池进行 RCS 到 SMS 的备用操作有关管理 AWS RCS 代理的详细信息,请参阅管理 RCS 代理。

注意

本页介绍使用 SendTextMessage API 通过 RCS 和 SMS 发送短信。要发送丰富的 RCS 内容,例如丰富的卡片、轮播、媒体文件和交互式建议,请改用 API。SendRcsMessage有关两个 API 操作的比较以及选择指南,请参阅在 SendTextMessage 和之间进行选择 SendRcsMessage。

发送图案

AWS 最终用户消息支持三种发送 RCS 消息的模式。每种模式都决定了服务如何选择发起身份以及是否可使用自动短信回退。

RCS 发送模式
模式 工作原理 短信备用 何时使用
Pool-based (推荐) 将池 ID 指定为原始身份。该服务从池中选择最佳身份。 是 所有用例。通过合规性安全路由提供自动频道选择和短信回退。
Account-level 省略起源身份。该服务从您账户中的所有可用身份中进行选择。 是 使用单一用例进行简单设置。不建议有多种用例的账户使用。
直接发送 指定 AWS RCS 代理 ARN 作为原始身份。该消息仅通过 RCS 发送。 否 RCS-or-nothing 用例,或者当您在 AWS 最终用户消息之外管理 SMS 备用时。

Pool-based 发送(推荐)

Pool-based 发送是所有 RCS 用例的推荐方法。当您在SendTextMessage请求中指定一个池 ID 作为发起身份时, AWS 最终用户消息会根据目的地、频道可用性和粘性发送历史从池中选择最佳的发起身份。

如果池中同时包含 AWS RCS 代理和 SMS 电话号码,则该服务将首先尝试 RCS 交付。如果 RCS 交付失败,该服务将使用同一池中的电话号码自动回退到 SMS。由于池中的所有身份都是针对相同的用例注册的,因此回退消息始终使用适当的号码发送。

有关使用 AWS RCS 代理创建和配置池的详细信息,请参阅使用电话池进行 RCS 到 SMS 的备用操作。

Account-level 发送

当您在SendTextMessage请求中省略来源身份时,“ AWS 最终用户消息” 会从您账户中的所有可用身份中选择一个发起身份。如果您的账户有活跃的 AWS RCS 代理,则该服务会先尝试交付 RCS。如果 RCS 交付失败,该服务将退回到账户中的专用电话号码或发件人 ID。RCS 后备不支持共享短信路由。如果账户中不包含对目的地国家有效的专用发件人,则消息将失败。该服务使用原始身份优先顺序来确定要使用哪个身份。有关更多信息,请参阅 后备逻辑和优先顺序。

重要

Account-level 如果您的账户包含为不同用例注册的电话号码,则发送会带来合规风险。当 RCS 传送失败且服务恢复为 SMS 时,它可能会选择与您的消息内容不匹配的电话号码。例如,OTP 消息可能会退回到注册预约提醒的免费电话号码,这违反了该号码的注册条款。为避免这种风险,请使用基于池的发送,每个用例都有一个池。有关更多信息,请参阅 账户级发送的合规风险。

直接发送(仅限 RCS)

当您在SendTextMessage请求中指定 AWS RCS 代理 ARN 作为发起身份时, AWS 最终用户消息仅通过 RCS 发送消息。没有自动短信回退。如果 RCS 传送失败,则不会在其他频道上重试该消息。

在以下情况下使用直接发送:

  • 你想 RCS-or-nothing 送货。该消息只能通过 RCS 传送,与 SMS 传送相比,您更倾向于不进行传送。

  • 您可以在 AWS 最终用户消息之外管理 SMS 备用信息。您的应用程序独立处理备用逻辑,例如,通过检测 RCS 传送失败以及通过其他系统或提供商发送单独的 SMS。

注意

直接发送会绕过所有短信回退逻辑。如果收件人的设备或运营商不支持 RCS,则消息不会传送。对于大多数用例,建议使用基于池的发送,因为它可以提供自动短信回退,无需额外付费。

粘性发送、优先顺序和短信备用

当您通过地址池或账户级别发送消息时, AWS 最终用户消息使用粘性发送(25 小时路由优化)、发件身份优先顺序和自动短信回退来为每条消息选择最佳信道和身份。有关这些机制如何运作的完整详细信息,包括自动回退、备用期间的交货收据以及账单影响,请参阅。使用电话池进行 RCS 到 SMS 的备用操作

代码示例

以下 Python 示例演示如何使用三种发送模式中的每一种发送 RCS 消息。所有示例都使用 boto3 pinpoint-sms-voice-v2 客户端和 API。SendTextMessage

Pool-based 发送示例

以下示例通过电话池发送消息。该服务从池中选择最佳的发起身份,如果无法传送 RCS,则会自动回退到短信。

import boto3 client = boto3.client('pinpoint-sms-voice-v2') response = client.send_text_message( DestinationPhoneNumber='+12065550100', OriginationIdentity='pool-a1b2c3d4e5f6g7h8i', MessageBody='Your appointment is confirmed for tomorrow at 2:00 PM.', MessageType='TRANSACTIONAL' ) print(f"Message ID: {response['MessageId']}")

Account-level 发送示例

以下示例通过省略发起始标识在账户级别发送消息。该服务使用优先顺序从您账户中的所有可用身份中选择一个身份。

import boto3 client = boto3.client('pinpoint-sms-voice-v2') response = client.send_text_message( DestinationPhoneNumber='+12065550100', MessageBody='Your verification code is 123456.', MessageType='TRANSACTIONAL' ) print(f"Message ID: {response['MessageId']}")
重要

如果您的账户包含为不同用例注册的电话号码,则账户级发送可能会通过与您的消息内容不匹配的号码路由短信回退。使用基于池的发送,每个用例都有一个池,以避免合规风险。

直接发送示例

以下示例直接通过 AWS RCS 代理 ARN 发送消息。该消息仅通过 RCS 传送,没有 SMS 回退。

import boto3 client = boto3.client('pinpoint-sms-voice-v2') response = client.send_text_message( DestinationPhoneNumber='+12065550100', OriginationIdentity='arn:aws:sms-voice:us-east-1:123456789012:rcs-agent/rcs-a1b2c3d4', MessageBody='Welcome to our RCS channel! Reply HELP for assistance.' ) print(f"Message ID: {response['MessageId']}")
注意

如果收件人的设备或运营商不支持 RCS,则消息不会传送。未尝试回退短信。仅当您想要传 RCS-or-nothing 送或在 AWS 最终用户消息之外管理 SMS 后备时才使用此模式。

AI 代理提示发送 RCS 消息

如果您使用生成式 AI 编码助手或 AI 代理,则可以使用以下提示获取有关使用 C AWS LI 或 SDK 发送 RCS 消息的帮助。

注意

复制以下提示并将其粘贴到您的 AI 代理或编码助手中:

## RCS Messaging Assistant Prompt Help me send RCS messages using AWS End User Messaging SMS with the `pinpoint-sms-voice-v2` service. Show me exact CLI commands and Python/boto3 examples. Ask me for my details before generating any commands. **Important rules for generating commands:** - The API is `send-text-message` — the same command used for SMS. There is NO separate RCS send API. - There is NO `describe-messages` API. Do not generate it. - The boto3 method is `send_text_message` on the `pinpoint-sms-voice-v2` client. - Use the term "testing" — NOT "sandbox". **Prerequisites:** I have an existing RCS agent (created via the setup process) and a verified test device. ### Pattern 1: Direct RCS sending (simplest, good for testing) Send directly through my RCS Agent ARN. RCS-only delivery, no SMS fallback. If the recipient's device doesn't support RCS, the message is not delivered. CLI: `send-text-message --destination-phone-number <E.164> --origination-identity <agent-arn> --message-body "<text>" --message-type <TRANSACTIONAL|PROMOTIONAL>` Returns `MessageId`. ### Pattern 2: Pool-based sending (recommended for production) Send through a phone pool containing my RCS agent (and optionally SMS phone numbers for fallback). The service tries RCS first, then falls back to SMS asynchronously if no RCS signal within 25 seconds. This is NOT synchronous fallback — the SMS is sent as a separate attempt after the timeout. To set up a pool: - `create-pool --origination-identity <rcs-agent-id> --message-type TRANSACTIONAL` → returns `PoolId` - Optionally add SMS numbers: `associate-origination-identity --pool-id <id> --origination-identity <phone-number-id>` CLI: `send-text-message --destination-phone-number <E.164> --origination-identity <pool-id> --message-body "<text>" --message-type <TRANSACTIONAL|PROMOTIONAL>` ### Pattern 3: Account-level sending Send without specifying `--origination-identity`. The service auto-selects the best identity from the account. CLI: `send-text-message --destination-phone-number <E.164> --message-body "<text>" --message-type <TRANSACTIONAL|PROMOTIONAL>` **Compliance warning:** If the account has multiple RCS agents, SMS numbers, or different use cases, the service picks an identity automatically — which may not be the intended one. Use pool-based or direct sending for explicit control over which identity is used. ### Delivery verification - For testing: check the test device directly — the message appears from the branded RCS agent. - For production: configure event destinations BEFORE sending using `create-event-destination` (SNS, CloudWatch Logs, or Firehose). Event destinations do not retroactively capture events for already-sent messages. - CloudWatch metrics in `AWS/SMSVoice` namespace provide aggregate delivery statistics. ### Behavioral notes - Sticky sending: the service remembers the last successful identity per destination number for 25 hours. - Pool-based sending is recommended for production because it provides automatic SMS fallback. - All three patterns use the same `send-text-message` API — the only difference is what you pass (or don't pass) as `--origination-identity`. --- **Before generating commands, ask me for:** - Which sending pattern I want to use (direct, pool-based, or account-level) - My RCS Agent ARN - My pool ID (if using pool-based sending) - Destination phone number in E.164 format - Message type (TRANSACTIONAL or PROMOTIONAL) - Message text

送货收据处理

AWS 最终用户消息通过亚马逊 EventBridge 和配置集的事件目的地提供 RCS 消息的送达收据。送达收据表明您的消息的最终状态以及使用哪个渠道进行传送。要了解如何设置事件目的地以捕获送达收据和其他消息事件,请参阅AWS 最终用户消息 SMS 中的事件目的地。

配送状态值

以下传送状态值适用于 RCS 消息:

已交付

消息已成功传送到收件人的设备。

PENDING

该消息已被 RCS 基础设施接受,但尚未收到传送确认。消息可能仍会送达。

EXPIRED

消息未在允许的时间窗口内送达。对于带有 SMS 回退功能的 RCS 消息,此状态适用于回退发生之前的 RCS 尝试。

无法送达

消息无法传送。当收件人的设备永久无法访问或电话号码无效时,可能会发生这种情况。

REJECTED

该消息被 RCS 基础设施或运营商拒绝。这可能是由于违反内容政策或运营商级别过滤造成的。

频道归因

传送收据包括渠道归因,表明消息是通过 RCS 还是 SMS 传送。这对于了解您的配送组合和计费非常重要。

  • 当消息通过 RCS 传送时,传送收据表明 RCS 是传送渠道,并包含 AWS RCS 代理身份。

  • 当消息回退到 SMS 时,传送收据会指示 SMS 作为传送渠道,并包含用于传送的 SMS 电话号码身份。

  • 当直接发送(AWS RCS 代理 ARN)失败时,交付收据会显示 RCS 是处于失败状态的尝试信道。不会生成短信备用收据。

有关 RCS CloudWatch 指标和监控交付模式的详细信息,请参阅RCS CloudWatch 指标和监控。有关配送渠道如何影响账单的信息,请参阅RCS 计费和定价模型。