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

Inserting Dynamic Source URLs in Dialogflow Data Store Agent Responses

Hello everyone,

I'm developing a Dialogflow agent and need assistance with including dynamic source URLs in the agent's responses, which are generated by data store agents. In the fulfillment's 'Agent says' section, the default is $request.knowledge.answers[0]. I want to append the source of the response as a clickable link but am uncertain about the correct placeholder syntax for this within Dialogflow's ecosystem.

After reviewing the fulfillment documentation, I found it does not clearly address the use cases for data store agents. To address this, I customized my summarization prompt for Generative AI Data Stores, aiming to include source links in the system's responses. Despite adhering to the guidelines in the documentation, I haven’t found any placeholders for dynamically inserting the source URL, and the custom prompt does not seem to generate the link either. Here is the custom prompt I've crafted:

Your task is to assist users in finding information on the *** website. When responding to user queries, use the information from the provided sources. Provide the answer in Italian, cite the sources with square bracketed numbers, and do not introduce additional information. If the answer is not found within the sources, respond with "NOT_ENOUGH_INFORMATION". For each answer, add a direct link to the source for more information.

Guidelines for your response:
+ Use the exact wording from the sources when possible.
+ All numerical data must be consistent with the sources.
+ Your answer must be comprehensive and include all relevant details, caveats, and conditions from the sources.
+ Cite the sources at the end of each statement.
+ Respond in Italian.

Now, let's answer the user's query step by step, making sure to use the provided sources.

Query: $original-query
Sources: $sources
Conversation history: $conversation

Remember to include a link to the source information for additional insights. Use the phrase: "Per maggiori informazioni, visita [insert source link here]." Replace '[insert source link here]' with the actual link of the source chosen for your answer. If the precise format for embedding the link is unclear, use a clear and direct description to indicate the link, ensuring it is easily recognizable and accessible to the user.


Could anyone provide guidance on the correct placeholder or method to dynamically insert source URLs into Dialogflow agent responses? If you've encountered and overcome this challenge, or know of any resources that could help, your advice would be invaluable.

Solved Solved
0 9 1,983
1 ACCEPTED SOLUTION

Hi,

You ca play with it like this: using system functions to retrieve the fields:

https://cloud.google.com/dialogflow/cx/docs/reference/system-functions#func-get

After a bit of investigation, I found out that the URI and title fields could be extracted from request.knowledge.sources using the following:

$sys.func.GET_FIELD($sys.func.GET($request.knowledge.sources[0], 0), "uri")

$sys.func.GET_FIELD($sys.func.GET($request.knowledge.sources[0], 0), "title")

Which integration are you using? by default, in the webchat integration it shows the clickable buttons.

Regards,

View solution in original post

9 REPLIES 9

Hi,

You ca play with it like this: using system functions to retrieve the fields:

https://cloud.google.com/dialogflow/cx/docs/reference/system-functions#func-get

After a bit of investigation, I found out that the URI and title fields could be extracted from request.knowledge.sources using the following:

$sys.func.GET_FIELD($sys.func.GET($request.knowledge.sources[0], 0), "uri")

$sys.func.GET_FIELD($sys.func.GET($request.knowledge.sources[0], 0), "title")

Which integration are you using? by default, in the webchat integration it shows the clickable buttons.

Regards,

Hi,

Thank you for your response. The extraction methods you provided work perfectly. I use T*elegram integration. Now the source link appears in the agent's responses, and it's clickable too. Appreciate the help!

Best,

cool!

Hi, could you please share how did you achieve that?

I'm also trying to add a link to the response, where I need to add $sys.func.GET_FIELD($sys.func.GET($request.knowledge.sources[0], 0), "uri")?

I tried like this but it didn't work 

tried both 

$sys.func.GET_FIELD($sys.func.GET($request.knowledge.sources[0], 0), "uri") 

and $sys.func.GET($request.knowledge.sources[0])

Timur_0-1710859591657.png

 

could you please help?

thank you in advance!

Hi @Timur ,

I've kept the summarization prompt default and made the changes in the 'Agent says' section of the fulfillment settings. There, I inserted the $sys.func.GET_FIELD($sys.func.GET($request.knowledge.sources[0], 0), "uri") directly into the response template. This approach worked well for me while enabling the source link to be both present and clickable in the responses.

hyperlink.png

Hope this helps!

Best regards,

this is great, and working thank you!

I was also experimenting with summarization, and looks like I found a way to add a link with using it:

Timur_0-1710862572177.png

but don't forget to add channel specific response (I'm using google chat)

Timur_1-1710862627871.png

but I still have the problem with link view (if link has spaces):

Timur_2-1710862763417.png

however I'm glad that link at least showing up, thanks again!

 

 

Perfect!

Hi there! One quick question

I am doing exactly what you described but i have a little problem.

The URL appears, but is not clickable. I think the problem is related with the fact that i am not able to load a Custom payload; when i try to do it, instead of appearing an Image, or an URL or anything,  the custom payload itself it is outputed in plain text, despite choosing the Custom Payload option in the Fullfilment

1.png2.png

Any ideas what could be happening?

Thanks in advance

glad that you found the solution @Timur !