

# Specify variables for certain parameters when creating or managing rules using Amazon Connect APIs
<a name="contact-lens-variable-injection"></a>

When you create or manage rules programmatically using Amazon Connect APIs (such as [CreateRule](https://docs.aws.amazon.com/connect/latest/APIReference/API_CreateRule.html) or [UpdateRule](https://docs.aws.amazon.com/connect/latest/APIReference/API_UpdateRule.html)), you can specify variables for certain parameters. The variables are resolved at runtime when the action is triggered, based on the value of the [EventSourceName](https://docs.aws.amazon.com/connect/latest/APIReference/API_RuleTriggerEventSource.html) parameter. 

For example, let's say you're setting up a task action and you want to add more context. Following is an example of how you could use variable injections to include the ID of the contact and the ID of the agent in the `Description` field of the task: 
+ Customer is unhappy about the phone call. A swear word was detected during the conversation with agent `$.ContactLens.PostCall.Agent.AgentId` in the contact `$.ContactLens.PostCall.ContactId`

When the action is triggered, his string would resolve to "Customer is unhappy about the phone call. A swear word was detected during a conversation with agent 12345678-1234-1234-1234-EXAMPLEID012 in the contact 87654321-1234-1234-1234-EXAMPLEID345"

The following table lists each event source, and the JSONPath to use for fields that support variable injection. 


| EventSourceName | JSONPath Reference | 
| --- | --- | 
|  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  | 