How aws-samples/amazon-connect-chat-translate works
This is a React agent-side application for Amazon Connect chat, translating customer messages into English and agent replies into each customer’s language. The main flow is authenticated startup, Connect contact events, per-contact language selection or first-message detection, translation, chat display, and sending the translated reply through the contact session. README also documents concurrent chats and custom terminology support. The sampled files show the UI and Amplify client calls; backend translation wiring is documented by the project setup but its handler source was not excerpted here.
Main entry points: ccp.js Connect controller · chatroom.js Chat workspace · App.js Authenticated app · state.js Chat state
Components 15
Agent application
- Authenticated app
src/App.js - Connect controller
src/components/ccp.js
Language processing
- Language detection
src/components/detectText.js - Client translation
src/components/translate.js - Translation API client
src/components/translateAPI.js
Chat interaction
- Chat workspace
src/components/chatroom.js - Message view
src/components/message.js - Chat state
src/store/state.js
Amplify services
- Translation API
amplify/backend/api/amazonTranslateAPI - Translation handler
amplify/backend/function/amazonTranslateLambda/src/index.js - Amazon Translate
- Amazon Comprehend
- Custom terminology setup
amplify/backend/function/postInstallScript/src/index.js
Other components
- Agent
- Amazon Connect
Connections 20
- Agent → Authenticated app: signs in
src/App.js - Authenticated app → Connect controller: renders
src/App.js - Connect controller → Amazon Connect: embeds CCP
src/components/ccp.js - Connect controller → Chat workspace: renders workspace
src/components/ccp.js - Connect controller → Chat state: updates
src/components/ccp.js - Connect controller → Language detection: detects language
src/components/ccp.js - Connect controller → Client translation: translates customer
src/components/ccp.js - Connect controller → Chat state: stores translated chat
src/components/ccp.js - Chat workspace → Chat state: reads and updates
src/components/chatroom.js - Chat workspace → Message view: renders messages
src/components/chatroom.js - Agent → Chat workspace: writes reply
src/components/chatroom.js - Chat workspace → Translation API client: requests translation
src/components/chatroom.js - Chat workspace → Amazon Connect: sends translated reply
src/components/chatroom.js - Translation API client → Translation API: posts translation
src/components/translateAPI.js - Translation API → Translation handler: routes request
- Translation handler → Amazon Translate: translates text
- Language detection → Amazon Comprehend: detects language
- Client translation → Amazon Translate: uses Predictions
- Custom terminology setup → Amazon Translate: registers terminology
amplify/backend/function/postInstallScript/src/index.js - Authenticated app → Connect controller: configures Amplify
src/App.js