当我使用实现在dialogflow中设置上下文时出现错误

时间:2019-08-16 13:47:24

标签: dialogflow dialogflow-fulfillment

当我尝试设置用于获取用户参数的上下文时,它会在agent.context.set方法上引发错误。

exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
    const agent = new WebhookClient({ request, response });
    console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
    console.log('Dialogflow Request body: ' + JSON.stringify(request.body));

agent.context.set({
    'name':'test-context',
    'lifespan': '5'});
function getUserInfo(agent) {

      // Get Actions on Google library conv instance
      const [fullname, email, age, disease, city, hospital, beneficiary_name, beneficiary_name_relation] = [agent.parameters.fullname,
        agent.parameters.email,
        agent.parameters.age,
        agent.parameters.disease,
        agent.parameters.city,
        agent.parameters.hospital,
        agent.parameters.beneficiary_name,
        agent.parameters.beneficiary_name_relation];

我遇到以下错误:

TypeError: Cannot read property 'set' of undefined
    at exports.dialogflowFirebaseFulfillment.functions.https.onRequest (/srv/index.js:26:17)
    at cloudFunction (/srv/node_modules/firebase-functions/lib/providers/https.js:57:9)
    at /worker/worker.js:783:7
    at /worker/worker.js:766:11
    at _combinedTickCallback (internal/process/next_tick.js:132:7)
    at process._tickDomainCallback (internal/process/next_tick.js:219:9)

应该测试测试上下文,但会抛出此错误。 我该怎么办?

0 个答案:

没有答案