Coder Social home page Coder Social logo

Comments (5)

dysnomia avatar dysnomia commented on June 8, 2024 3

Please see

The code should look something like:

intents_client = dialogflow.IntentsClient()
contexts_client = dialogflow.ContextsClient()
# ...
parent = intents_client.project_agent_path(project_id)
intent = dialogflow.types.Intent(
  display_name=display_name,
  output_contexts=[
    dialogflow.types.Context(
        name=contexts_client.context_path(project_id, "-", "name"),
        lifespan_count=5)
  ],
  # ... add other fields        
)
response = intents_client.create_intent(parent, intent)

You may also want to use update_intent (https://dialogflow-python-client-v2.readthedocs.io/en/latest/gapic/v2/api.html#dialogflow_v2.IntentsClient.update_intent) with an appropriate update mask.

from python-dialogflow.

dysnomia avatar dysnomia commented on June 8, 2024 3

Structs comes is shared non-Dialogflow specific type. Please use:

from google.protobuf import struct_pb2
payload = struct_pb2.Struct()
payload['test'] = 1

from python-dialogflow.

Akashutreja avatar Akashutreja commented on June 8, 2024

Thanks a lot, It works!

from python-dialogflow.

Akashutreja avatar Akashutreja commented on June 8, 2024

Hi @dysnomia ,
can you please tell me how to add payload as rich message for an unspecified platform. I did exactly same as above you have done for text.
I write this code.

text = dialogflow.types.Intent.Message.Text(text=message_texts)
message = dialogflow.types.Intent.Message(text=text)
data={"askingformood":"true"}
payload=dialogflow.types.Intent.Message.Struct(payload=data)
message=dialogflow.types.Intent.Message(payload=payload)
intent_id=_get_intent_ids(project_id,"welcome-intent")
print(intent_id)
intent = dialogflow.types.Intent(
display_name=display_name,
training_phrases=training_phrases,
messages=[message],
output_contexts=[
dialogflow.types.Context(
name=contexts_client.context_path("fir-chatbot-ccc2d", "-", "next-output"),lifespan_count=1)],
input_context_names=["projects/project_id/agent/sessions/-/contexts/name"],
payload=[payload]
)

And I am getting this error.
AttributeError: type object 'Message' has no attribute 'Struct'
please help.
thanks

from python-dialogflow.

Akashutreja avatar Akashutreja commented on June 8, 2024

Thanks @dysnomia

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.