mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-20 12:39:24 +00:00
fix check file
This commit is contained in:
@@ -4,19 +4,28 @@ const nanoid = require('nanoid')
|
|||||||
/**
|
/**
|
||||||
* Debes de tener tu archivo con el nombre "chatbot-account.json" en la raíz del proyecto
|
* Debes de tener tu archivo con el nombre "chatbot-account.json" en la raíz del proyecto
|
||||||
*/
|
*/
|
||||||
const CREDENTIALS = JSON.parse(fs.readFileSync(`${__dirname}/../chatbot-account.json`));
|
let PROJECID;
|
||||||
|
let CONFIGURATION;
|
||||||
|
let sessionClient;
|
||||||
|
|
||||||
const PROJECID = CREDENTIALS.project_id;
|
const checkFileCredentials = () => {
|
||||||
|
if(!fs.existsSync(`${__dirname}/../chatbot-account.json`)){
|
||||||
const CONFIGURATION = {
|
return false
|
||||||
credentials: {
|
|
||||||
private_key: CREDENTIALS['private_key'],
|
|
||||||
client_email: CREDENTIALS['client_email']
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const parseCredentials = JSON.parse(fs.readFileSync(`${__dirname}/../chatbot-account.json`));
|
||||||
|
PROJECID = parseCredentials.project_id;
|
||||||
|
CONFIGURATION = {
|
||||||
|
credentials: {
|
||||||
|
private_key: parseCredentials['private_key'],
|
||||||
|
client_email: parseCredentials['client_email']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sessionClient = new dialogflow.SessionsClient(CONFIGURATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new session
|
// Create a new session
|
||||||
const sessionClient = new dialogflow.SessionsClient(CONFIGURATION);
|
|
||||||
|
|
||||||
// Detect intent method
|
// Detect intent method
|
||||||
const detectIntent = async (queryText) => {
|
const detectIntent = async (queryText) => {
|
||||||
@@ -61,4 +70,6 @@ const getDataIa = (message = '', cb = () => { }) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkFileCredentials();
|
||||||
|
|
||||||
module.exports = { getDataIa }
|
module.exports = { getDataIa }
|
||||||
Reference in New Issue
Block a user