Amazon Connect Contact Flows
Sample Inbound Flow
This is a sample contact flow to be used for inbound chat contacts, to properly set up the records in Salesforce required to present the contact for acceptance by agents working in Omni-Channel, and for the messages exchanged by participants to be ingested into Salesforce. The required elements of this contact flow are:
- The Set contact attributes block, to set the attribute channelAddressIdentifier to the channel address identifier for the Salesforce messaging channel (created using Chat Channel Definition AWS SCC) to which this contact flow will route messaging contacts. Please ensure you have updated the value set by this block to the channel address identifier for the Salesforce messaging channel you would like to use.
- The Invoke AWS Lambda block (Execute create messaging session function) which invokes the CreateMessagingSessionFunction Lambda to create records in Salesforce representing the messaging session.
- The only inputs needed by the Lambda function are the channel address identifier, which was set as a contact attribute by the Set contact attributes block encountered earlier, and the contact ID, which is automatically provided by Amazon Connect as part of the input to the Lambda invocation.
- If you have an identifier available that is unique to the customer who initiated the chat contact (e.g. a GUID or an email address), you can set it as a contact attribute with the key clientId before this Invoke AWS Lambda block, or pass it as a contact attribute in the parameters of your StartChatContact API request. Any future messaging sessions initiated by the same customer will be automatically associated with this identifier in Salesforce, and agents will be able to see messages from past messaging engagements with the customer in their Salesforce transcript.
- When this function succeeds, it returns three values, which are stored as contact attributes:
- conversationIdentifier, the conversation identifier in Salesforce for the newly-created Conversation record that will represent this messaging contact
- workItemId, the Salesforce record identifier for the MessagingSession record that will represent the work item in Omni-Channel ultimately offered to agents for acceptance
- source, which will be set to the value SCCAC and is used to mark the contact as originating from SCC-AC
- The Invoke AWS Lambda block (Execute routing function) which invokes the RoutingFunction Lambda with the parameter routingType set to the value Initial
- By default, contacts will be routed in Omni-Channel using the method configured on the Salesforce messaging channel, if any (i.e. Omni-Flow or Omni-Queue)
- It’s possible to override the configuration on the messaging channel to use a custom Omni-Flow or route to a custom Omni-Queue, by adding additional parameters to this Invoke AWS Lambda block. Refer to the section (Optional) Configure advanced routing overrides in the contact flow for more details.
- If the contact was routed using an Omni-Flow ending in a Route Work action (to a queue that is mapped in Salesforce to a queue in the Amazon Connect instance), or using an Omni-Queue that is mapped in Salesforce to a queue in the Amazon Connect instance, this function will return a value with key externalQueueId (available in the External namespace) containing the ARN of the mapped target queue on the Amazon Connect side.
- If creating a custom inbound contact flow, you should replicate the behavior of the sample inbound flow, which uses a Set working queue block to set the working queue to the queue returned from the routing process as the externalQueueId.
- The Set working queue block, with the queue specified By queue and Set dynamically, using the Namespace External and the Key externalQueueId
- If your messaging channel is not configured in Salesforce with a routing mechanism which will resolve to a queue mapped to a corresponding queue in the Amazon Connect instance (either a mapped Omni-Queue, or an Omni-Flow ending with a Route Work action targeting a mapped Omni-Queue), you can either change this block to manually set the Amazon Connect queue via which the contact should be routed, or add a fallback from the Error branch to another Set working queue block, which will be used in case the Salesforce routing process does not return an Amazon Connect queue to be used for the contact.
- The Transfer to queue block, which will enqueue the contact to the target Amazon Connect queue.
Important: if either of the Invoke AWS Lambda blocks fail (error branch), it won’t be possible for the contact to be offered to agents in Omni-Channel, and the contact should be disconnected. If creating a custom inbound contact flow in Amazon Connect for SCC-AC messaging contacts, you should follow the same pattern as in the example flow to surround the Invoke AWS Lambda blocks with looping constructs, to allow the API calls to be retried multiple times before disconnecting the contact.
Sample Agent Transfer Flow
This is a sample contact flow to be used for agent Quick Connects, for agent-to-agent transfers initiated from the agent messaging UI in Salesforce. The required elements of this contact flow are:
- The Invoke AWS Lambda block (Execute routing function) which invokes the RoutingFunction Lambda with the parameter routingType set to the value Transfer (timeout should be the maximum allowed)
- If this Lambda invocation fails (error branch), it won’t be possible for the transfer to succeed, and the contact should be disconnected. If desired, you can add a loop with a preset number of retries around the Lambda invocation block so it will be attempted several times before disconnecting the contact.
- The Set working queue block, with the queue specified By agent and Set dynamically, using the Namespace Agent and the Key User name.
- The Transfer to queue block, which will perform the actual transfer to the target agent.
Sample Queue Transfer Flow
This is a sample contact flow to be used for queue Quick Connects, for agent-to-queue transfers initiated from the agent messaging UI in Salesforce. The required elements of this contact flow are:
- The Invoke AWS Lambda block which invokes the RoutingFunction Lambda with the parameter routingType set to the value Transfer
- If this Lambda call fails (error branch), it won’t be possible for the transfer to succeed, and the contact should be disconnected. If desired, you can add a loop with a preset number of retries around the Lambda invocation block so it will be tried several times before disconnecting the contact.
- The Transfer to queue block, which will perform the actual transfer to the target queue. (The target queue will already have been set as the working queue by the transfer process in Amazon Connect, as part of initiating the transfer flow).
Sample Transcription Subflow with Contact Lens
This is a sample contact subflow that demonstrates how to enable Contact Lens chat analytics for a chat contact. The required element of this subflow is the Set recording and analytics behavior block, configured with the Chat > Enable chat analytics option enabled. This option will enable ML-based chat analytics for post-contact and real-time scenarios for the current chat contact. Please note that chat analytics features require chat transcripts to be enabled for this Amazon Connect instance from the Amazon Connect AWS management console.
Sample Omni-Channel Subflow - Task Routing
This is a sample contact flow that can be used as part of the SCC-AC unified routing feature for Case records in Salesforce. If the Case record in scope for unified routing was assigned to an Omni-Queue that is mapped to a corresponding queue in the Amazon Connect instance, the attribute queueId will be populated on the corresponding task contact created in Amazon Connect, with the value as the ARN of the mapped queue in the Amazon Connect instance. If the Case record was assigned directly to a Salesforce user, or to an Omni-Queue that is not mapped to a queue in the Amazon Connect instance, the attribute will not be set.
If you plan to route Case records in Salesforce using an Omni-Queue mapped to a queue in the Amazon Connect instance, you can use a Check contact attributes block to validate whether the queueId attribute is set; if so, you can use the attribute with a Set working queue block to dynamically set the Amazon Connect queue to use for routing the Case record. Otherwise, or in cases where the queueId contact attribute is not set, you can use a Set working queue block that will manually specify the Amazon Connect queue to use for routing the Case record.
The other attributes that will automatically be set on the task contact are:
- workItemId, whose value will be the Salesforce record ID for the associated Case record
- serviceChannelId, whose value will be the Salesforce ID of the ServiceChannel supporting Case records that was used to route the case in Salesforce
- externalRouting, whose value will be true to indicate that the task contact was created by the unified routing feature
- groupId, whose value will be the Salesforce record ID of the Case record’s current owner (the ID of the Salesforce user, if the case was assigned directly to a user, or the Salesforce queue ID, if the case was assigned to an Omni-Queue)
The required elements of this contact flow are:
- Set working queue block/s, which will either set the working queue to the value of the contact attribute queueId or to a manually-specified queue in the Amazon Connect instance.
- A Transfer to queue block, which will enqueue the contact to be routed to an agent staffed on the desired queue. Once the contact is routed to an agent by Amazon Connect, the corresponding Case record will be presented for acceptance by the agent in Omni-Channel.