Agent Assist backend modules basics

Agent Assist now offers backend modules, an out-of-the-box option for integrating Agent Assist into your system. Backend modules includes a Cloud Pub/Sub interceptor service and a UI connector service. The interceptor processes feature-related event notifications from Dialogflow using Cloud Pub/Sub topics and then the UI connector pushes them to the agent desktop UI. UI connectors also support feedback signals from the agent desktop and sends them to Dialogflow.

Backend modules structure

Backend module components

Backend modules require the following Google products to integrate Agent Assist into your system:

  • Cloud Pub/Sub
  • Cloud Pub/Sub interceptor
  • Memorystore for Redis
  • UI connector

Cloud Pub/Sub

Cloud Pub/Sub topics are configured in conversation profiles. Agent Assist will then publish suggestions, new messages, and conversation lifecycle-related events to the topic. Suggestions are in the form of HumanAgentAssistantEvent, and both new messages and conversation lifecycle events in the form of ConversationEvent. For each conversation profile, these three kinds of event messages are published to different topics. For example, a conversation lifecycle event message might be {"conversation":"projects/your-project-id/locations/global/conversations/your-conversation-id","type":"CONVERSATION_STARTED"}, which indicates the start of a conversation.

Cloud Pub/Sub interceptor

The Cloud Pub/Sub interceptor is deployed on Cloud Run. The functionality of each container instance (server) of this Cloud Run service is identical to each other instance, including:

  • Processing event messages posted by Cloud Pub/Sub topics using HTTP requests.
  • Publishing messages received to Redis Pub/Sub channels, specific to the conversation name and the UI connector server ID. The channel format is {connector_id}:{conversation_name}.

Redis

Redis uses Memorystore for Redis to do the following:

  • Record the UI connector server ID information for each conversation in mapping <conversation_name, connector_id>.
  • Forward event notifications published by Cloud Pub/Sub interceptor to the corresponding UI connector server using the Redis Pub/Sub mechanism.

UI connector

UI connectors are deployed on Cloud Run. Because WebSockets connections are stateful, the agent desktop will stay connected to the same container on Cloud Run throughout the lifespan of the connection. Therefore, every UI connector server handles different conversations and subscribes to distinct Redis Pub/Sub channels ({connector_id}:*) for the conversations they handle. Tasks for each UI connector server:

  • Supports a customized authentication method for agent desktops.
  • Generates temporary JWT after authenticating agent desktops' customized tokens. When they send requests to the Dialogflow API or WebSockets connection, UI connectors validate the attached JWT instead of checking the original agent token.
  • Establishes a WebSockets connection with the authenticated agent desktop based on a given conversation name.
  • Subscribes event messages to Redis Pub/Sub channels for the conversations it handles.
  • Pushes Agent Assist events to the desktop UI as they are received.

Secret Manager

The UI connector needs a JWT secret key to generate temporary JWTs for authenticated agent desktops. This secret key is stored in the Secret Manager.

Directory

The following is an outline of directory structure in the code repository. Contact your Google representative for permissions if you are not able to access the repository.

.
├── cloud-pubsub-interceptor
│   ├── Dockerfile: Builds Docker image for Cloud Pub/Sub interceptor deployment on Cloud Run.
│   ├── main.py: A starter for flask app.
│   ├── requirements.txt
│   └── unit_test.py: Unit test code for Cloud Pub/Sub interceptor.
└── ui-connector
    ├── auth.py: Handles JWT validation and registration.
    ├── config.py: Configures variables about authentication, logging and CORS origins.
    ├── dialogflow.py: Includes Dialogflow utilities for handling conversations at runtime.
    ├── Dockerfile: Builds Docker image for UI connector deployment on Cloud Run.
    ├── main.py: A starter for flask app.
    ├── requirements.txt
    ├── templates
    │   └── index.html: A simple interactive demo.
    └── unit_test.py: Unit test code for UI connector.

What's next

See the backend modules installation guide for more information about getting started with this integration method.