The Genesys Chat Adapter for CXAS is a lightweight middleware application designed to seamlessly connect Genesys Cloud chat deployments with Google Cloud's CX Agent Studio (CXAS) agents.
Modern customer service operations often rely on sophisticated bot experiences managed centrally on platforms like Google Cloud. Meanwhile, customer interactions happen on established platforms like Genesys Cloud.
This adapter acts as a high-speed bridge between the two platforms. Instead of forcing you to build complex, custom integrations directly inside Genesys, this adapter handles all the translation work automatically:
- Real-time Passthrough: It listens to incoming messages from Genesys chat interactions.
- Format Translation: It translates the proprietary Genesys message structure into a format that Google's CXAS agents understand natively.
- Intelligent Routing: It automatically identifies the correct underlying application and deployment within CXAS.
- Context Continuity: It preserves custom user parameters and session context, preventing the AI from losing track of the conversation history.
- Escalation Handling: It natively understands when the Google AI decides to transfer the user to a human agent, gracefully formatting the response to inform Genesys to execute the handover.
By utilizing this adapter, organizations can rapidly deploy advanced Google Cloud AI agents directly over their existing Genesys chat infrastructure without locking themselves into complex, interdependent architectures.
The Genesys Chat Adapter for CXAS is a Python 3.13+ application built on top of the FastAPI web framework. It relies on standard internal Google httpx and google-auth mechanisms to interact with the CES gRPC REST transcoding interface (ces.googleapis.com).
- Endpoint:
POST /v1/postUtterancereceives the JSON payload from a Genesys Webhook / Bot Connector. - Authentication: The API is secured via a required
API-KEYheader, verifiable against an environment variable (or Google Secret Manager path). - Session Routing: The adapter dynamically constructs the CES endpoint by extracting the application identity and location directly from either the
__deployment_idor_deployment_idparameter in the Genesys request payload. A single adapter can route traffic for multiple distinct bots. - Stateful Turn Tracking: Mappings of session IDs to deployment IDs and turn counts are stored persistently:
- By default, these are kept in-memory for testing purposes via a TTLCache.
- For production, set
FIRESTORE_SESSIONS_COLLECTIONto store session documents in Firestore. Old session documents are automatically cleaned up using Firestore's TTL policy based on theexpiry_timefield (set to 24h into the future).
To prevent infinite loops and wasteful processing of resources, the Genesys BYOB (Bring Your Own Bot) Bot Connector v1 automatically terminates any chatbot session that returns the same intent name for more than 3 consecutive interactions without slot value updates. It will raise a NoMatchError and fail the session.
To bypass this restriction, this adapter tracks conversation turns (turn_count) statefully and alternates the returned intent name between generic-even and generic-odd on successive turns. This resets Genesys BYOB's loop detection counter on every transaction, allowing the conversation to proceed indefinitely:
- Odd Turns: The adapter returns the intent as
generic-odd. - Even Turns: The adapter returns the intent as
generic-even. - On Session End: When CXAS signals session completion, it returns the intent as
end-session. - On Escalation: On handover, it returns the intent as
live-agent-handoff.
To support this workaround, you must register the generic-even, generic-odd, end-session, and live-agent-handoff intents in your Genesys Bot Connector configuration.
Below is the curl command and the corresponding payload structure to update the Bot List configuration via the Genesys Cloud Admin API:
curl -X PUT 'https://api.usw2.pure.cloud/api/v2/integrations/botconnector/YOUR_BOT_CONNECTOR_INTEGRATION_ID/bots' \
-H 'Authorization: Bearer YOUR_GENESYS_ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
--data-raw '{
"chatBots": [
{
"id": "YOUR_CXAS_APP_ID",
"name": "ces-genesys-chat-agent",
"description": "CXAS Bot integration",
"versions": [
{
"version": "1.0",
"supportedLanguages": ["en-US"],
"intents": [
{"name": "generic-even"},
{"name": "generic-odd"},
{"name": "end-session"},
{"name": "live-agent-handoff"}
]
}
]
}
]
}'- Python 3.13+
- The
uvpackage manager (recommended) orpip. - A Google Cloud Project with the
ces.googleapis.comAPI enabled and Firestore enabled (if using Firestore session mapping). - Application Default Credentials (ADC) configured locally, or a Service Account when deployed.
- Clone the repository and navigate into the root directory.
- Install dependencies using
uv:uv venv source .venv/bin/activate uv pip install -r requirements.txt - Authenticate with Google Cloud:
gcloud auth application-default login
- Set your environment variables:
Create a local setup script or export directly:
export API_KEY="your-secret-local-dev-key" export DEBUG="true" export FIRESTORE_SESSIONS_COLLECTION="ces_sessions" # Optional: Uses Firestore for scalable session tracking
- Run the server:
uvicorn src.main:app --host 0.0.0.0 --port 8000 --reload
To function properly, your Genesys Bot Connector must include a _deployment_id as a custom parameter. This dictates where the traffic runs.
Format Pattern:
projects/{project}/locations/{location}/apps/{app_id}/deployments/{deployment_id}
Sample Genesys Payload Definition:
{
"botSessionId": "c86e246...",
"inputMessage": {
"text": "help me with my invoice",
"type": "Text"
},
...
"parameters": {
"_deployment_id": "projects/my-project/locations/us/apps/123/deployments/456"
}
}The application is fully configured to be deployed as a containerless Python service on Google Cloud Run via Buildpacks (defined via Procfile).
- Ensure the Google Cloud SDK is installed and authorized.
- Copy the template
script/values.sh.exampletoscript/values.shand configure your targetPROJECT_ID,SERVICE_NAME,LOCATIONand the Google Secret Manager path for yourAPI_KEY. - Execute the deployment script:
./script/deploy.sh
The script will automatically allocate memory, set concurrency values, attach the Service Account, and inject the API_KEY from Secret Manager directly into the runtime environment.
- Production (Default): Logs are kept clean at the
INFOlevel. Structural validation errors (422 Unprocessable Content) are inherently logged to identify schema drift between Genesys and the Adapter. - Debug Mode: Set the environment variable
DEBUG="true"to force the application to dump the full raw JSON input from Genesys and the full outbound payload to CES for deep functional troubleshooting.