在Dialogflow中设置输出上下文 [英] Setting output contexts in Dialogflow
本文介绍了在Dialogflow中设置输出上下文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用Dialogflow的C#客户端库,我试图在webhook响应中设置输出上下文。但是,输出上下文字段是只读的。这是我的代码:
Using the C# client library for Dialogflow, I am trying to set the output context in a webhook response. However, the output context field is read only. This is my code:
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"
};
如何设置输出上下文?
推荐答案
我知道这是一个老问题,但是以防万一有人遇到相同的问题。
I know this is an old question but just in case someone has the same problem.
您不能分配新的列表到OutputContexts,您必须将它们添加到列表:
You can not assign a new list to OutputContexts, you have to add them to the list:
例如:
response.OutputContexts.Add(new Context
{
Name = $"{request.Session}/your_context",
LifespanCount = 1
});
这篇关于在Dialogflow中设置输出上下文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文