0

I have a Dialogflow CX agent that returns a Custom payload. My client is a Python application using the dialogflowcx_v3beta1 SDK to call DetectIntent. The application needs to forward the custom payload in JSON format to another application, but I have been unable to find a way to convert the structured payload to JSON. There is no schema associated with the custom payload, which could be literally any valid JSON, and because it will simply be forwarded to another component, the application has no reason to interpret the content in any way.

Is there a way to serialize the custom payload to JSON?

  • I'm missing the content ... isn't JSON (by definition) already serialized and transmissible information? If the data you are getting has already been parsed into a Python dictionary, wouldn't we serialize this back to a JSON string? – Kolban May 25 '21 at 16:44
  • That's just it: the data is only made available by the SDK only as a protobuf structure. I would like to convert this back to JSON, so I can forward it to a different component using a different protocol. In other words, I would like to recover the original JSON from the protobuf structure. – Thorsten Nordholm Søbirk May 26 '21 at 14:16

1 Answers1

0

Unless you're asking a Python question, the "CX Solution" could be to use the Fulfillment text instead of the Custom Payload feature, and include there the serialized JSON.

  • This is certainly a possibility. However, my Dialogflow agent will often respond with both a fulfillment text and a custom payload, and it seems a little cludgey to me to have to write code to detect whether a fulfillment text contains JSON or not. – Thorsten Nordholm Søbirk May 26 '21 at 14:19