How can we configure Context & Events in Inline Code editor

送分小仙女□ 提交于 2020-07-23 11:08:09

问题


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' }});

回答1:


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"});

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.

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.



来源:https://stackoverflow.com/questions/62421668/how-can-we-configure-context-events-in-inline-code-editor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!