Amazon Connect Workers

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.

Secrets

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.

Other Amazon Connect fields

  • ContactFlowId: Flow in amazon connect that will be initiated.
  • InitialConnectionMessage: Configuration needed for Amazon Connect. Do not change.
    • Default: "{\"topic\":\"aws/subscribe\",\"content\":{\"topics\":[\"aws/chat\"]}}"
  • InstanceId: Instance of amazon connect.
  • Region: Region where the Amazon Connect bot is configured.
  • Secret: Cross-account role secret.

Creating an Amazon Connect worker through cli

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"
      }
    }
  },
  "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.

Creating and setting up an Amazon Connect worker with a Blueprint

  1. Create a contact flow on AWS Connect

    1. Go to the Amazon Connect console.
    2. Select ‘Contact Flows’ under ‘Routing’ on the dropdown menu on the left.
    3. Click the ‘Create contact flow’ button.
    4. Create a contact flow such as the following:
  2. Build your bot

    1. Navigate to the Bot designer and click “Create Bot”.
    2. Select the “Amazon Connect Bot” Blueprint.
    3. Enter a name for the bot. This name will be given to the flow worker bot. The bot with the connect worker will have the same name with “ConnectBot” appended to it.
    4. Enter a description, which is given to both bots.
    5. Under “Amazon Connect Configuration”, enter a region, connect instance ID, a contact flow ID, and a secret.
      • The instance ID and contact flow ID can be found in the URL of the contact flow page from earlier.
      • E.g. …/instance/123a456b-123a-456b-789c-0123456789ab/contact-flow/987z654y-987z-654y-321x-9876543210zy
    6. Build it!
  3. Test and adjust your bot

    1. Find the flow bot (not the connect bot) that was created in Bot Army and open its test page.
    2. Go to Amazon Connect and click the phone button to open a chat window.
    3. Send the bot a message through its test page.
    4. If the flow triggers a human handover, a notification will appear in the Amazon Connect chat window, prompting the user to connect to the bot, and a conversation is started.

Sample Baas for translation

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",
}

Sample baas that can be used as slash command to send an email

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,
}