[英]How to add parameters to Dialogflow event in python
我正在嘗試使用python dialogflow client v2( https://dialogflow.com/docs/reference/api-v2/rest/v2beta1/projects.agent.sessions/detectIntent#eventinput )發送EventInput,但無法設置參數。
將其設置為類似{"result_guid": "49A8608C-4854-4964-81C3-0A75F912B994"}
將返回錯誤ValueError: Protocol message Struct has no "result_guid" field.
如何解決呢?
找到了解決方案。 parameters
必須是google.protobuf.Struct,因此以下內容可以正常工作
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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.