View a markdown version of this page

使用 API 或 CLI 建立對外行銷活動 - Amazon Connect 客戶

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

使用 API 或 CLI 建立對外行銷活動

您可以使用 CLI AWS 或 Amazon Connect Outbound Campaigns API,以程式設計方式建立和管理對外行銷活動。本主題說明如何使用 CLI 建立 Connect Customer 對外行銷活動、定義行銷活動流程,以及參考生命週期命令。

先決條件

使用 API 或 CLI 建立行銷活動之前,請確定您有下列項目:

建立行銷活動流程

行銷活動流程會定義為每個收件人執行的動作順序。您可以使用 CreateContactFlow API 建立流程,並將流程類型設定為 CAMPAIGN。如需每個動作類型的詳細資訊,請參閱 旅程流程區塊定義

簡單流程 (不重試)

簡單流程會傳送單一通訊給每個收件人,而不檢查交付狀態。這是最簡單的流程結構:

{ "Version": "2019-10-30", "StartAction": "SendSMS", "Actions": [ { "Identifier": "SendSMS", "Type": "SendSMS", "Parameters": { "Message": { "MessageSourceType": "TEMPLATE", "TemplatedMessage": { "WisdomKnowledgeBaseArn": "arn:aws:wisdom:us-east-1:123456789012:knowledge-base/your-kb-id", "WisdomMessageTemplateArn": "arn:aws:wisdom:us-east-1:123456789012:message-template/your-kb-id/your-template-id" } }, "SourceEndpoint": { "Address": "arn:aws:connect:us-east-1:123456789012:phone-number/your-phone-number-id", "Type": "CONNECT_PHONENUMBER_ARN" } }, "Transitions": { "NextAction": "EndFlow", "Conditions": [], "Errors": [ { "NextAction": "EndFlow", "ErrorType": "NoMatchingError" } ] } }, { "Identifier": "EndFlow", "Type": "EndFlowExecution", "Parameters": {} } ] }

具有交付狀態檢查和重試的流程

對於檢查交付狀態並在失敗時重試的流程,請使用下列結構。流程會傳送通訊、等待交付接收、擷取通訊狀態,然後根據結果進行分支。

重試流程中的關鍵動作為:

  1. SendSMSSendOutboundEmailPutDialRequest - 傳送傳出通訊。

  2. Wait - 等待交付接收。

  3. GetOutboundCommunicationStatus - 擷取最新通訊的交付狀態。

  4. 比較 - 根據結果評估交付接收和分支 (例如,退信時重試、成功時結束)。

  5. EndFlowExecution - 終止流程。所有流程路徑都必須以此動作結尾。

下列範例顯示行銷活動的流程,該MANAGED行銷活動會傳送簡訊、等待交付接收、檢查狀態,並在訊息退信時透過電子郵件重試:

{ "Version": "2019-10-30", "StartAction": "SendSMS", "Actions": [ { "Identifier": "SendSMS", "Type": "SendSMS", "Parameters": { "Message": { "MessageSourceType": "TEMPLATE", "TemplatedMessage": { "WisdomKnowledgeBaseArn": "arn:aws:wisdom:us-east-1:123456789012:knowledge-base/your-kb-id", "WisdomMessageTemplateArn": "arn:aws:wisdom:us-east-1:123456789012:message-template/your-kb-id/your-sms-template-id" } }, "SourceEndpoint": { "Address": "arn:aws:connect:us-east-1:123456789012:phone-number/your-phone-number-id", "Type": "CONNECT_PHONENUMBER_ARN" } }, "Transitions": { "NextAction": "Wait", "Conditions": [], "Errors": [ { "NextAction": "EndFlow", "ErrorType": "NoMatchingError" } ] } }, { "Identifier": "Wait", "Type": "Wait", "Parameters": { "TimeLimitSeconds": "900" }, "Transitions": { "NextAction": "GetOutboundCommunicationStatus", "Conditions": [ { "NextAction": "GetOutboundCommunicationStatus", "Condition": { "Operator": "Equals", "Operands": ["WaitCompleted"] } } ], "Errors": [ { "NextAction": "EndFlow", "ErrorType": "NoMatchingError" } ] } }, { "Identifier": "GetOutboundCommunicationStatus", "Type": "GetOutboundCommunicationStatus", "Parameters": { "OutboundCommunicationIds": ["$.OutboundCommunication.Latest.Id"] }, "Transitions": { "NextAction": "Compare", "Conditions": [], "Errors": [ { "NextAction": "EndFlow", "ErrorType": "NoMatchingError" } ] } }, { "Identifier": "Compare", "Type": "Compare", "Parameters": { "ComparisonValue": "$.DeliveryReceipts['`$.OutboundCommunication.Latest.Id`'].Bounce" }, "Transitions": { "NextAction": "EndFlow", "Conditions": [ { "NextAction": "SendEmail", "Condition": { "Operator": "Exists", "Operands": [] } } ], "Errors": [ { "NextAction": "EndFlow", "ErrorType": "NoMatchingCondition" } ] } }, { "Identifier": "SendEmail", "Type": "SendOutboundEmail", "Parameters": { "EmailMessage": { "MessageSourceType": "TEMPLATE", "TemplatedMessage": { "WisdomKnowledgeBaseArn": "arn:aws:wisdom:us-east-1:123456789012:knowledge-base/your-kb-id", "WisdomMessageTemplateArn": "arn:aws:wisdom:us-east-1:123456789012:message-template/your-kb-id/your-email-template-id" } }, "FromEmailAddress": { "EmailAddress": "noreply@example.com" } }, "Transitions": { "NextAction": "EndFlow", "Conditions": [], "Errors": [ { "NextAction": "EndFlow", "ErrorType": "NoMatchingError" } ] } }, { "Identifier": "EndFlow", "Type": "EndFlowExecution", "Parameters": {} } ] }
重要
  • 如果您的流程使用多種管道類型 (例如,簡訊和電子郵件),請在建立行銷活動時將所有管道包含在 --channel-subtype-config 參數中。

  • 對於用於MANAGED檢查交付狀態類型的行銷活動的流程,所需的動作序列為:等待GetOutboundCommunicationStatus比較Wait 動作會在指定的持續時間內暫停流程,讓交付接收有時間到達。GetOutboundCommunicationStatus 動作會擷取交付狀態。根據結果Compare的動作分支。

  • 中的 OutboundCommunicationIds 參數GetOutboundCommunicationStatus必須參考 $.OutboundCommunication.Latest.IdCompare 動作中的交付接收參考必須使用相同的金鑰。例如:$.DeliveryReceipts['`$.OutboundCommunication.Latest.Id`'].Bounce

  • MANAGED 使用語音管道的行銷活動需要 PutDialRequest動作dialCriteriaRules

    { "Identifier": "PutDialRequest", "Type": "PutDialRequest", "Parameters": { "dialCriteriaRules": [ { "type": "CheckSegmentMembershipForCustomerProfile", "segmentArn": "arn:aws:profile:us-east-1:123456789012:domains/your-domain/segments/your-segment" } ] }, ... }

建立行銷活動流程版本

建立行銷活動流程之後,您必須建立流程的版本。建立行銷活動時,需要版本控制的流程 ARN。使用 CreateContactFlowVersion API 建立版本。

版本化流程 ARN 包含版本尾碼。例如:arn:aws:connect:us-east-1:123456789012:instance/your-instance-id/contact-flow/your-flow-id:1

如需詳細資訊,請參閱 create-contact-flow-version CLI 參考

建立對外行銷活動

使用 create-campaign命令來建立行銷活動。下列範例會使用無代理程式傳出模式建立 SMS 行銷活動:

aws connectcampaignsv2 create-campaign \ --name "My SMS Campaign" \ --connect-instance-id "your-instance-id" \ --type MANAGED \ --connect-campaign-flow-arn "arn:aws:connect:us-east-1:123456789012:instance/your-instance-id/contact-flow/your-flow-id:1" \ --source '{"customerProfilesSegmentArn": "arn:aws:profile:us-east-1:123456789012:domains/your-domain/segments/your-segment"}' \ --channel-subtype-config '{ "sms": { "outboundMode": {"agentless": {}}, "defaultOutboundConfig": { "connectSourcePhoneNumberArn": "arn:aws:connect:us-east-1:123456789012:phone-number/your-phone-number-id", "wisdomTemplateArn": "arn:aws:wisdom:us-east-1:123456789012:message-template/your-kb-id/your-template-id" } } }' \ --schedule '{"startTime": "2026-07-01T09:00:00", "endTime": "2026-07-01T17:00:00", "refreshFrequency": "PT30M"}' \ --communication-time-config '{ "localTimeZoneConfig": {"defaultTimeZone": "America/New_York"}, "sms": { "openHours": { "dailyHours": { "MONDAY": [{"startTime": "T09:00", "endTime": "T17:00"}], "TUESDAY": [{"startTime": "T09:00", "endTime": "T17:00"}], "WEDNESDAY": [{"startTime": "T09:00", "endTime": "T17:00"}], "THURSDAY": [{"startTime": "T09:00", "endTime": "T17:00"}], "FRIDAY": [{"startTime": "T09:00", "endTime": "T17:00"}] } } } }' \ --region us-east-1

成功時,命令會傳回行銷活動 ID 和 ARN:

{ "id": "campaign-id", "arn": "arn:aws:connect-campaigns:us-east-1:123456789012:campaign/campaign-id" }
注意

--type 參數指定行銷活動類型。將 MANAGED用於對外行銷活動。使用 JOURNEY進行多步驟、多頻道的旅程,請參閱 視覺化旅程建置器

注意

您也可以指定 --communication-limits-override來控制可以聯絡收件人的次數。如需參數的完整清單,請參閱 create-campaign CLI 參考

若要管理行銷活動生命週期操作 (開始、停止、暫停、繼續、刪除),請參閱 AWS connectcampaignsv2 的 CLI 參考