Type: Amazon Connect Worker
An Amazon Connect worker will route a conversation to a live agent in Amazon Connect. If messages come in outside of the configured business hours automated messages from connect will respond to the user. A connect worker can be created through the CLI or as part of a bot through the Amazon Connect Blueprint.
Note: Amazon Connect workers cannot be interacted with directly by users, they must be transferred to an agent on Amazon Connect through a flow worker first.
An AWS cross-account role is required in order to access Amazon Connect. Please see cross-account roles for more information.
Below is an example policy containing the required permissions which should be attached to the cross account role to allow the AWS connect worker to function correctly.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"connect:UpdateContactAttributes",
"connect:StartChatContact",
"connect:GetCurrentMetricData"
],
"Resource": [
"arn:aws:connect:${AWS::Region}:${AWS::AccountId}:instance/${ConnectInstanceId}/contact/*",
"arn:aws:connect:${AWS::Region}:${AWS::AccountId}:instance/${ConnectInstanceId}/contact-flow/${ContactFlowId}",
"arn:aws:connect:${AWS::Region}:${AWS::AccountId}:instance/${ConnectInstanceId}/queue/*"
]
}
]
}
You should replace the values surrounded by ${} with values relative to your aws account and region. Where the placeholder values in the policy above are as follows:
${AWS::Region} - is the region your AWS Connect instance is deployed and the region you are creating the cross account role in.
${AWS::AccountId} - is your AWS Account Id where the AWS Connect instance is deployed and the account you are creating the cross account role in.
${ConnectInstanceId} - is the AWS Connect instance id the worker is interacting with.
${ContactFlowId} - is the contact flow id within the connect instance.
"{\"topic\":\"aws/subscribe\",\"content\":{\"topics\":[\"aws/chat\"]}}"
Save this json to a file and create a worker using the cli command sb-cli worker create file.json
. Note to replace the values for Secret, Region, InstanceId, InitialConnectionMessage, and ContactFlowId.
{
"Data": {
"ContactFlowId": "GUID for Contact Flow ID",
"InitialConnectionMessage": "{\"topic\":\"aws/subscribe\",\"content\":{\"topics\":[\"aws/chat\"]}}",
"InstanceId": "GUID for Connect Instance ID",
"Region": "us-east-1",
"Secret": "srn:vault::ORG:aws-cross-account-role:SECRETALIAS",
"ShortLinkConfig": {
"Config": {
"Api": "https://squeeze.prod.servismatrix.com/standard",
"ApiKey": "srn:vault::ORG:secret:squeeze"
},
"Type": "Squeeze"
},
"EgressTranslationConfig": {
"ConnectorAlias": "EgressTranslateBaas",
"SourceLanguageCode": "en",
"TargetLanguageCode": "es"
},
"IngressTranslationConfig": {
"ConnectorAlias": "IngressTranslateBaas",
"SourceLanguageCode": "es",
"TargetLanguageCode": "en"
},
"SlashCommands": {
"/welcome": {
"actions": [{
"type": "content",
"value": "welcomewithname"
},
{
//Another valid botnet action
}
],
"description": "A welcome message with the users name"
}
},
"AutoDisconnectEvents": [
{
"Description": "Timer to send a message after 10 seconds",
"SecondsAfterAgentMessage": 10,
"Type": "WARNING",
"UserMessage": "It has been a while since we heard from you. We will disconnect your chat after 20 seconds of inactivity",
"AgentMessage": "It has been 10 sec since the last heard from the user. After 20 seconds of inactivity, the chat will disconnect"
},
{
"Description": "Timer to send a message after 20 seconds",
"SecondsAfterAgentMessage": 20,
"Type": "DISCONNECT",
"UserMessage": "The session has been disconnected due to inactivity",
"AgentMessage": "The session has been disconnected due to inactivity"
}
],
},
"Description": "Worker that routes to livechat agents",
"Enabled": true,
"Name": "ConnectOne",
"Type": "amazon-connect-worker"
}
Once you have created the worker using the CLI, it will return an ID for you. You need to then update/create a bot and place the filter worker at the top with the id and the type of amazon-connect-worker
.
Create a contact flow on AWS Connect
Build your bot
Test and adjust your bot
Below is an example of the inbound translate:
{
"Persona": "/images/blueprints/amazon-comprehend.svg",
"Headers": {
"content-type": "application/json"
},
"Organization": "shane",
"Description": "Translate Language",
"RequestMapping": {
"TargetLanguageCode": {
"type": "requestBody",
"requestBodyPath": "$.TargetLanguageCode",
"inputPath": "$.TargetLanguageCode"
},
"Text": {
"type": "requestBody",
"requestBodyPath": "$.Text",
"inputPath": "$.Text"
},
"SourceLanguageCode": {
"type": "requestBody",
"requestBodyPath": "$.SourceLanguageCode",
"inputPath": "$.SourceLanguageCode"
}
},
"ResponseMapping": {},
"Type": "aws-sdk",
"Body": {},
"Created": 1585215907115,
"Credentials": "srn:vault::YOURORG:secretdoc:translatesecret",
"Method": "translateText",
"Endpoint": "Translate",
"Alias": "IngressTranslateBaas",
}
This requires the customer email to be set in context.
The example slash command would be:
"SlashCommands": {
"/email": {
"description": "Send an email to the customer",
"actions": [
{
"type": "executeApi",
"value": "sendEmail"
}
]
}
}
Baas Example:
{
"Persona": "/images/blueprints/Amazon-Simple-Email-Service-SES.png",
"Organization": "shane",
"Description": "!Ref:::Parameters.baasDescription",
"RequestMapping": {
"Email": {
"type": "requestBody",
"requestBodyPath": "$.Destination.ToAddresses[0]",
"inputPath": "$.email"
}
},
"ResponseMapping": {},
"Type": "aws-sdk",
"Body": {
"Message": {
"Body": {
"Text": {
"Data": "body of the email"
}
},
"Subject": {
"Data": "Subject here"
}
},
"Source": "YOUR_SOURCE@EMAIL.HERE"
},
"Created": 1585815972627,
"Credentials": "srn:vault::YOURORG:cross-account-role:somesecret",
"Method": "sendEmail",
"Endpoint": "SES",
"Alias": "sendEmail",
"Updated": 1585818222020,
}
Adding AutoDisconnectEvent to your connect worker allows you to send messages and disconnect users N seconds after the agent has sent the customer a message.
"AutoDisconnectEvents": [
{
"Description": "Timer to send a message after 10 seconds",
"SecondsAfterAgentMessage": 10,
"Type": "WARNING",
"UserMessage": "It has been a while since we heard from you. We will disconnect your chat after 20 seconds of inactivity",
"AgentMessage": "It has been 10 sec since the last heard from the user. After 20 seconds of inactivity, the chat will disconnect"
},
{
"Description": "Timer to send a message after 20 seconds",
"SecondsAfterAgentMessage": 20,
"Type": "DISCONNECT",
"UserMessage": "The session has been disconnected due to inactivity",
"AgentMessage": "The session has been disconnected due to inactivity"
}
]
Adding Failover Region Configuration to your worker allows you to specify additional Amazon Connect configurations for Amazon Connect instances in other AWS regions which can be used in the event of a failover.
"FailoverRegionConfig": {
"ActiveFailoverRegion": "us-west-2-oregon",
"FailoverRegions": [
{
"Secret": "srn:vault::acme:aws-cross-account-role:call-deflection-failover",
"Region": "us-west-2",
"InstanceId": "618c435d-1330-45a5-9834-285c5422de81",
"ContactFlowId": "8949fcc8-9d49-4e97-8bb5-eba4a847f1a1",
"Name": "us-west-2-oregon",
"QueueId": "4f565c31-f091-4114-9ca0-c4751a166bf8"
},
{
"Secret": "srn:vault::acme:aws-cross-account-role:call-deflection-failover",
"Region": "us-west-3",
"InstanceId": "6gdtuyjyc435d-1330-45a5-9834-285c5h22de81",
"ContactFlowId": "894sdgrfcc8-9d49-4e97-8bb5-ebf4a847f1a1",
"Name": "us-west-3-oregon",
"QueueId": "5f565c31-f091-4114-9ca0-c4751a166bf8"
}
]
}
The properties are as follows:
ActiveFailoverRegion: Optional, if provided this must match the Name of one of the failover region configurations to start using that failover configuration. If the Name
does not match any of the failover region configuration names the primary region configuration will be used.
FailoverRegions: A list of failover region configurations which the worker can failover to.
To activate a failover region set ActiveFailoverRegion to match the Name of one of the failover regions in the FailoverRegions list and update your worker. Once the worker is updated and the ActiveFailoverRegion points to a valid failover region your worker will start to communicate with the failover region.
To disable a failover region remove the ActiveFailoverRegion attribute from your worker and update the worker. Once the worker has been updated, your worker will being to communicate with the primary region Amazon Connect instance. In this case “primary region” refers to the amazon connect configuration at the root level of your worker configuration.
When you return to the original Bot after being transferred to a bot containing an Amazon Connect Worker there are certain items available in context
Contains the reason the session with the connect worker has ended. Current values:
Contains the last known agent in the conversation in the form of
{ AgentName: "Agent" }
This is the ID of the participant as Amazon Connect knows the user. This can be used to find a conversation in the Amazon Connect interface
Contains a boolean value determining whether the conversation was auto disconnected - true if so, false otherwise.
If you want to change the default name that comes out to agent on connect for the customer. You need to set the name in context. What ever name
is set to in context will appear as the customers name and if no name is set, it defaults to the bot name. So say you wanted to use something like name-reference
you can do something like follows
msg.payload.user.name = msg.payload.context.FirstName + ' - ' + msg.payload.context.Reference
return msg;
name
to msg.payload.user.name
this will then make the name appear in connect like botty - sb2314211