I have this fullfillment dialogflow code
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
...............
app.intent('Control_Devices',(conv, { devices, status }) => {
return admin.database().ref(`/ESP8266/${devices}/value`).set(status)
.then(snapshot => {
conv.ask(`OK, ${devices} ${status}. Do you want more?`);
conv.ask(new Suggestions(intentSuggestions));
});
});
and have an error with return admin.database().ref().set() .then(snapshot =>{});
It cannot connect with my realtime database. Can anyone help me fix this !!!!
{
"name": "dialogflowFirebaseFulfillment",
"description": "This is the default fulfillment for a Dialogflow agents using Cloud Functions for Firebase",
"version": "0.0.1",
"private": true,
"license": "Apache Version 2.0",
"author": "Google Inc.",
"engines": {
"node": "8"
},
"scripts": {
"start": "firebase serve --only functions:dialogflowFirebaseFulfillment",
"deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment"
},
"dependencies": {
"actions-on-google": "^2.2.0",
"firebase-admin": "^5.13.1",
"firebase-functions": "^2.0.2",
"dialogflow": "^0.6.0",
"dialogflow-fulfillment": "^0.5.0"
}
}
This is my package.json
I edit to this but it isnt work
{
"name": "dialogflowFirebaseFulfillment",
"description": "This is the default fulfillment for a Dialogflow agents using Cloud Functions for Firebase",
"version": "0.0.1",
"private": true,
"license": "Apache Version 2.0",
"author": "Google Inc.",
"engines": {
"node": "8"
},
"scripts": {
"start": "firebase serve --only functions:dialogflowFirebaseFulfillment",
"deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment"
},
"dependencies": {
"actions-on-google": "^2.2.0",
"firebase-admin": "^7.0.0",
"firebase-functions": "^2.2.0",
"dialogflow": "^0.6.0",
"dialogflow-fulfillment": "^0.5.0"
}
}
Related
I added valid Environment Variables (PORT and Database URI) to Vercel.
When searching I found that whole project must be wrapped in "api" folder so i did it.
This is my configuration. I added everything I found. Am I missing something or i added something wrong?.
vercel.json
{
"version": 2,
"builds": [
{
"src": "./api/index.ts",
"use": "#vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "./api/index.ts"
}
]
}
package.json
{
"name": "back-app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon api/index.ts"
},
"engines": {
"node": "16.x"
},
"author": "",
"license": "ISC",
"devDependencies": {
"#types/express": "^4.17.16",
"#types/mongoose": "^5.11.97",
"#types/node": "^18.11.18",
"#types/nodemon": "^1.19.2",
"nodemon": "^2.0.20",
"typescript": "^4.9.5"
},
"dependencies": {
"body-parser": "^1.20.1",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"mongoose": "^6.9.1"
}
}
Vercel 404 Page`
I tried to deploy my app on vercel
I am actually a flutter developer and have configured an existing project whose admin panel is built in VUE.js and mobile app is built in flutter. I have configured this app many times for clients but can't do it for the last time.
This hosted VUE.app is making problem and this is not. Both's code are same except some of the library changes however both were deployed with some of the deprecation warnings to firebase ( I will provide those warnings if necessary).
Admin panel has two parts i.e BACKEND & FRONTEND
Backend:
Index.js where the api cloud function lies which is deployed on firebase-functions.
const functions = require('firebase-functions');
const api = require('./src/api');
const runtimeOpts = {
timeoutSeconds: 300,
memory: '1GB',
};
exports.api = functions
.runWith(runtimeOpts)
.https.onRequest(api);
And this is the api's index being called from above index.js
const express = require('express');
const cors = require('cors');
const app = express();
const authFirebaseService = require('../auth/authFirebaseService');
const authMiddleware = require('../auth/authMiddleware');
const {
init: databaseInit,
middleware: databaseMiddleware,
} = require('../database/databaseInit');
const bodyParser = require('body-parser');
databaseInit().catch((error) => console.error(error));
authFirebaseService.init();
app.use(databaseMiddleware);
app.use(authMiddleware);
app.use(bodyParser.json());
app.use(cors({ origin: true }));
const routes = express.Router();
require('./auditLog')(routes);
require('./auth')(routes);
require('./iam')(routes);
require('./settings')(routes);
require('./customers')(routes);
require('./suppliers')(routes);
require('./staff')(routes);
require('./products')(routes);
require('./brands')(routes);
require('./categories')(routes);
require('./expenses')(routes);
require('./expenseCategory')(routes);
require('./assets')(routes);
require('./devices')(routes);
require('./notice')(routes);
require('./sales')(routes);
require('./purchases')(routes);
require('./returns')(routes);
require('./stockAdjustments')(routes);
require('./units')(routes);
require('./giftCard')(routes);
require('./coupon')(routes);
require('./damages')(routes);
require('./leave')(routes);
require('./leaveType')(routes);
require('./allowanceAndDeduction')(routes);
require('./payroll')(routes);
require('./attendance')(routes);
require('./taxClass')(routes);
require('./todo')(routes);
require('./documents')(routes);
require('./paymentMethods')(routes);
require('./documentTypes')(routes);
require('./memos')(routes);
require('./currency')(routes);
require('./holiday')(routes);
require('./stall')(routes);
require('./variation')(routes);
require('./productLogs')(routes);
require('./stockTransfer')(routes);
require('./deviceSessions')(routes);
require('./productCount')(routes);
require('./productValue')(routes);
require('./register')(routes);
require('./commissions')(routes);
require('./transactions')(routes);
require('./priceChange')(routes);
app.use('/api', routes);
module.exports = app;
package.json:
{
"name": "app-backend",
"description": "Backend",
"scripts": {
"serve": "firebase serve --only functions",
"shell": "firebase functions:shell",
"start": "nodemon ./server.js",
"logs": "firebase functions:log",
"test": "nodemon --exec 'cross-env NODE_ENV=test mocha ./src/**/*.test.js --exit || exit 1'",
"predeploy:development": "firebase use development && firebase functions:config:set env.value=\"development\"",
"deploy:development": "firebase deploy --only functions",
"deploy:appengine:development": "gcloud app deploy app-engine.development.yaml --project <insert project id here>",
"predeploy:production": "firebase use production && firebase functions:config:set env.value=\"production\"",
"deploy:production": "firebase deploy --only functions",
"deploy:appengine:production": "gcloud app deploy app-engine.production.yaml --project <insert project id here>"
},
"dependencies": {
"cors": "2.8.5",
"express": "4.16.4",
"firebase-admin": "7.0.0",
"firebase-functions": "2.2.0",
"graphql": "14.1.1",
"graphql-fields": "2.0.1",
"graphql-iso-date": "3.6.1",
"graphql-tools": "4.0.4",
"graphql-type-json": "0.2.1",
"lodash": "^4.17.15",
"moment": "2.24.0",
"nodemailer": "5.1.1"
},
"engines": {
"node": "16"
},
"private": true,
"devDependencies": {
"cross-env": "5.2.0",
"firebase-functions-test": "0.1.6",
"mocha": "^6.2.2",
"node-mocks-http": "1.7.3",
"nodemon": "1.18.10"
},
"version": "1.0.0",
"main": "index.js",
"author": "Bilal Saeed",
"license": "ISC"
}
Frontend:
package.json
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "npm run start:localhost",
"start:localhost": "vue-cli-service serve --mode localhost --port 8081",
"build:localhost": "vue-cli-service build --mode localhost",
"start:development": "vue-cli-service serve --mode development --port 8081",
"build:development": "vue-cli-service build --mode development",
"deploy:development": "firebase use development && npm run build:development && firebase deploy --only hosting,storage",
"start:production": "vue-cli-service serve --mode production --port 8081",
"build:production": "vue-cli-service build --mode production",
"deploy:production": "firebase use production && npm run build:production && firebase deploy --only hosting,storage",
"lint": "vue-cli-service lint"
},
"dependencies": {
"axios": "^0.19.0",
"chart.js": "2.7.3",
"element-ui": "2.5.4",
"file-saver": "2.0.1",
"filesize": "4.1.2",
"firebase": "^9.9.1",
"lodash": "^4.17.15",
"md5": "2.2.1",
"moment": "2.24.0",
"nprogress": "0.2.0",
"portal-vue": "2.1.6",
"qs": "6.7.0",
"uuid": "7.0.3",
"vue": "2.6.7",
"vue-router": "3.0.2",
"vuex": "3.1.0",
"xlsx": "0.14.1",
"yup": "0.26.10"
},
"devDependencies": {
"#vue/cli-plugin-babel": "3.4.1",
"#vue/cli-plugin-eslint": "3.4.1",
"#vue/cli-service": "3.4.1",
"#vue/eslint-config-prettier": "4.0.1",
"babel-eslint": "10.0.1",
"eslint": "5.14.1",
"eslint-plugin-vue": "5.2.2",
"vue-cli-plugin-element": "1.0.1",
"vue-template-compiler": "2.6.7"
},
"main": ".eslintrc.js",
"author": "Bilal Saeed",
"license": "ISC",
"description": ""
}
I have no experience with configuration of VUE.js app, just read the provided manual for installation of software and whenever I faced any bug during configuration, I googled it. But in this case, I'm not having any error.
im trying to deploy a project to heroku , everything appears to work just fine but when trying to accsess the url given
this is what i see
can anyone have an idea what seems to be the problem?
i've tried looking for a solution via heroku.com but came up short.
if you need a screenshot of anything please tell me what is relevant cause i'm new at this.
here is the package.json for the backend
{
"name": "server",
"version": "1.0.0",
"engines": { "node": "14.x" },
"description": "production ready server",
"main": "server.js",
"scripts": {
"start": "node server.js",
"server:dev": "set NODE_ENV=development&&nodemon server.js",
"server:prod": "set NODE_ENV=production&&node server.js"
},
"author": "Me",
"license": "ISC",
"dependencies": {
"cors": "^2.8.5",
"express": "^4.17.2",
"express-session": "^1.16.2",
"express-socket.io-session": "^1.3.5",
"mongo": "^0.1.0",
"mongodb": "^3.7.3",
"socket.io": "^4.2.0"
},
"devDependencies": {
"nodemon": "1.18.10"
}
}
When deploying the Cloud Functions to the Firebase Cloud, they take a very long time right after the log "functions: all necessary APis are enabled".
I am deploying 6 functions.
I am using node 10 since using node 8 in combination with the URL module caused some errors that went away using node 10.
the package.json:
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"lint": "eslint .",
"serve": "firebase serve --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"dependencies": {
"babel-eslint": "^10.0.1",
"cheerio": "^1.0.0-rc.2",
"firebase-admin": "~7.0.0",
"firebase-functions": "^2.3.0",
"lighthouse": "^5.1.0",
"ping": "^0.2.2",
"puppeteer": "^1.17.0",
"puppeteer-extra": "^2.1.3",
"request": "^2.88.0",
"request-promise-native": "^1.0.7",
"url": "^0.11.0"
},
"devDependencies": {
"eslint": "^5.12.0",
"eslint-plugin-promise": "^4.0.1"
},
"engines": {
"node": "10"
},
"private": true
}
The deployment used to go much faster, but recently it started behaving differently.
I dont know when excactly it happened.
My questions are:
Does anyone know what the issue might be?
If no, does anyone know how I would go about 'debugging' this issue?
Thank you.
my app works fine local. But when I upload it to github and try to start it with heroku, it says "application error". The build log doesn't show any errors but the app log shows this:
and I think I my port connection is right:
const config = {
port: process.env.PORT || 3000,
};
app.listen(config.port);
package.json:
{
"name": "labo4",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon ."
},
"author": "",
"license": "ISC",
"dependencies": {
"ejs": "^2.5.7",
"express": "^4.16.3",
"glob": "^7.1.2",
"jade": "^1.11.0",
"path": "^0.12.7"
}
}
package.json
{
"name": "labo4",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"ejs": "^2.5.7",
"express": "^4.16.3",
"glob": "^7.1.2",
"jade": "^1.11.0",
"path": "^0.12.7"
}
}
By default Heroku will search for a start in your package.json so edit it as above.