清除节点sdk中的传入代理上下文不起作用

时间:2018-05-27 00:46:05

标签: dialogflow

  • 我有一个带有'test_contexts'意图的dialogflow代理,启用了webhook。
  • 在匹配此意图时,我想使用完整填充来控制对话中的传入/传出上下文。
  • 我无法从对话框流中删除传入请求中的上下文。
  • 例如,在下面的代码中,如果传入请求包含“已登录”的上下文,则不会将其删除。

完整填充代码

'use strict';

const { WebhookClient } = require('dialogflow-fulfillment');
const { Card, Suggestion } = require('dialogflow-fulfillment');

exports.MyAgent = (request, response) => {

    // Create a webhookclient class
    const agent = new WebhookClient({ request, response });

    // Create function to test context control
    const test_context = function(agent){

        // fails to remove incoming context, set previously in the conversation
        agent.clearContext('loggedin');

        // fails to remove/modify incoming context, set previously in the conversation
        agent.setContext({ name: 'loggedin', lifespan: 0 });

        // successfully removes contexts set at the current point in the conversation, however, fails to remove any incoming contexts (as the name suggests)
        agent.clearOutgoingContexts();

    }

    // Define which functions are called for which intents
    let intentMap = new Map();
    intentMap.set('test_contexts', test_context);

    agent.handleRequest(intentMap);
}

如何删除从Dialogflow传入的上下文?!

1 个答案:

答案 0 :(得分:3)

agent.setContext({name:' loggedin',lifespan:-1});成功删除了上下文。