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

How to extract URL from data store in Dialogflow

Hello,

I’m working on a chatbot that return answer together with the link to the article. I created datastore that congains metadata of title and URL. I use Data store to generate the response but I’m not sure how to get the URL from the metadata. 

0 1 137
1 REPLY 1

Hi @konradpsiuk,

Welcome to Google Cloud Community!

To retrieve URLs from your datastore and generate responses in your chatbot, you can consider the following, which might help you answer your current scenario:

Using the $entity parameter in your response (Dialogflow CX) : The $entity parameter allows you to directly reference fields from your datastore entity in your Dialogflow responses. It is particularly useful when your datastore has a straightforward structure.

  • Datastore Setup: You need a Dialogflow CX agent and a connected datastore. This datastore must contain entities with fields, including one named “url” and another named “title.”
  • Intent and Parameters: Create an intent in your Dialogflow CX agent. This intent will need a parameter, let’s call it “myData”, that is linked to an entity type in your datastore. This entity type must match the structure of your datastore entities (containing “title” and “url”)
  • Fulfillment: When the intent is triggered, the fulfillment receives the “myData” parameter. This parameter contains the entire entity from your datastore. The “$entity” system parameter allows direct access to the fields within this entity. 
  • Response Template:  Your fulfillment response uses the “$entity.myData.title” and “$entity.myData.url” to construct the output string. The “$entity” prefix accesses the parameter, “.myData” specifies the parameter’s name, and “.title” and “.url” access the specific fields within that parameter.

I hope the above information is helpful.