1

I am trying to use the followup event to trigger an intent from the webhook code.

 const event_trigger = {
        followupEventInput: {
          name: "event_name",
          languageCode: "en-US"
        }
      };
      return response.json(event_trigger);

I am getting this error in the console:

Error: Can't set headers after they are sent.
at validateHeader (_http_outgoing.js:491:11)
at ServerResponse.setHeader (_http_outgoing.js:498:3)
at ServerResponse.header (/worker/node_modules/express/lib/response.js:767:10)
at ServerResponse.send (/worker/node_modules/express/lib/response.js:170:12)
at ServerResponse.json (/worker/node_modules/express/lib/response.js:267:15)
at V2Agent.sendJson_ (/srv/node_modules/dialogflow-fulfillment/src/v2-agent.js:226:26)
at V2Agent.sendMessagesResponse_ (/srv/node_modules/dialogflow-fulfillment/src/v2-agent.js:205:10)
at WebhookClient.send_ (/srv/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:486:19)
at promise.then (/srv/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:306:38)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:229:7)

Does returning the response.json() method not the best approach? What would work?

0 Answers0