本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
发送 RCS 消息
AWS 最终用户消息传送使用相同SendTextMessage的 API 进行 RCS 和短信传送。服务如何路由您的消息取决于您在请求中指定的来源身份。您可以通过电话池(推荐)、账户级别或直接通过 AWS RCS 代理 ARN 发送消息。
本节介绍三种发送模式、如何解释送货收据,并提供代码示例。有关粘性发送、发起身份优先顺序和自动短信回退的详细信息,请参阅。使用电话池的 RCS 到 SMS 回退有关管理 AWS RCS 代理的详细信息,请参阅管理 RCS 代理。
发送模式
AWS 最终用户消息支持三种发送 RCS 消息的模式。每种模式都决定了服务如何选择发端身份以及是否提供自动短信回退。
| 模式 | 工作原理 | 短信回退 | 何时使用 |
|---|---|---|---|
| 基于池(推荐) | 将池 ID 指定为发起标识。该服务从池中选择最佳身份。 | 是 | 所有用例。通过合规性安全路由提供自动频道选择和短信回退。 |
| 账户级别 | 省略起源身份。该服务从您账户中的所有可用身份中进行选择。 | 是 | 只需一个用例即可完成简单设置。不建议有多个用例的账户使用。 |
| 直接发送 | 指定 AWS RCS 代理 ARN 作为发起身份。该消息仅通过 RCS 发送。 | 否 | RCS-or-nothing 用例,或者当您在 AWS 最终用户消息之外管理 SMS 回退时。 |
基于池的发送(推荐)
所有 RCS 用例都推荐使用基于池的发送方法。当您在SendTextMessage请求中指定池 ID 作为发起身份时, AWS 最终用户消息将根据目标、频道可用性和粘性发送历史记录从池中选择最佳的发起身份。
如果池中同时包含 AWS RCS 代理和 SMS 电话号码,则该服务会先尝试交付 RCS。如果 RCS 传送失败,则该服务会自动使用同一地址池中的电话号码回退到 SMS。由于池中的所有身份都是针对同一个用例注册的,因此备用消息始终由相应的号码发送。
有关使用 AWS RCS 代理创建和配置池的详细信息,请参阅使用电话池的 RCS 到 SMS 回退。
账户级发送
当您在SendTextMessage请求中省略原始身份时,“ AWS 最终用户消息” 会从您账户中的所有可用身份中选择一个发起身份。该服务使用发起身份优先顺序来确定要使用哪个身份。有关更多信息,请参阅 回退逻辑和优先顺序。
重要
如果您的账户包含针对不同用例注册的电话号码,则账户级别的发送会带来合规风险。当 RCS 传送失败并且服务回退到短信时,它可能会选择与您的消息内容不匹配的电话号码。例如,OTP 消息可能会回退到注册预约提醒的免费电话号码,这违反了该号码的注册条款。为避免这种风险,请使用基于池的发送,每个用例只有一个池。有关更多信息,请参阅 账户级发送存在合规风险。
直接发送(仅限 RCS)
当SendTextMessage您在请求中指定 AWS RCS 代理 ARN 作为发起身份时 AWS ,最终用户消息仅通过 RCS 发送消息。没有自动短信回退功能。如果 RCS 传送失败,则不会在其他频道上重试该消息。
在以下情况下使用直接发送:
-
你想要 RCS-or-nothing送货。消息只能通过 RCS 传送,您更喜欢不发送短信。
-
您可以在 “ AWS 最终用户消息” 之外管理 SMS 回退。您的应用程序独立处理回退逻辑,例如,通过检测 RCS 传送失败并通过不同的系统或提供商发送单独的 SMS。
注意
直接发送会绕过所有短信回退逻辑。如果收件人的设备或运营商不支持 RCS,则不会传送消息。对于大多数用例,建议使用基于池的发送,因为它可以自动回退短信,无需支付额外费用。
粘性发送、优先顺序和短信回退
当您通过池或账户级别发送消息时, AWS 最终用户消息使用粘性发送(25 小时的路由优化)、发件身份优先顺序和自动短信回退来为每条消息选择最佳渠道和身份。有关这些机制的工作原理(包括自动回退、回退期间的送货收据以及计费影响)的完整详细信息,请参阅。使用电话池的 RCS 到 SMS 回退
代码示例
以下 Python 示例演示了如何使用三种发送模式中的每一种发送 RCS 消息。所有示例都使用 boto3 pinpoint-sms-voice-v2 客户端和 API。SendTextMessage
基于池的发送示例
以下示例通过电话池发送一条消息。该服务会从池中选择最佳的发起身份,如果无法传送 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']}")
账户级发送示例
以下示例通过省略原始身份在账户级别发送消息。该服务使用优先顺序从您账户中的所有可用身份中选择一个身份。
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 传送,没有短信回退。
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 最终用户消息之外管理短信回退时,才使用此模式。
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 最终用户消息提供通过 Amazon 的 RCS 消息的送达回执 EventBridge 和配置设置的事件目的地。送达收据会显示您的邮件的最终状态以及使用哪个渠道进行投递。要了解如何设置事件目的地以捕获送达回执和其他消息事件,请参阅AWS 最终用户消息 SMS 中的事件目的地。
配送状态值
以下传送状态值适用于 RCS 邮件:
- 已交付
-
消息已成功传送到收件人的设备。
- PENDING
-
该消息已被 RCS 基础设施接受,但尚未收到送达确认。消息可能仍会送达。
- EXPIRED
-
消息未在允许的时间窗口内送达。对于带有 SMS 回退功能的 RCS 消息,此状态适用于回退之前的 RCS 尝试。
- 无法送达
-
消息无法传送。当收件人的设备永久无法访问或电话号码无效时,就会发生这种情况。
- REJECTED
-
该消息被 RCS 基础设施或运营商拒绝。这可能是由于违反内容政策或运营商级别的过滤而发生的。
频道归因
送达收据包括渠道归因,表明消息是通过 RCS 还是通过 SMS 传送的。这对于了解您的配送组合和计费非常重要。
-
通过 RCS 传送消息时,传送收据会显示 RCS 为传递渠道,并包含 AWS RCS 代理身份。
-
当消息回退到 SMS 时,传送收据会指示 SMS 为传送渠道,并包含用于传送的 SMS 电话号码身份。
-
当直接发送(AWS RCS Agent ARN)失败时,传送收据会显示 RCS 是处于失败状态的尝试通道。不会生成任何短信备用回执。
有关 RCS CloudWatch 指标和监控交付模式的详细信息,请参阅RCS CloudWatch 指标和监控。有关配送渠道如何影响账单的信息,请参阅RCS 计费和定价模型。