- Introduction
- Service Architecture
- Service Flow
- Technical Overview
- Genesys Integration
- Developer Guide
- Adding a New Web Chat
- Contributing
Home Office service for web messengers. This service provides 3 web messenger, chat bot style services for public use. The 3 services included in this application are:
- ETA (Electronic Travel Authorisation)
Each messenger integrates with Genesys Web Messenger, which provides automated bot interactions based on specific knowledge bases for each service, whilst also providing human interaction and support through live agents.
The application is hosted within the ACP platform, deployed onto Kubernetes infrastructure.
- The end user accesses the service via their browser.
- On initial load of the application, the service fetches and initialises the Genesys Headless SDK.
- Whilst this is happening, a loading spinner is shown to indicate further loading is taking place.
- Once the SDK is loaded, the application will begin a sequence of actions to ensure the SDK is ready and subscribe to a number of core SDK events (see genesys overview for more detail).
- Once the application is deemed ready, the chat components will be loaded into the user browser, replacing the loading spinner. The user will then be able to interact with the digital assistant or live agent through the use of the chat form.
See the technical overview
See the genesys overview for details on how the service integrates with Genesys Cloud Platform.
This guide shows how to run web-messengers locally for development, how to provide runtime environment values, and how to run the built image locally so you can test behaviour that's close to production.
- Node (the currently pinned base image is hof-nodejs 20). Use the project's node manager or the official Node installation.
- Yarn
- Docker (when testing container builds locally).
The application loads runtime configuration from env.json (fetched by the client before React mounts). For local dev, create a file at the project root named env.json with keys the app expects.
Example env.json:
{
"ETA_DEPLOYMENT_ID": "REPLACE_ME",
"GENESYS_ENVIRONMENT": "REPLACE_ME",
"GOOGLE_TAG_MANAGER_ID": "REPLACE_ME",
"ENABLE_ANALYTICS": false,
"LOG_ENDPOINT": "REPLACE_ME"
}Note: Non-prod values can be found in Keybase (
WM-env.json), a senior developer on the team can help you to find this if you're unfamiliar with Keybase.
- Install dependencies:
yarn install-
Ensure
env.jsonexists at the project root (see above). Parcel will serve files from project root so the client can fetch/env.json. -
Start the dev server:
yarn start
# opens on http://localhost:3000Behaviour:
src/index.jscallsloadEnvironmentConfig()which fetches/env.json. The app will not mount until the env is loaded.- To quickly check that
env.jsonis accessible, openhttp://localhost:3000/env.jsonin the browser. If fetch fails the console will show an error and the app will not bootstrap.
If you want to build and serve the static files like production (so generate-env.sh or nginx behaviour can be tested), follow these steps:
- Build the production artifact:
yarn build-prod
# outputs to ./dist- Copy your
env.jsonintodist/(or ensuregenerate-env.shwill create it when running the container). For a local static server, putenv.jsonintodist/:
cp env.json dist/env.json- Serve
dist/with a simple static server (you can usenpx serveor python):
npx serve -s dist -l 8080
# or
python3 -m http.server --directory dist 8080Then open http://localhost:8080 to verify the built app loads and reads env.json.
This lets you exercise generate-env.sh which writes env.json from env vars at container startup.
- Build the image (from project root):
docker build -t web-messengers:local .- Create a
.envfile with keys required bygenerate-env.sh(or pass env vars directly todocker run). Example.env:
ETA_DEPLOYMENT_ID=REPLACE_ME
GENESYS_ENVIRONMENT=REPLACE_ME
GOOGLE_TAG_MANAGER_ID=REPLACE_ME
ENABLE_ANALYTICS=false
LOG_ENDPOINT=REPLACE_MENOTE: the file doesn't have to be named
.envit's just to pass the environment variables to the docker environment. Again the non-prod values can be found in keybase (WM-env.json).
- Run the container with the env file and port mapping:
docker run --rm --env-file .env -p 8080:80 web-messengers:local- Run unit tests with coverage:
yarn test- Run ESLint:
yarn lint
yarn lint:fix- env.json fetch failures: open the browser devtools Network tab and check the
/env.jsonrequest and response. If it returns 404 or 500 the app will throw and not mount. - Parcel (dev): source maps are enabled by default — use the browser devtools to set breakpoints in app sources.
- Forgot
env.json— app won't start. Ensureenv.jsonis served at/env.jsonbefore the app's JS runs. - Port collisions — dev server runs on 3000 by default. Production nginx listens on 80 inside the container and is mapped to the host port you choose.
The service has been built in a modular way. As the 3 embedded services all follow the exact same pattern, there is a single core chat component which handles the core chat capability. Each service which uses this component just needs to import it and pass the required props to work.
In order to add a new chat service, the follow key elements will need to be implemented:
Assumption here is that a new Genesys deployment would have been configured and deployed for this new service
- A new config entry would need adding to the service config file to reflect the new chat settings
- The env.json file would need an entry adding for the new Genesys deploymentId
- The kube deployment manifest would need updating to add the new Genesys deploymentId as a secret env value
- A new route needs to be added to
src/routes. Within that new route component, simple follow the same pattern as the other routes to enable a new chat service inside the application:
export default function NewWebChatComponent() {
return (
<ErrorBoundary>
<GenesysChatComponent
deploymentId={config.newChatComponent.deploymentId}
localStorageKey={config.newChatComponent.localStorageKey}
serviceName={config.newChatComponent.name}
serviceSubText={config.newChatComponent.subText}
errorContactLink={config.newChatComponent.errorContactLink}
/>
</ErrorBoundary>
);
}
- A new route would need adding to the App.js file so the service is reachable
- New routes would need adding to support the cookie pages for the new service
- New Google Analytics UTM parameters would need assigning to the new service (and added as config to the config file)
Note: This service has been primarily built as a re-skin project to replace an existing service which hosts the 3 web messeger applications. The view isn't to add more web messenger services to this project. However, this section provides the detail on how to do so, if that requirement was considered.
Follow the Pull Request Template when raising a pull request.
