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

Data store agents on dialogflow cx access session parameter in generative fallback template

how can I access session parameter in generative fallback template
in a format like: 
relate in your response to this data: $session.params.additionalInfo
and send an API call like this:

additional_info = "5*4";
const dialogflowResponse = await fetch('https://' + LOCATION + '-dialogflow.googleapis.com/v3/projects/' + PROJECT_ID + '/locations/' + LOCATION + '/agents/4f05d821-977a-4def-b241-cexxxxxx/sessions/session-003:detectIntent', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${TOKEN}`,
},
body: JSON.stringify({
queryInput: {
text: {
text: text,
},
languageCode: 'iw',
},
queryParams: {
parameters: {
additionalInfo: additional_info
}
},
}),
});
0 1 163
1 REPLY 1

Hi @arickatz,

Welcome to Google Cloud Community!

Session parameters cannot be directly accessed within a generative fallback template in Dialogflow CX. These templates are designed to generate general responses when no specific intent matches, and they do not automatically use the agent's session data. However, you can achieve the desired behavior by using a webhook. Here are some possible ways to address your issue:

  • Create Your Webhook:
    • Develop a serverless function (using services like Cloud Functions) to act as your webhook.
    • This function will receive the Dialogflow CX request, which includes the session parameters.
    • The webhook will extract the necessary session data (like additionalInfo), make the necessary API call, and process the response.
    • Ensure that the function returns a JSON response in the format expected by Dialogflow CX (e.g., fulfillmentMessages).
  • Configure Your Fallback Intent:
    • Set up your fallback intent in Dialogflow CX to trigger your webhook when no matching intent is found.
    • This will allow the fallback intent to process session parameters and call the webhook.
  • Handle Your Webhook Response:
    • The webhook will process the session parameters and send a response back to Dialogflow CX in the required format (typically as fulfillmentMessages).
    • Map this webhook response to the appropriate fulfillment or response in Dialogflow CX.
  • Secure Your API Keys:
    • For security, store your API keys in a safe location, such as environment variables or a secrets management service.
    • Avoid hardcoding sensitive information like API keys directly in your code.

I hope the above information is helpful.