我们如何配置Context&内联代码编辑器中的事件 [英] How can we configure Context & Events in Inline Code editor
问题描述
我们如何配置Context& Dialogflow内联代码编辑器中的事件? 我已经尝试过以下选项,但是这些都不起作用.
How can we configure Context & Events in Dialogflow Inline Code editor? I have tried the options below, but none of these is working.
app.intent('test1', (conv)=>{
conv.Context.set({ name: 'weather', lifespan: 2, parameters: { city: 'Rome' }});
conv.followupEventInput.set({
'name':'Event_Sample',
"parameters": {
"parameter-name-1": "parameter-value-1",
"parameter-name-2": "parameter-value-2"
},
"languageCode": "en-US"
});
});
//conv.setContext({ name: 'weather', lifespan: 2, parameters: { city: 'Rome' }});
//conv.setfollowupEventInput({ name: 'event-name', languageCode: 'en-US', parameters: { parameter-name-1: 'parameter-name-1', parameter-name-2: 'parameter-name-2' }});
推荐答案
要设置上下文,您需要调用conv.contexts.set()
并提供上下文的名称和寿命. (可选)您可以提供可发送到会话的下一轮的参数.一个例子是:
To set a context you need to call conv.contexts.set()
and provide a name and lifespan for the context. Optionally you can provide parameters that you can send to a next turn in the conversation. An example would be:
conv.contexts.set("Foo", 5, {foo: "bar"});
在您的代码示例中,调用Context.set()
而不是contexts.set()
,并且在参数周围使用了{ }
,因此您提供的是一个对象,而不是三个单独的值.这很可能是您的上下文不起作用的原因.
In your code example calling Context.set()
instead of contexts.set()
and you used { }
around the parameters, so you are providing one object instead of three seperate values. This is most likely why you context isn't working.
您的后续活动也是如此.您正在调用FollowupEventInput()
而不是followup()
,并且由于{ }
,您正在使用单个对象设置参数,因此请删除这些参数.
The same goes for your follow-up event. You are calling FollowupEventInput()
instead of followup()
and you have are setting the parameters with a single object due to the { }
, so remove those.
有关的更多信息和示例上下文和后续事件可以在文档中找到.
More info and examples on context and follow-up events can be found in the docs.
这篇关于我们如何配置Context&内联代码编辑器中的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!