Dialogflow es 是否使用DialogFlow实现更新所有上下文的参数值?

Dialogflow es 是否使用DialogFlow实现更新所有上下文的参数值?,dialogflow-es,dialogflow-es-fulfillment,Dialogflow Es,Dialogflow Es Fulfillment,如何使用DialogFlow实现库更新参数值?我编写了一个helper方法来访问代理的上下文并通过更新值进行循环,但这似乎不起作用: export const dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => { const wbhc = new WebhookClient({ request, response }); function testIntentH

如何使用DialogFlow实现库更新参数值?我编写了一个helper方法来访问代理的上下文并通过更新值进行循环,但这似乎不起作用:

export const dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
    const wbhc = new WebhookClient({ request, response });

    function testIntentHandler(agent: any) {
        const date = agent.parameters['date'];
        const datePeriod = agent.parameters['date-period'];

        if (date && !datePeriod) {
            setDialogFlowParameter('date-period', {
                startDate: date,
                endDate: date
            }, agent.context);
        }

        agent.add("I've set the value");
    }

    // Run the proper function handler based on the matched Dialogflow intent name
    const intentMap = new Map();
    intentMap.set('TestIntent', testIntentHandler);
    wbhc.handleRequest(intentMap);
});

function setDialogFlowParameter(param: string, val: any, context: any) {
    const contexts = context.contexts;
    const keys = Object.keys(contexts);

    for (const key of keys) {
        const c = context.get(key);
        c.parameters[param] = val;
        context.set(key, c.lifespan, c.parameters);
    }
}

请注意,这个问题集中在NodeJS dialogflow fulfillment library上,经过数小时的搜索,我找不到答案。

您是否查看了dialogflow控制台“诊断信息”中“fulfillment RESPONSE”选项卡的输出上下文属性?在使用agent.context.set()方法并更新参数值后,应该能够看到其中的值