如何在python中向Dialogflow事件添加参数 [英] How to add parameters to Dialogflow event in python

查看:103
本文介绍了如何在python中向Dialogflow事件添加参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用python dialogflow client v2( https://dialogflow.com/docs/reference/api-v2/rest/v2beta1/projects.agent.sessions/detectIntent#eventinput ),但无法设置参数。

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.

将其设置为
{ result_guid: 49A8608C-4854-4964-81C3-0A75F912B994}} code>返回错误 ValueError:协议消息Struct没有 result_guid字段。

如何

推荐答案

找到了解决方案。 参数必须是google.protobuf.Struct,以便类似下面的内容

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)

这篇关于如何在python中向Dialogflow事件添加参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆