Overview
Custom Highlights functions in a similar way as the Smart Highlights feature. A highlight contains keywords, phrases or sentences that Insights recognizes as being important to determining the user's intent. If highlights are present, they are labeled in the returned transcript. Smart Highlights automatically detects highlights based on a range of pre-set scenarios, while Custom Highlights lets you specify custom criteria that should be recognized as highlights.
A custom highlight can be made up of one or more phrase match rule groups. A phrase match rule group contains one or more rules. You can use the following parameters to customize the behavior of your rules.
Rules to determine a match
You can specify whether a highlight should be detected if only one of the
rule groups resolves to true
, or if all of the rule groups resolve to true
.
Similarly, you can specify that a rule group should resolve to true
if only
one of its rules is met, or if conditions for all rules in the rule group must
be met.
Create a custom highlight using the Insights API
Detect "any of" a list of specified query strings
The following sample creates a
PhraseMatcher
object that tells Insights to add highlight labels to
either of two phrases whenever they appear in a conversation. Both phrases
don't need to appear in order to be detected as a highlight.
REST
See the
PhraseMatcherType
and PhraseMatchRuleGroupType
reference documentation for complete details. Substituting PHONE
and
CELLPHONE
for the two query
fields should result in the sample output.
Before using any of the request data, make the following replacements:
- PROJECT_ID: your Google Cloud project ID.
- DISPLAY_NAME: the human-readible name of the phrase matcher.
- QUERY: the word or phrase to be matched.
HTTP method and URL:
POST https://contactcenterinsights.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/phraseMatchers
Request JSON body:
{ "display_name": DISPLAY_NAME, "type": "ANY_OF", "active": true, "phrase_match_rule_groups": { "type": "ANY_OF", "phrase_match_rules": { "query": QUERY "config": { "exact_match_config": {} } }, "phrase_match_rules": { "query": QUERY "config": { "exact_match_config": {} } } } }
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/phraseMatchers/PHRASE_MATCHER_ID", "revisionId": "REVISION_ID", "revisionCreateTime": "2021-01-20T10:10:10.123000Z", "displayName": "PHONE_SERVICE", "type": "ANY_OF", "active": true, "phraseMatchRuleGroups": [ { "type": "ANY_OF", "phraseMatchRules": [ { "query": "PHONE", "config": { "exactMatchConfig": {} } }, { "query": "CELLPHONE", "config": { "exactMatchConfig": {} } } ] } ], "activationUpdateTime": "2021-01-20T10:10:10.123000Z" }
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.
Detect "all of" a list of specified query strings
The following sample creates a
PhraseMatcher
object that tells Insights to add highlight labels to
conversations that do contain the query words in the first
phraseMatchRuleGroups
but also do not contain the query words in the
second 'phraseMatchRuleGroups`.
REST
See the
PhraseMatcherType
and PhraseMatchRuleGroupType
reference documentation for complete details. Substituting PHONE
and
CELLPHONE
for the two query
fields and SHIPPING
and DELIVERY
for the
second two query
fields should result in the sample output. The sample
tells Insights to add highlight labels to conversations that
contain "phone" and "cellphone" but don't contain "shipping" or "delivery".
Before using any of the request data, make the following replacements:
- PROJECT_ID: your Google Cloud project ID.
- DISPLAY_NAME: the human-readible name of the phrase matcher.
- QUERY: the word or phrase to be matched.
HTTP method and URL:
POST https://contactcenterinsights.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/phraseMatchers
Request JSON body:
{ "display_name": DISPLAY_NAME, "type": "ALL_OF", "active": true, "phrase_match_rule_groups": { "type": "ANY_OF", "phrase_match_rules": { "query": QUERY "config": { "exact_match_config": {} } }, "phrase_match_rules": { "query": QUERY "config": { "exact_match_config": {} } }, "phrase_match_rule_groups": { "type": "ALL_OF", "phrase_match_rules": { "query": QUERY "negated": "true" "config": { "exact_match_config": {} } }, "phrase_match_rules": { "query": QUERY "negated": "true" "config": { "exact_match_config": {} } } } } }
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/phraseMatchers/PHRASE_MATCHER_ID", "revisionId": "456456456", "revisionCreateTime": "2021-01-20T10:10:10.123000Z", "displayName": "NON_SHIPPING_PHONE_SERVICE", "type": "ALL_OF", "active": true, "phraseMatchRuleGroups": [ { "type": "ANY_OF", "phraseMatchRules": [ { "query": "PHONE", "config": { "exactMatchConfig": {} } }, { "query": "CELLPHONE", "config": { "exactMatchConfig": {} } } ] }, { "type": "ALL_OF", "phraseMatchRules": [ { "query": "SHIPPING", "negated": true, "config": { "exactMatchConfig": {} } }, { "query": "DELIVERY", "negated": true, "config": { "exactMatchConfig": {} } } ] } ], "activationUpdateTime": "2021-01-20T10:10:10.123000Z" }
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.