Enabling Cloud Pub/Sub notifications allows you to receive a notification each time a CCAI Insights event completes. You can configure CCAI Insights to send a notification for all events or only specified events. To learn more about the events that can trigger Cloud Pub/Sub notifications, see the reference documentation.
Prerequisites
- Follow the instructions to create a Cloud Pub/Sub topic and a pull subscription.
Enable Cloud Pub/Sub notifications
You can configure CCAI Insights to send a notification for specific events only or for all events. The following code sample configures CCAI Insights to only send a notification each time a conversation or an analysis is created.
REST
Before using any of the request data, make the following replacements:
- PROJECT_ID: your Google Cloud project ID.
- LOCATION_ID: the location you chose for your Cloud Storage bucket. The only
location currently available is
us-central1
. - TOPIC_ID: the ID for the notification topic (for example, notify each time a conversation is created). Each notification topic should have a unique ID.
HTTP method and URL:
POST https://contactcenterinsights.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/settings?updateMask=pubsub_notification_settings
Request JSON body:
{ "pubsub_notification_settings": { "create-conversation": "projects/PROJECT_ID/topics/TOPIC_ID_1", "create-analysis": "projects/PROJECT_ID/topics/TOPIC_ID_2" }, }
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_ID/locations/us-central1/settings", "createTime": "2021-01-20T10:10:10.123000Z", "updateTime": "2021-01-20T11:11:11.456000Z", "pubsubNotificationSettings": { "create-conversation": "projects/PROJECT_ID/topics/TOPIC_ID_1", "create-analysis": "projects/PROJECT_ID/topics/TOPIC_ID_2" } }
Python
To authenticate to CCAI Insights, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Java
To authenticate to CCAI Insights, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
To authenticate to CCAI Insights, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Content of the Cloud Pub/Sub message
The content of the Cloud Pub/Sub message depends on the event that triggers that Cloud Pub/Sub notification.
Trigger | Message Data | Message Attributes |
---|---|---|
create-analysis | Long-running operation whose response is an analysis | {"operation_name": "projects/{project}/locations/{location}/operations/{operation}"} |
create-conversation | Conversation | {"conversation_name": "projects/{project}/locations/{location}/conversations/{conversation}"} |
export-insights-data | Long-running operation whose response is empty | {"operation_name": "projects/{project}/locations/{location}/operations/{operation}"} |
update-conversation | Conversation | {"conversation_name": "projects/{project}/locations/{location}/conversations/{conversation}"} |