完整填充代码
'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传入的上下文?!
答案 0 :(得分:3)
agent.setContext({name:' loggedin',lifespan:-1});成功删除了上下文。