Hi everyone, I’m working on a Dialogflow CX agent that uses a datastore handler to fetch answers for user queries. The datastore query takes around 3-4 seconds to process, and I’d like to display a partial response (e.g., "Please wait while we process your request...") to users while the query is being processed (Not sure is there a simple way to achieve this behaviour).
Here’s what I’ve tried so far:
Using a webhook and enable partial response:
I created a webhook (and enable the partial response check) that sends the user question to the agent with the datastore and waits for the response. However, the webhook doesn’t seem to handle getting the responses properly. It sends the question to the agent but doesn’t get the response.
Here’s part of my webhook code:
// Initialize Dialogflow Sessions Client
const client = new SessionsClient({
apiEndpoint: 'global-dialogflow.googleapis.com', // Use this for global agents
});
functions.http('dialogflowWebhook', async (req, res) => {
console.log('Dialogflow Request Body:', JSON.stringify(req.body, null, 2));
try {
const parameters = req.body.sessionInfo?.parameters || {};
const userQuestion = parameters.user_question || 'No question provided';
const sessionId = req.body.sessionInfo?.session.split('/').pop(); // Extract Session ID from the session path
// Construct the session path for a global agent
const sessionPath = client.projectLocationAgentSessionPath(
projectId,
location,
agentId,
sessionId
);
// Build the query input
const request = {
session: sessionPath,
queryInput: {
text: {
text: userQuestion,
},
languageCode: 'en-US',
},
pageSize: 1,
};
console.log('Extracted user question:', userQuestion);
// Send the query to Dialogflow
const [response] = await client.detectIntent(request);
...
Solved! Go to Solution.
Hi @r2carrillo,
Welcome to the Google Cloud Community!
Your webhook triggers the Datastore query but fails to handle Dialogflow CX's final response, preventing you from delivering the complete answer to your user. You can send the ‘userQuestion’ to Dialogflow but can't retrieve your corresponding response.
Here are the potential ways that might help with your use case:
Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.
Hi @r2carrillo,
Welcome to the Google Cloud Community!
Your webhook triggers the Datastore query but fails to handle Dialogflow CX's final response, preventing you from delivering the complete answer to your user. You can send the ‘userQuestion’ to Dialogflow but can't retrieve your corresponding response.
Here are the potential ways that might help with your use case:
Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |