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

Dialoglow CX Generator to fill parameter (NER for address)

Hi ,

I’m trying to set up a flow in Dialogflow CX where the user can search for locations (e.g., “X near me”), but I’m running into issues with handling cases where the user doesn’t provide an address or asks an unrelated question. Here’s what I’ve implemented and where I need help:

Context:

  • Datastore: The integration is with a website.
  • Desired Flow:
    1. From the Default Start Flow, if the user intent is “X near me,” route them to the X Near Me Flow.
    2. Once the intent is triggered, the user input is processed by a generator to extract a target address.
      • Example Input:
        • “Where can I find X near <address>” → Address is extracted.
        • “Where can I find X in my area?” → No address in the input.

Behavior Examples:
Case 1:
User: Where can I find the nearest mall?
Agent: (Intent route triggered)

  • Generator processes input → $session.params.address = null.
  • Agent: What is the address you want to use for your search?
  • If the user provides an address in the next input, the flow works perfectly: the generator extracts the address, and the flow routes to a webhook.

Case 2 (Problematic):
If the user provides unrelated input instead of an address, I want the Datastore to respond if it has a relevant answer. If the Datastore has no relevant answer, I want to route the user back to the start page. Currently, I can’t achieve this functionality.

Technical Setup:
Here’s how I’ve structured the flow so far:

  1. Intent Trigger:

    • If the intent matches, the user is routed to the X Near Me Flow.
  2. X Near Me Flow:

    • Process Address (Page):

      • Routes:
        • Route 1: $session.params.address != null → Route to Webhook (works as expected).
        • Route 2: $session.params.address = null → Route to Ask User For Address (Page).
    • Ask User For Address (Page):

      • Captures user input and routes to Get Address (Page).
    • Get Address (Page):

      • Entry Fulfillment: Generator processes input to extract an address and set $session.params.address.
      • Route: $session.params.address != null → Route to Webhook (works perfectly).
      • Event Handler: Includes a Datastore fallback.

What I Need Help With:
I want the following functionality when the address parameter remains null:

  • If the user’s input triggers a relevant Datastore response, display it.
  • If there’s no relevant Datastore response, redirect the user back to the start page.

I’ve tried using the Datastore fallback in the Get Address (Page), but I can’t get the desired behavior to work seamlessly.

Question:
How can I achieve this functionality while still supporting the address form-filling process and ensuring the Datastore fallback works correctly?

Any insights or suggestions would be greatly appreciated. Thanks in advance!

Flow: 

jordanshans_0-1731674540111.png

 

0 1 91
1 REPLY 1

Hi @jordanshans,

Welcome to Google Cloud Community!

The issue is that your current setup only checks for $session.params.address being null or not. It doesn't handle the scenario where the Datastore provides a response even if the address is still null. You need to incorporate the Datastore response into your routing logic.

Here's how you can modify your Dialogflow CX flow to achieve the desired functionality:

  1. Modify the Get Address Page:
  • Remove the direct route based solely on $session.params.address: Delete the route from Get Address that checks only for $session.params.address != null. This route is causing a premature jump to the webhook before checking the Datastore.
  • Add an Event Handler: This event handler is crucial. It needs to check for both the presence of an address and the Datastore response.
  • Event Handler Logic (Pseudocode):
// Get the Datastore response (this is how you access it; the exact method depends on your Datastore integration).
const datastoreResponse = getResponseFromDatastore(); 

if (datastoreResponse && datastoreResponse.length > 0) {
  // Datastore has a relevant response. Display it.
  displayDatastoreResponse(datastoreResponse); 
} else if ($session.params.address != null) {
  // Address was provided, route to the webhook.
  routeToWebhook();
} else {
  // No address and no Datastore response, go back to the Start Page.
  routeToStartPage();
}
  1. Add explicit routing in the Event Handler:
  • You need to use explicit Go to Page actions within the Event Handler to handle each case:
    • displayDatastoreResponse: This would be a page that simply displays the information from the Datastore. After the user reads it, it can route back to the Start Page.
    • routeToWebhook: This would be a direct route to the webhook.
    • routeToStartPage: This is a direct route to your Start Page.
  1. Enhance the Datastore Integration:

Ensure your Datastore integration provides a clear indication of whether a relevant response exists. A simple boolean flag (hasRelevantResponse) or an empty array in the response object would work well.

  1. Revised Flow (Conceptual):

     

Default Start Flow -> X Near Me Intent -> Process Address Page -> Get Address Page

Get Address Page:
  - Entry Fulfillment: Extracts address, sets $session.params.address.  If no address, `$session.params.address` remains null.
  - Event Handler:
    - Checks Datastore for relevant response.
    - IF Datastore response exists: Go to Datastore Response Page -> Go to Start Page
    - ELSE IF $session.params.address != null: Go to Webhook
    - ELSE: Go to Start Page
Datastore Response Page:
    - Displays Datastore response.
    - Go to Start Page

   

Important Considerations:

  • Error Handling: Add robust error handling in your Event Handler to gracefully manage unexpected situations, such as failures in the Datastore query or issues extracting the address.
  • Context Management: Consider using contexts to manage the flow and prevent unexpected behavior. For example, set a context at the start of the "X Near Me" flow and clear it if the user returns to the Start Page.
  • Testing: Thoroughly test your flow with various user inputs, including those with and without addresses, and those that do and don't trigger Datastore responses.

I hope the above information is helpful.