This demo explains how you can use Amazon Chime SDK and Amazon Connect to develop a video enabled contact center. Currently, Amazon Connect provides a great service to develop a chat and voice-based contact center. Using Amazon Chime SDK, you can enhance the current support experience by enabling video meeting between the agent and the customer. In this demo, you get the information on how to use Amazon Connect with Amazon Chime SDK to develop a video enabled contact center.
The demo has a customer application that uses the pre-built customer chat widget provided by Amazon Connect and a customized agent CCP application that uses Amazon Connect Streams API in-order to subscribe to the events which provide the agent and customer state.
Note: Setting up and running the Amazon Chime SDK and the Amazon Connect integration demo may incur extra charges in your AWS account.
This bot is needed for the contact flow (Chime Connect Integration flow.json
). This bot helps in branching the Amazon Connect contact flow decision making when the customer wants to do a video enabled chat or just simple chat.
- Goto Amazon Lex.
Please use Lex V1 console. You can change to V1 console by clicking 'Return to the V1 console', if AWS Management console shows you V2 UI by default.
- If you have never created any Amazon Lex bot, then click on Get Started → Click Cancel (This is needed to go to home page)
- You should see the Amazon Lex home page with Create and Actions buttons and all the created Amazon Lex bots
- Click Actions → Import bot → Upload the zip file from
/lexbot/
→ Click Import - If it asks for overwriting intents click overwrite and the StartVideoCall Amazon Lex bot gets imported in NOT_BUILT status
- Click on StartVideoCall Amazon Lex bot → Click Build and then Publish (In the top right corner of your page)
- If it asks you for alias put StartVideoCall as alias and click Publish
- Follow Amazon Connect Create Instance
- In Step 1: Identity Management, choose Store users within Amazon Connect
- Provide Access URL as https://
<instance_alias_name>
.awsapps.com/connect/home
- Provide Access URL as https://
- In Step 2: Administrator, choose add new admin. This admin is required when you run the Agent CCP application for login purposes
- Click on Create instance
- Goto Amazon Connect
- Click on the instance alias for the above created Amazon connect instance
- On the left-hand side panel click on Contact flows
- Under Amazon Lex, select StartVideoCall against Bot and click on Add Lex Bot
- Goto Amazon Connect
- Click on the Access URL to login on the Amazon connect instance you created; a Dashboard is displayed once logged in successfully
- Check for Create contact flows, and click on View contact flows
- Click on the
Create contact flow
→ SelectImport flow (beta)
from dropdown. Import the contact flow by navigating to/contact-flow/Chime Connect Integration flow.json
in this repository. Now you should have an Amazon Connect contact flow named Chime Connect Integration Flow, with Get Customer Input block having a StartVideoCall Amazon Lex bot attached to it. - Click Save → Publish
Follow Amazon Connect Chat UI Example GitHub to create a simple website that enables customer to start chat with pre-built widget.
- Start with Step 2, In step 2, click on Launch Stack button against
us-east-1
region. It creates asyncCustomerChatUX AWS CloudFormation stack. - You can skip the Testing Steps for the purpose of this demo.
- In Adding this chat widget to your website section
- In step 1, update the header "Access-Control-Allow-Origin" to have value "http://localhost:9000" in
buildSuccessfulResponse
andbuildResponseFailed
functions in theasyncCustomerChatUX-InitiateChatLambda-*
AWS Lambda function created from the AWS CloudFormation template. - For step 2 do only this, download the
amazon-connect-chat-interface.js
from the Amazon Simple Storage Service (Amazon S3) bucket created by the asyncCustomerChatUX AWS CloudFormation stack. Add downloaded file to/customer/public/
. It's the minified JavaScript source file developed and provided by Amazon Connect to handle the chat functionality in the customer chat widget. - Skip Step 3 and 4.
- In step 1, update the header "Access-Control-Allow-Origin" to have value "http://localhost:9000" in
Navigate to /customer/
- Update the
API_GATEWAY_ENDPOINT
,CONTACT_FLOW_ID
andINSTANCE_ID
in/customer/src/ConnectChatInterfaceConfig.js
- Update
AWS_REGION
if needed. - Get the
API_GATEWAY_ENDPOINT
from output tab once you create theasyncCustomerChatUX
AWS CloudFormation template stack. - You can get the
CONTACT_FLOW_ID
andINSTANCE_ID
when you open yourChime Connect Integration Flow
contact flow in Amazon Connect instance, check the URL in browser. The URL will have → instance/{instanceId}/contact-flow/{contactId}.
- Update
- Check if
amazon-connect-chat-interface.js
file is added to/customer/public
folder - Open terminal, navigate to
/customer/
directory- Install NPM dependencies:
npm install
- Build the app:
npm run build
- Start the server:
npm run start
- Install NPM dependencies:
- Step 3 opens http://localhost:9000 in your browser
- Goto Amazon S3
- Click Create bucket
- Bucket name:
<unique Amazon S3 bucket name>
- Region:
us-east-1
- Keep everything rest as is and click on Create bucket
- Goto created Amazon S3 bucket, click on Upload then click on Add files and upload the zip files from
/agent/aws_lambdas
You should now have the Amazon S3 bucket with two lambda function zip files.
- Goto AWS CloudFormation
- Click
Create Stack
- Create stack
- Prerequisite - Prepare template:
Template is ready
- Specify template:
- Template source: Select
Upload a template file
- Upload a template file → Select the
ChimeConnectIntegrationDemo.yaml
file from/agent/
folder - Click Next
- Template source: Select
- Prerequisite - Prepare template:
- Specify stack details
- Stack Name:
ChimeSDKConnectIntegrationDemo
- In Parameters section:
- AmazonS3BucketName: Provide Amazon S3 bucket name created in agent setup step 1
- Click Next
- Stack Name:
- Click Next on Configure stack options with everything as is.
- On the final Review page, check the acknowledge option under capabilities and click Create Stack.
Once creation is complete, in the output section you will get three variables as mentioned below:
ChimeConnectDemoUserAccessKey
,ChimeConnectDemoUserSecretKey
- This is the access key and secret key for the development user to call the Amazon API Gateway endpoint's DELETE and POST method from localhost.invokeURL
- API Gateway endpoint invoke URL.
This template creates required roles, API Gateway with resources, methods and proxy AWS Lambda integration.
Follow these steps to enable CORS:
- Go to the Amazon APIGateway
- Click
chime-meeting-operations
- Check
/meeting
under resources. Select it, click on Actions dropdown and click on Enable CORS - Check the 4XX and 5XX for
Gateway Responses for chime-meeting-operations API
and click onEnable CORS and replace existing CORS headers
- Finally click Deploy API from Actions dropdown.
Navigate to /agent/
-
Update the
ACCESS_KEY
,SECRET_KEY
,INVOKE_URL
in/agent/src/AgentConfig.js
with values received in AWS CloudFormation output tab. UpdateAWS_REGION
if needed, but keep it the same everywhere -
Update the
AGENT_CCP_URL
in/agent/src/AgentConfig.js
with the created Amazon Connect instance alias. You can find the instance alias by going to Amazon Connect check 'Instance Alias' under Amazon Connect virtual contact center instances -
As the demo uses Amazon Connect Streams API, it is required to add your website as an approved origin to the created Amazon connect instance.
- To do this, goto Amazon Connect, click 'Instance Alias' under Amazon Connect virtual contact center instances. On the left-hand side panel, you will find Application integration, click on it.
- Under Approved origins, click on + Add origin → enter origin URL as https://localhost:8080 and click Add.
-
Open terminal, navigate to
/agent/
directory- Install NPM dependencies:
npm install
- Build the app:
npm run build
- Start the server:
npm run start
- Install NPM dependencies:
-
Step 4 opens https://localhost:8080 in your browser.
-
Once open, a separate Amazon Connect window opens as well requesting you to login to your connect instance that you created. Use the admin credentials for the administrator you created as part of the connect instance creation steps. Upon login, go back to the https://localhost:8080 tab and change the status to "Available" from the left top side to make the agent available to receive the calls from customer application. The agent application might result into certificate issues in Firefox. Recommend to use Chrome browser for this demo purpose. At times,
SAMEORIGIN
X-Frame-Options
error may also be seen in where the agent application keeps on trying to connect due to certificate issue. If that is the case, openhttps://<YOUR AMAZON CONNECT INSTANCE ALIAS>.awsapps.com/connect/ccp-v2/chat
in a separate tab in same window, login using the administrator and again refresh the https://localhost:8080 tab.
Check the demo screenshots in the Build a video contact center with Amazon Connect and Amazon Chime SDK blog post to follow through the demo experience with agent and customer application now running in the browser.
To avoid incurring future charges, delete the Amazon Connect instance and the AWS CloudFormation templates created as part of the setup steps.
The access and secret key are included as part of the JavaScript for the purpose of this demo. In a production application, these keys should not be delivered as part of any JavaScript. You can use Amazon Cognito for better implementation of authentication and authorization.
Amazon Cognito lets you add user sign-up, sign-in, and access control to your web and mobile apps quickly and easily. Amazon Cognito scales to millions of users and supports sign-in with social identity providers, such as Facebook, Google, and Amazon, and enterprise identity providers via SAML 2.0.
Amazon Cognito also provides solutions to control access to backend resources from your app. You can define roles and map users to different roles so your app can access only the resources that are authorized for each user.
-
This demo is developed and tested in
us-east-1
region, if you use any other region please update the same everywhere else in the entire customer and agent application. -
If you have selected an AWS region other than
us-east-1
, theStartVideoCall
Amazon Lex bot will not work as it was exported fromus-east-1
region, to update it do the following:- Update the
StartVideoCall
Amazon Lex bot by going toChime Connect Integration flow
(imported just above) →Get Customer Input
block - Click on
Get Customer Input
and on the right side panel, under the Lex tab select the single entry ofStartVideoCall
Amazon Lex bot from the dropdown. This updates theStartVideoCall
Amazon Lex bot you created in your region.
- Update the
This project is licensed under the Apache-2.0 License.