

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

# 在使用 Amazon Connect API 建立或管理規則時指定特定參數的變數
<a name="contact-lens-variable-injection"></a>

當您使用 Amazon Connect API，例如，[CreateRule](https://docs.aws.amazon.com/connect/latest/APIReference/API_CreateRule.html) 或 [UpdateRule](https://docs.aws.amazon.com/connect/latest/APIReference/API_UpdateRule.html)，以程式設計方式建立或管理規則時，您可以為某些參數指定變數。這些變數會在執行期根據 [EventSourceName](https://docs.aws.amazon.com/connect/latest/APIReference/API_RuleTriggerEventSource.html) 參數的值，在觸發動作時解析。

例如，假設您正在設定任務動作，而且想要新增更多內容。下列範例說明如何使用變數注入包含聯絡的 ID 和客服人員在任務 `Description` 欄位中的 ID：
+ 客戶對電話通話不滿意。客服人員 `$.ContactLens.PostCall.Agent.AgentId` 與聯絡 `$.ContactLens.PostCall.ContactId` 的對話中偵測到髒話

觸發動作時，他的字串將解析為「客戶對電話通話不滿意」。在與客服人員 12345678-1234-1234-1234-EXAMPLEID012 進行聯絡 87654321-1234-1234-1234-EXAMPLEID345，在對話中偵測到髒話

下表列出了每個事件來源，以及用於支援變量注入欄位的 JSONPath。


| EventSourceName | JSONPath 參考 | 
| --- | --- | 
|  OnPostCallAnalysisAvailable  |  \$1.ContactLens.PostCall.ContactId \$1.ContactLens.PostCall.Agent.AgentId \$1.ContactLens.PostCall.Queue.QueueId  | 
|  OnRealTimeCallAnalysisAvailable  |  \$1.ContactLens.RealTimeCall.ContactId \$1.ContactLens.RealTimeCall.Agent.AgentId \$1.ContactLens.RealTimeCall.Queue.QueueId  | 
|  OnPostChatAnalysisAvailable  |  \$1.ContactLens.PostChat.ContactId \$1.ContactLens.PostChat.Agent.AgentId \$1.ContactLens.PostChat.Queue.QueueId  | 
|  OnSalesforceCaseCreate  |  \$1.ThirdParty.Salesforce.CaseCreate.CaseNumber \$1.ThirdParty.Salesforce.CaseCreate.Name \$1.ThirdParty.Salesforce.CaseCreate.Email \$1.ThirdParty.Salesforce.CaseCreate.Phone \$1.ThirdParty.Salesforce.CaseCreate.Company \$1.ThirdParty.Salesforce.CaseCreate.Type \$1.ThirdParty.Salesforce.CaseCreate.Reason \$1.ThirdParty.Salesforce.CaseCreate.Origin \$1.ThirdParty.Salesforce.CaseCreate.Subject \$1.ThirdParty.Salesforce.CaseCreate.Priority \$1.ThirdParty.Salesforce.CaseCreate.CreatedDate \$1.ThirdParty.Salesforce.CaseCreate.Description  | 
|  OnZendeskTicketCreate  |  \$1.ThirdParty.Zendesk.TicketCreate.Id \$1.ThirdParty.Zendesk.TicketCreate.Priority \$1.ThirdParty.Zendesk.TicketCreate.CreatedAt  | 
|  OnZendeskTicketStatusUpdate  |  \$1.ThirdParty.Zendesk.TicketStatusUpdate.Id \$1.ThirdParty.Zendesk.TicketStatusUpdate.Priority \$1.ThirdParty.Zendesk.TicketStatusUpdate.CreatedAt  | 