Coder Social home page Coder Social logo

Comments (4)

Luttik avatar Luttik commented on May 30, 2024 4

I found the following solution:

from google.protobuf.json_format import MessageToDict

result: DetectIntentResponse = detect_intent_texts([request_text], int(session_token, 16), agent_id)
messages = [MessageToDict(x) for x in result.query_result.fulfillment_messages]

This method seems works great it is just hard to find in the documentation.

@dysnomia Thanks for you assistance.

from python-dialogflow.

dysnomia avatar dysnomia commented on May 30, 2024

Yeah, this shared protobuf type only has very basic documentation at https://developers.google.com/protocol-buffers/docs/reference/python-generated#struct. There are some more usage examples https://github.com/google/protobuf/blob/master/python/google/protobuf/internal/well_known_types_test.py#L683.

About converting to/from Python types:

I'll file a bug to improve our shared documentation.

from python-dialogflow.

Luttik avatar Luttik commented on May 30, 2024

So serialization works for instance for converting to string, but ToJsonString for instance is not implemented on all objects.

And for instance a Message object does not implement .items(), for that you need to use ListFields() which works slightly different.

I keep running into errors because different object types are used in unexpected places (and a seemingly inconsistent fashion), and I need to convert these elements before i can do something like sending the dialogflow payload to the frontend.

from python-dialogflow.

nnegrey avatar nnegrey commented on May 30, 2024

This appears to be answered, if not, please feel free to re-open.

Thanks! :)

from python-dialogflow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.