Conversations can be viewed in Conversational Insights after a corresponding conversation object has been created. This how-to guide walks you through the process of analyzing a conversation using the REST API. If preferred, you can also perform these actions using the Insights console.
Prerequisites
- Enable the Cloud Storage and Insights APIs on your Google Cloud project.
- Import your conversation data.
Chat conversation
Import the conversation's chat transcript as an object in your Cloud Storage bucket.
Make a note of the object path, with the format
gs://<bucket>/<object>
.
The chat transcript file must be supplied as a JSON-formatted file that matches the CCAI conversation data format.
Voice conversation
Import all the files from a Cloud Storage bucket. Audio and transcript files must be imported as objects in your Cloud Storage bucket.
Make a note of the two object paths, with the format
gs://<bucket>/<object>
.
The transcript files must be the returned result of a Cloud Speech-to-Text API transcription. Specifically, they must match the response returned from audio recognition, which is identical for synchronous recognition and asynchronous recognition across all Speech-to-Text API versions. Other transcription formats are unsupported and will result in an error during conversation analysis.
Analyze a conversation
Once a Conversation
object is created in Insights, it must be
analyzed in order to produce useful results. A single conversation can be
analyzed many times, and each separate analysis creates a new Analysis
object.
An analysis runs a series of annotators against your conversation data and returns the results in the response. By default, the analysis will run all available annotators. Optionally, you can configure the analysis to run specified annotators only.
An analysis is a long-running operation. Calling the CreateAnalysis
method
creates an Operation
object that represents the long-running process. After
the operation is complete, the Operation
object contains the result. You can
poll the Operation
object to check for completion.
Create a new analysis
REST
Refer to the
conversations.analyses:create
API endpoint for complete details.
Before using any of the request data, make the following replacements:
- PROJECT_ID: your Google Cloud project ID.
- CONVERSATION_ID: the ID of the conversation you want to analyze. This value was returned in the `createConversation` response.
HTTP method and URL:
POST https://contactcenterinsights.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/conversations/CONVERSATION_ID/analyses
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/operations/OPERATION_ID" }
Python
To authenticate to Insights, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Java
To authenticate to Insights, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
To authenticate to Insights, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
(Optional) Configure an analysis
REST
Refer to the
conversations.analyses:create
API endpoint for complete details. Include any annotators that you want to run
in the annotatorSelector
object and set them to true
. Any annotators not
included will default to false
. If you don't specify any annotators in the
annotatorSelector
object all annotators will be run.
Before using any of the request data, make the following replacements:
- PROJECT_ID: your Google Cloud project ID.
- PHRASE_MATCHER(s): The fully qualified phrase matcher resource names of the phrase matchers you want to use for the phrase matcher annotator. If left empty, all active phrase matchers will run.
- ISSUE_MODEL(s): The fully qualified resource names of the issue models you want to use for the issue model annotator. Only works if run_issue_model_annotator is true. If left empty, all deployed issue models will run. Currently limited to 1 deployed model.
HTTP method and URL:
POST https://contactcenterinsights.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/conversations/CONVERSATION_ID/analyses
Request JSON body:
{ "annotatorSelector": { "run_interruption_annotator": {true/false}, "run_silence_annotator": {true/false}, "run_phrase_matcher_annotator": {true/false}, "phrase_matchers": PHRASE_MATCHER(s), "run_sentiment_annotator": {true/false}, "run_entity_annotator": {true/false}, "run_intent_annotator": {true/false}, "run_issue_model_annotator": {true/false} "issue_models": ISSUE_MODEL(s) } }
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/operations/OPERATION_ID" }
Poll the operation
Creating an analysis returns a long-running operation. Long-running methods are asynchronous, and the operation might not be completed when the method returns a response. You can poll the operation to check on its status. See the long-running operations page for details and code samples.