I'm setting up a lambda function using serverless that will be invoked through a Webhook in Google's NLP Dialogflow. My end goal is to be able to use the dialogflow-fulfillment library.
I have tried reinstalling node_modules by doing "npm install ..." to all the required modules. The package.json has all dependencies require.. using npm init
.
// handler.js
const debug = require('debug')('http');
const express = require('express')
const sls = require('serverless-http');
const app = express();
app.get('/', async (req, res, next) => {
//console.log(req + res);
const { WebhookClient } = require('dialogflow-fulfillment')
const agent = new WebhookClient({ req, res });
function justSayHi(agent) {
console.log(`Something's happening`);
agent.add('Hello from dialogflow-fulfillment');
}
let intentMap = new Map();
intentMap.set('justsayhi', justSayHi);
agent.handleRequest(intentMap);
console.log("webhook called")
});
module.exports.server = sls(app);
When printing the logs in the command prompt sls logs -f app
, I get the following error message:
"Unable to import module 'app': Error
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)"
Again, my end goal is to be able to use Dialogflow-fulfillment library utilizing the serverless architecture.
I'm wondering why it's saying unable to import module app
.
I'm open to restructuring how I have this set up also, I have not found a good way to do this so far.