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

Dialogflow CX Datastore Filter Playbook in Datastore

I would like someone's help to create a simple filter.
Context: I'm trying to develop a filter that I can use in the Playbook parameter to find the file more specifically from the Datastore. My data repository is in the JsonL style, because it seemed to be the best way to use filters, but the documentation didn't explain much how I could declare them in the Dialogflow Playbook.

I followed the JSONL assembly examples, so I could
https://cloud.google.com/dialogflow/cx/docs/concept/data-store?hl=pt-br#structured

An example of how the jsonl looked,
{"id": "1", "structData": {"title": ".", "category": [""], "text": "extra extra", "schema": ["Title", "Category", "Question", "Answer", "Subtitle", "URL"]}, "content": {"mimeType": "application/pdf", "uri": "gs:///pdf/Acompanhamento Registral.pdf"}}

But I can't create a useful example of the input for the tool, I'm using this example in the playbook, I'll just translate it to English to make it easier.

- fallback: "Sorry, I couldn't find any information about [theme]"
- userMetada from Input(requestBody): "userMetada": "<filter_expression>", example: "category:(\"$theme\") OR title:(\"$theme\")"
- filter: "User question".

Kozato_0-1738071818004.png

Kozato_1-1738071840635.png

The Tool provides the information, but I would like there to be a way for me to be sure that it didn't make a mistake, because many times I get an error message because it didn't even do the search.

If anyone can help me with examples of filters for these types of problems, I would appreciate it.

It looks like the Agent Builder in the datastore has a new schema feature, but it is in preview. Has anyone used it?



0 2 435
2 REPLIES 2

Hi Kozato,

Welcome to the Google Cloud Community!

It seems like you're exploring how to implement filters in your Dialogflow CX Datastore Playbook with JSONL data, and you're looking for ways to optimize the process. Here are some ways that might help with your use case:

  • Understand Filter Syntax: To use filter syntax, first access nested fields with dot notation (e.g., structData.title). For string matching, use field:("value"), placing the value in parentheses when special characters are involved. For array matching, use field:("value") to check if an array contains a particular value. Logical operators like OR, AND, and NOT can combine multiple conditions, while field:CONTAINS("value") checks if a field contains a specific value.
  • Construct Filter Expressions: Build precise filter strings by utilizing the appropriate syntax for your specific needs. You can use parameters, such as $theme, to create dynamic filters that adjust based on different inputs or conditions. 
  • Implement in Playbook: To filter your Datastore search, place your filter expression in the filter field of the Tool's Input section. Make sure that parameters like $theme have their intended values so that the filter expression works as expected.
  • Debugging and Testing: Begin with a simple filter, such as filtering by structData.title, to ensure basic functionality. Then, check your Dialogflow logs to see the exact filter being applied, which helps identify any issues. Gradually increase the complexity of your filters, testing after each change to ensure everything works as expected.
  • Error Handling: Make sure your tool has a clear fallback response in case no results are found. This fallback should be separate from the agent's fallback response, specifically addressing situations where the filter yields no matches.

You can find further information on these topics in the Dialogflow CX documentation: 

Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.

@nikacalupas 

Thank you for clarifying some doubts I had, even regarding what to search for. However, I might have other questions based on your answers.

For example:
- Where exactly should I apply this filter? Should it be in `GOAL/Instructs` or directly in the summary of the Datastore prompt?
- Could you provide a direct example of how to apply it? I attempted to implement something, but I couldn't fully extract the knowledge you provided.

I would really appreciate your help in overcoming this obstacle.

Kozato_1-1738278310204.png

 

I even considered passing `structData.title` in `userMetadata`, but that might not have been the best approach.

This part was quite confusing, and the examples in the documentation didn’t really help.

In the Original Response, it even brings the information, the problem here too is that it doesn't present the text or doesn't show it, maybe I'm a bit of an idiot in this part, but I can't achieve the objective.