Closed reziakk closed 1 year ago
Hi @reziakk,
There is currently no way to configure SYSTEM_MESSAGE
or BOT
name in your contact flow. This is hard-coded internally and customizing this is unfortunately not a feature. You will need to hardcode this in the UI, and we provide open source code for you to customize.
Can you include details about your setup? Are you using the customChatWidget
ui-example code, referring to this file? - https://github.com/amazon-connect/amazon-connect-chat-ui-examples/blob/master/customChatWidget/src/constants/index.js
You can fork the open source code and generate a custom amazon-connect-chat-interface.js
bundle file.
You could hard code new displayName
for the incoming messages, in this ChatMessage.js#L175 file:
An incoming transcript item over the websocket will look like this:
{
transportDetails: {
direction: 'Incoming',
status: 'SendSuccess',
},
AbsoluteTime: AbsoluteTime + 4000,
MessageMetadata: {
MessageId: '31bf18c9-d80b-4f75-8145-c47946a26e03',
Receipts: [],
},
Content:
'Hello, Welcome to our Contact Center, connecting you with an agent now',
ContentType: 'text/plain',
DisplayName: 'SYSTEM_MESSAGE',
Id: '31bf18c9-d80b-4f75-8145-c47946a26e03',
ParticipantId: 'bcd32342-dd03-42ce-9288-9c44ebf81c4e',
ParticipantRole: 'SYSTEM',
Type: 'MESSAGE',
},
{
Id: 'bulletedList2',
Type: 'message',
ParticipantId: '123',
AbsoluteTime: AbsoluteTime + 5000,
ParticipantRole: 'CUSTOMER',
transportDetails: {
direction: 'Outgoing',
status: 'SendSuccess',
},
content: {
type: ContentType.MESSAGE_CONTENT_TYPE.TEXT_MARKDOWN,
data: '* item3 \n * item4',
},
}
$ git clone https://github.com/amazon-connect/amazon-connect-chat-interface.git
$ cd amazon-connect-chat-interface
$ npm install
ChatMessage.js
component// https://github.com/amazon-connect/amazon-connect-chat-interface/src/components/Chat/ChatTranscriptor/ChatMessages/ChatMessage.js
export class ParticipantMessage {
static propTypes = {
messageDetails: PT.object.isRequired,
incomingMsgStyle: PT.object,
outgoingMsgStyle: PT.object,
mediaOperations: PT.object,
isLatestMessage: PT.bool,
shouldShowMessageReceipts: PT.bool,
sendReadReceipt: PT.func.isRequired,
};
constructor(props) {
super(props);
}
renderHeader() {
const isOutgoingMsg = this.props.messageDetails.transportDetails.direction === Direction.Outgoing;
+ let displayName = this.props.messageDetails.displayName || (isOutgoingMsg ? "Customer" : "Agent");
+ if (displayName === "BOT" || displayName === "SYSTEM_MESSAGE") {
+ displayName = "ALEXA"
+ }
const transportDetails = this.props.messageDetails.transportDetails;
return (
<React.Fragment>
<Header.Sender>{ displayName } < /Header.Sender>
< Header.Status > { transportStatusElement } < /Header.Status>
< /React.Fragment>
);
}
// ...
}
$ npm run release
# open the build output folder
amazon-connect-chat-interface.js
: https://github.com/amazon-connect/amazon-connect-chat-ui-examples/blob/master/customChatWidget/public/amazon-connect-chat-interface.jsOtherwise, if you are using the OOTB Amazon Connect Hosted Chat Widget, you can follow the documentation to customize SYSTEM_MESSAGE
and BOT
name: https://docs.aws.amazon.com/connect/latest/adminguide/add-chat-to-website.html#customize-chat-widget
Please let us know if this is help resolve your use case, or you had further questions.
Thanks, Spencer
amazon-connect-interface it is not generating the build file after the npm run release. also tried the npm run build and npm run dev-build as suggested in the git page.
seems that the test script it is not going through:
No tests found, exiting with code 1
Run with --passWithNoTests
to exit with code 0
In C:\Users\%username%\amazon-connect-chat-interface
107 files checked.
testMatch: C:/Users/%username%/amazon-connect-chat-interface/src//tests//*.{js,jsx,ts,tsx}, C:/Users/%username%/amazon-connect-chat-interface/src/*\?(.)(spec|test).{js,jsx,ts,tsx} - 0 matches
testPathIgnorePatterns: \node_modules\ - 107 matches
testRegex: - 0 matches
Pattern: - 0 matches
tried to use the --passWithNoTests too but still exits as code 1 and doesn't go through.
Hi @reziakk, can you try just running node scripts/build.js
, or removing npm run coverage
from the build
script? You may want to use Node 16 LTS (nvm tool could help).
amazon-connect-chat-interface.js
file should end up in build/dist/static/js
folder after a successful run.
The npm run release
is running npm run coverage
AND node scripts/builds
.
Team is working on fix to support newer version of Node. You may run into issues until then. It is taking longer since we need to upgrade from webpack 4.
Here is an example package.json that should work:
$ npm install
$ npm run release
{
"name": "@amzn/connect-chat-interface",
"version": "1.0.0",
"homepage": "https://github.com/amazon-connect/amazon-connect-chat-interface",
"author": "Amazon Web Services",
"license": "MIT-0",
"repository": {
"type": "git",
"url": "git+https://github.com/amazon-connect/amazon-connect-chat-interface.git"
},
"engines": {
"node": ">=16.0.0"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"scripts": {
"build": "node scripts/build.js",
"release": "npm run build",
"debug": "npm run dev-build && node scripts/copyToOutput.js",
"dev-build": "NODE_ENV=development npx webpack --config configuration/webpack.config.dev.js",
"dev-watch": "nodemon --watch src -x \"NODE_ENV=development npx webpack --config configuration/webpack.config.dev.js && cp build/dist/static/js/amazon-connect-chat-interface.js local-testing/\"",
"clean": "rm -rf build/ node_modules build",
"test": "node scripts/test.js",
"coverage": "node scripts/test.js --coverage",
"test:watch": "node scripts/test.js --watchAll"
},
"jest": {
"setupFilesAfterEnv": [
"<rootDir>/configuration/jest/setup.js"
],
"collectCoverage": true,
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.d.ts"
],
"resolver": "jest-pnp-resolver",
"setupFiles": [
"react-app-polyfill/jsdom"
],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
"<rootDir>/src/**/?(*.)(spec|test).{js,jsx,ts,tsx}"
],
"testEnvironment": "jsdom",
"testURL": "http://localhost",
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/configuration/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/configuration/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
"^.+\\.module\\.(css|sass|scss)$"
],
"moduleNameMapper": {
"^react-native$": "react-native-web",
"^connect-components/(.*)$": "<rootDir>/src/components/$1",
"^connect-core$": "<rootDir>/src/components/core/",
"^connect-services/(.*)$": "<rootDir>/src/services/$1",
"^connect-chat$": "<rootDir>/src/components/Chat",
"^connect-chat/(.*)$": "<rootDir>/src/components/Chat/$1",
"^connect-constants$": "<rootDir>/src/constants/global",
"^connect-hooks$": "<rootDir>/src/hooks",
"^connect-images$": "<rootDir>/src/assets/images",
"^connect-prop-types$": "<rootDir>/src/propTypes",
"^connect-theme$": "<rootDir>/src/theme",
"^connect-theme/(.*)$": "<rootDir>/src/theme/$1",
"^connect-app-context/(.*)$": "<rootDir>/src/context/$1",
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
},
"moduleFileExtensions": [
"web.js",
"js",
"web.ts",
"ts",
"web.tsx",
"tsx",
"json",
"web.jsx",
"jsx",
"node"
],
"globalSetup": "./global-setup.js"
},
"husky": {
"hooks": {
"pre-commit": "npm run build && cp build/dist/static/js/amazon-connect-chat-interface.js local-testing/ && git add local-testing/amazon-connect-chat-interface.js"
}
},
"dependencies": {
"@babel/runtime": "7.9.2",
"@emotion/core": "^10.0.35",
"@svgr/webpack": "^6.2.1",
"@types/jest": "^26.0.19",
"amazon-connect-chatjs": "^1.3.0",
"core-js": "^3.8.3",
"draft-js": "^0.11.7",
"emoji-mart": "^3.0.1",
"dompurify": "^3.0.3",
"is-json": "^2.0.1",
"markdown-draft-js": "^2.4.0",
"react": "^16.6.3",
"react-app-polyfill": "^0.1.3",
"react-dom": "^16.6.3",
"react-error-boundary": "^3.1.4",
"react-intersection-observer": "8.33.1",
"react-linkify": "0.2.2",
"react-markdown": "^6.0.3",
"react-router-dom": "^4.3.1",
"react-spinners": "^0.10.4",
"react-textarea-autosize": "8.4.0",
"styled-components": "^4.1.1",
"webpack": "^4.46.0",
"whatwg-fetch": "^3.2.0",
"workbox-webpack-plugin": "3.6.3"
},
"devDependencies": {
"@babel/core": "^7.1.0",
"@babel/preset-env": "^7.2.0",
"@emotion/babel-plugin": "^11.10.6",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
"@testing-library/dom": "7.29.4",
"@testing-library/jest-dom": "^5.15.0",
"@testing-library/react": "^12.1.5",
"@testing-library/user-event": "13.0.7",
"@types/react": "^16.14.35",
"acorn": "^8.8.2",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "9.0.0",
"babel-jest": "27.2.0",
"babel-loader": "^8.3.0",
"babel-plugin-named-asset-import": "^0.2.3",
"babel-preset-react-app": "^8.0.0",
"bfj": "6.1.1",
"case-sensitive-paths-webpack-plugin": "2.1.2",
"chalk": "2.4.1",
"css-loader": "^5.0.2",
"dotenv": "6.0.0",
"dotenv-expand": "4.2.0",
"enzyme": "^3.7.0",
"enzyme-adapter-react-16": "^1.7.0",
"eslint": "5.6.0",
"eslint-config-react-app": "^3.0.5",
"eslint-loader": "2.1.1",
"eslint-plugin-flowtype": "2.50.1",
"eslint-plugin-import": "2.14.0",
"eslint-plugin-jsx-a11y": "6.1.2",
"eslint-plugin-react": "7.11.1",
"file-loader": "2.0.0",
"fork-ts-checker-webpack-plugin": "6.3.3",
"fs-extra": "7.0.0",
"html-webpack-plugin": "4.0.0-alpha.2",
"husky": "^4.3.8",
"identity-obj-proxy": "3.0.0",
"jest": "^27.1.1",
"jest-location-mock": "^1.0.9",
"jest-pnp-resolver": "1.0.1",
"jest-resolve": "23.6.0",
"jest-styled-components": "^6.3.1",
"lodash": "^4.17.21",
"mini-css-extract-plugin": "^0.9.0",
"nodemon": "^2.0.20",
"optimize-css-assets-webpack-plugin": "^6.0.0",
"pnp-webpack-plugin": "1.1.0",
"postcss-flexbugs-fixes": "4.1.0",
"postcss-loader": "3.0.0",
"postcss-preset-env": "6.0.6",
"postcss-safe-parser": "4.0.1",
"prop-types": "^15.8.1",
"react-dev-utils": "^12.0.0",
"react-render-html": "^0.6.0",
"react-test-renderer": "^16.6.3",
"resolve": "1.8.1",
"sass-loader": "^10.1.1",
"shallow": "^1.0.0",
"style-loader": "0.23.0",
"terser-webpack-plugin": "4.2.3",
"typescript": "^4.9.4",
"typescript-formatter": "^7.2.2",
"universal-cookie": "^3.0.7",
"url-loader": "1.1.1",
"webpack-cli": "^4.8.0",
"webpack-dev-server": "^4.1.1",
"webpack-manifest-plugin": "2.0.4"
},
"overrides": {
"glob-parent": "^5.1.2",
"css-loader": {
"webpack": "^4.46.0"
}
}
}
Amazing , working as expected, Thanks for that.
Hi, I'm looking for a way to replace the "SYSTEM_MESSAGE" and "BOT" when receiving messages. Already tried to replace the values in constants/index.js
export const chatParties = { SYSTEM_MESSAGE: 'Another value', BOT: 'Another value' }
Is there a way to replace it? To change for a custom value to display when the user receive the message from the system, meaning Contact Flow or the Bot?