How to add parameters to Dialogflow event in python

主宰稳场 提交于 2019-12-12 12:50:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!