问题
I'm trying to send an EventInput using python dialogflow client v2 (https://dialogflow.com/docs/reference/api-v2/rest/v2beta1/projects.agent.sessions/detectIntent#eventinput) but couldn't set parameters.
Setting it to an object like
{"result_guid": "49A8608C-4854-4964-81C3-0A75F912B994"}
returns an error ValueError: Protocol message Struct has no "result_guid" field.
How can this be solved?
回答1:
found the solution. parameters
needs to be a google.protobuf.Struct so something like below works
from google.protobuf import struct_pb2
parameters = struct_pb2.Struct()
parameters["result_guid"] = "49A8608C-4854-4964-81C3-0A75F912B994"
event_input = dialogflow.types.EventInput(name=event_name, parameters=parameters, language_code=language_code)
来源:https://stackoverflow.com/questions/49416563/how-to-add-parameters-to-dialogflow-event-in-python