Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Dialogflow Intent Detection with Custom Entity

I have created a dialogflow agent which is using a datastore to answer user queries. The datastore includes information about new features available in my company's product, on a release note page.

The title of the release note page is "2024.1 release". When a user asks something like "What is new in 24.1 release", the agent is unable to recognise that this is the same as 2024.1, and just returns a fallback no match intent response.

To tackle this, I have created an entity, and added 24.1 as a synonym to 2024.1, and created a new intent so that the agent recognises these type of questions. When the user asks questions on this topic, I still want the response to come from the datastore. How should I structure the flow/route to achieve this?

1 15 1,716
15 REPLIES 15

Hi,

So you can do a couple of things:

1. first, lowering down the grounding level and set it to very low:

xavidop_0-1708514620038.png

2. When you added an intent, the intent will be hit before the data store so you will be transitioning to a flow or a page. See the order of evaluation:

xavidop_1-1708514760443.png

3. you can change your data store to add this synonym in your docs.

Would love the input from @alessiasacchi here too.

Best,

Xavi

 

 

@xavidop what I am currently doing is mapping the intent, which then transitions to a new page. Is there a way to get the response when the new page is started, by taking the input from the previous conversation turn?
Changing the grounding to very low is degrading the answers for other questions, so not preferring that option

Actually, there is no way of calling the data store when you are transitioning. What do you think about the idea of modifying the docs? I know it is  a patch

@xavidop sure I will try this option.
Just to clarify, I am using jsonl file, which has the gcs location for the document, and url of the actual page, one sample line is like this -

{"id": "d00000001", "content": {"mimeType": "text/html", "uri": "<gcs-location>"}, "structData": {"title": "Check out our new features | Reltio", "url": "<url>"}}

Do I need to mention 24.1 somewhere here, or in the content of the actual page itself?
 

you will need to mention it in the content of the actual page

@xavidop Ok understood, thanks for your help 😁

please keep me posted how that goes.

Hi! You could connect a generator to your information retrieval system, to dynamically retrieve the information based on the query. You can simply save the output of that system into a parameter and connect it to a placeholder in the prompt. Since you have the release number stored in a session param you could also inject that information in the prompt as a custom placeholder. The generator will be triggered as part of the route fulfillment.

In the past to handle multiple datasources (it'd fit in this scenario too) I have found a solution using Playbooks and data store tools.

Create a default generative agent and a datastore tool. The tool will query the data store for answers. Below are the instructions I have provided to the default generative agent:
 
- If the user asks about Google Store products use ${TOOL: Google Store Datastore}
- Display the answer you have retrieved
 
You can configure the data store summarization prompt to include the conversation and the session parameter. The generative agent can further provide instructions on how to proceed with the answer from the data stores or how to respond when there is no answer.
 
I know playbooks are currently available in public preview in the global and us-central1 regions and that only en is supported at the moment but I hope this still helps. 
 
 
playbook.png
 

 

 

I have read the thread with Xavier. So since you're dealing with a JSON object, you can write your generator to accept an input JSON object from webhook and then perform information retrieval and search in the content of your JSON.

 
Here's a sample prompt:
You are specialized in extracting information
from both structured and unstructured data formats like CSV, SQL, JSON,
and also plain text.

Given an existing $json-object, extract the information requested
by the user from the $last-user-utterance

EXAMPLE:
json_object = $json_object
User: What is new in 24.1 release?
Agent: In v.2024.1 we have added the following new features. Feature 1:
User: $last-user-utterance
Agent:
 

I believe that's already at least partially addressed. The user has created a route for that intent meaning we are bypassing data store, so now we need to find a way to answer the question using the data we have. I do expect that regardless of what's mentioned in the json 24.1 or 2024.1 we are able to query the data store, find the answer and generate a response (via generator). In the worst scenario the prompt can be further engineered to something like: "Do the following rewrite: if the user only provides the last two digits of the year, prepend it accordingly to match format YYYY. 
Example: "What's new in 24.1?" should be rewritten as ""What's new in 2024.1?"" 

Obviously these are all suggestions that I have not tested. 

Thanks @alessiasacchi will try out these solutions

@alessiasacchi Great to read this conversation on using generators with playbook and tool. 
In the same context, would like to know your suggestion of filtering datastore values based on session context.

Ex: Assume i already uploaded JSONL files with all release notes along with a metadata field Category. So some htmls  are mapped to category: 'Sales', and some with category:'Marketing'

In the session i have user_category. Is it possible to use this session variable somewhere to inform the datastore to search only the documents with the metadata category: $session.params.user_category.

- Should we use Custom Prompt in DataStore in the Agent Settings ?. 
- Do we need to create a Prompt in Generative Fallback. 

Like this
```
While searching datastore search only the documents related to the $session.params.user_category
```

Hi Nirmal,

I think you will need to create a custom prompt as you suggested to to have a better or improved summary based on $user_category

Best,

Xavi

Thanks Xavi, I will check it out and update the thread.

Great question and apologies for the delay. So I think data store filtering is precisely what we need here:

"In some cases, you may only want certain data stores available for queries, depending on session parameter values. For example, you may have unique data stores for product categories. To accomplish data store filtering for product categories:

  • Set session parameters to product categories.
  • Create condition routes that check the values of the session parameters and transition to a specific page that has the desired data store handler.
  • The data store handler should transition back to the calling page, so that the conversation can continue."

What this is suggesting is to use N data stores where N is the number of categories. Use $session.params.user_category to check the current category and then transition to a specific page that has the desired data store handler or a playbook which has been configured with a data store tool. Then transition back to the calling page, so that the conversation can continue. 

Alternatively you could test the custom prompt you suggested however the previous approach seems a lot more deterministic and you would almost certainly query the right data store due to the conditional routing. Let us know!!