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

Dialogflow UX: How to access the user.utterance

Hi everybody,

i would like to send the last User utterance to a Webhook, but there doesn´t seem to be a placeholder for this.
"$last-user-utterance" only works inside a Generator, but nowhere else.
Bard suggested "$session.params.user_message", which does not work.

How can i access that last User message? I would like to send it to a RAG pipeline for answering of "open question answering"

thanks

Solved Solved
0 8 2,089
1 ACCEPTED SOLUTION

this is the request that Dialgoflow sends to your webhook. You do not have to add the user utterance, dialogflow manages that for you!

View solution in original post

8 REPLIES 8

Hi you can get that information in the field called text under in the root object of a Dialgoflow request. This is an example of a Dialgoflow Request:

{
"detectIntentResponseId":"dsfsdaf-c5c9-46ce-bf2c-935396c08926",
"intentInfo":{
"lastMatchedIntent":"projects/my-project-123/locations/us-central1/agents/sddadsa-576c-4bbb-bc27-34c276bfecd5/intents/00000000-0000-0000-0000-000000000000",
"displayName":"Default Welcome Intent",
"confidence":0.6684057
},
"pageInfo":{
"currentPage":"projects/my-project-123/locations/us-central1/agents/sadasd-d5fc-4eb7-88fc-c25169027aee/flows/68f7790d-5c1f-4546-bb53-8d641f8288b4/pages/21939010-3336-450d-ae8b-0c9926aec791",
"formInfo":{
"parameterInfo":[
{
"displayName":"pokemon",
"required":true,
"state":"FILLED",
"value":"pikachu"
}
]
}
},
"sessionInfo":{
"session":"projects/my-project-123/locations/us-central1/agents/sadasd-d5fc-4eb7-88fc-c25169027aee/sessions/7fab78-aac-10e-989-d99313ca4",
"parameters":{
"pokemon":"pikachu"
}
},
"fulfillmentInfo":{
"tag":"test"
},
"text":"Hi!",
"languageCode":"en"
}

Hey,

thanks for the reply! I´m not sure i understand your answer and how to work with a DF request payload this inside of Dialogflow? I´d simply like to add the User utterance to the Webhook request body: eg.: {"question": "$last-user-utterance"}

best regards

this is the request that Dialgoflow sends to your webhook. You do not have to add the user utterance, dialogflow manages that for you!

ah, great, thank you!

So basically im using a webhook and i need to send it a json object which is of the last user utterance. What do i add in the json object?. Last user utterance doesnt seem to work. Or how do i setup the page to that auto request is sent to the webhook

What i have understood:

- if you use a "standard webhook", the utterance is part of the request.

- if you use a "custom webhook", there is no way of accessing the utterance.

Still not sure what the product people had in their minds to do it this way, as it does not make any sense to me. Principally exposing the utterance for "standard webhooks" feels like an unnecessary data-leak, not having it for "custom" is diminishing the capabilities of Dialogflow UX.

 

Another question, is there any way to set the last-user-utterance via DFCX console?

To capture the last user message for a webhook or RAG pipeline, store it as a session parameter in Dialogflow (`$request.queryResult.text`), use `tracker.latest_message.get('text')` in RASA, or capture it in custom bots via `req.body.user_message` (Node.js/Python). Use `event.payload.text` in Botpress.