mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-18 03:29:15 +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
|
||||
*/
|
||||
const CREDENTIALS = JSON.parse(fs.readFileSync(`${__dirname}/../chatbot-account.json`));
|
||||
let PROJECID;
|
||||
let CONFIGURATION;
|
||||
let sessionClient;
|
||||
|
||||
const PROJECID = CREDENTIALS.project_id;
|
||||
|
||||
const CONFIGURATION = {
|
||||
credentials: {
|
||||
private_key: CREDENTIALS['private_key'],
|
||||
client_email: CREDENTIALS['client_email']
|
||||
const checkFileCredentials = () => {
|
||||
if(!fs.existsSync(`${__dirname}/../chatbot-account.json`)){
|
||||
return false
|
||||
}
|
||||
|
||||
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
|
||||
const sessionClient = new dialogflow.SessionsClient(CONFIGURATION);
|
||||
|
||||
|
||||
// Detect intent method
|
||||
const detectIntent = async (queryText) => {
|
||||
@@ -61,4 +70,6 @@ const getDataIa = (message = '', cb = () => { }) => {
|
||||
})
|
||||
}
|
||||
|
||||
checkFileCredentials();
|
||||
|
||||
module.exports = { getDataIa }
|
||||
Reference in New Issue
Block a user