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

Problem with Conversational Agents session parameters - cloud function integration

Hi, I'm trying to use the tool from playbook.
My tool is conected with a cloud function that returns a JSON list. 
All conections are OK and tested.

My issue is that I get the answer from there, but when I try to use this in my converstational agents chat I get no value. How can I solve this?

First I tried to set this variable via playbook prompt, then I use in my function the fulfillment_response stuff, setting up the parameter json_resp, but still not working.

My example calling my function and didn't setting the variable properly:Captura de tela 2024-12-24 104625.png

At that time, I've already had the values:

Captura de tela 2024-12-24 104607.png

But, as you can see in the first image, the session parameter don't work.

Thanks

Solved Solved
1 5 974
1 ACCEPTED SOLUTION

Hi, this idea of call a variable doesn't work, so I tried to work with examples in the playbook tab, after some examples the playbook generate automaticly and that worked.

View solution in original post

5 REPLIES 5

Hi @GabrielBaptista,

Welcome to Google Cloud Community!

It looks like you're successfully calling your cloud function, receiving the expected JSON, and the outputActionParameters within your Dialogflow CX response have the json_resp parameter correctly populated. However, you're unable to access this data using $session.params.json_resp within your conversation agent's response.

Here are potential ways that might help with your use case:

  • Set Session Parameter in Cloud Function: You might want to create a fulfillment_response object to update the session parameter. In sessionInfo.parameters, set the parameter json_resp and convert your JSON response to a string using json.dumps(json_data).
  • Verify that the Parameter is Set: After deploying your updated Cloud Function, you may want to run a test and check that the response you receive, for example in the 'Agent response' tab or using the log explorer, now includes sessionInfo.parameters from the fulfillment.
  • Error Handling: You might want to ensure proper error handling is always included in your cloud function. In case the function fails, make sure not to return any faulty data that could disrupt the conversation.
  • Review Data type: You may want to consider storing a large and complex JSON as a string and then using JSON.parse in the chat.

For more information about Conversational Agents (Dialogflow CX), please refer to the documentation.

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, thanks for your answer!

When I posted it I've already had the fulfillment_response setup:

res = {
            "fulfillment_response": {
            "messages": [{"text": {"text": [json_data]}}]},
            'sessionInfo': {"parameters": {"json_resp": json_data}}
        }
        return res
 
That screenshot with the output parameters have the json_resp value from this.
The problem itself is that I cannot call it in the agent conversation, I try to call $session.params.json_resp and didn't show anything in the chat.

I'm also having problems using DFCX/Conv agents parameters. It looks like we can't set the parameter's scope, so the playbook can't be made aware of, and use the parameters. 

@MarvinLlamas do you know if is it a bug? because it's not only with me.

Hi, this idea of call a variable doesn't work, so I tried to work with examples in the playbook tab, after some examples the playbook generate automaticly and that worked.