google-cloud-platform - 在 Dialogflow 中设置输出上下文
问题描述
使用 Dialogflow 的 C# 客户端库,我试图在 webhook 响应中设置输出上下文。但是,输出上下文字段是只读的。这是我的代码:
WebhookResponse response = new WebhookResponse
{
FulfillmentText = "This is a test",
OutputContexts = ... //Regardless of what I try and set OutputContexts to be, I get the error "property or indexer 'WebhookResponse.OutputContexts' cannot be assigned to -- it is read only"
};
如何设置输出上下文?
解决方案
我知道这是一个老问题,但以防万一有人遇到同样的问题。
您不能将新列表分配给 OutputContexts,您必须将它们添加到列表中:
例如:
response.OutputContexts.Add(new Context
{
Name = $"{request.Session}/your_context",
LifespanCount = 1
});
推荐阅读
- node.js - 在Node Js中将Mysql结果推送到数组
- python - 将一系列元组和列表解压缩成一维列表?
- css - 修复多轮播中项目之间的间距
- google-play - 卡住拒绝和更新循环谷歌播放控制台
- php - 如何使用 PHP cURL 从 xml 响应中访问数据?
- android - Google Places Android 显示错误“地点字段不能为空”?
- python - 按字符拆分 unicode 到列表中
- python - 无法使用烧瓶运行运行 Python 应用程序
- python - 将单个不同点添加到 python 中的现有 matplotlib 图
- html - 尝试切换图片尺寸,但总是选择小的