So as far we developers know, Twilio can be used for creating chat rooms, but for it is hard to create chat rooms for itself right, here Interplay is for rescue you from hassle to create chat rooms! as for this project, we created a demo chat room
Steps
1) Receiving authentication token from Twilio
Switch to Main tab and find and drop the 'Get-token' like this:
now we fetch them HTTP input and output itselfBy double clicking 'Get Token' you could add API keys which are provided by Twilio
2) /getClassStatus works used to get participient's name and fetchs status for waiting room
Node.js Function 1
var require = context.global.get('require');
if (msg.req.query.mindbodyId === undefined ||
msg.req.query.mindbodyId === null ||
msg.req.query.mindbodyId === '') {
return msg.res.status(400).send({
error: "missing 'mindbodyId'",
});
}
msg.topic = `SELECT mindbodyId, meetingStatus, hostStartTime, sessionInfo, className FROM conferenceDetailsNew WHERE mindbodyId = "${msg.req.query.mindbodyId}" AND participantType = "host"`;
return msg;
Node.js Function 2
var require = context.global.get('require');
msg.statusCode = 200;
msg.payload = msg.payload[0];
node.warn(msg);
return msg;
//res.status(200).send(msg.req.body);
3) When the room started, every participient's frontend is updated with host For Node.js function
var require = context.global.get('require');
if (msg.payload.hostStartTime === null) msg.topic = `UPDATE conferenceDetailsNew SET meetingStatus = "STARTED" WHERE mindbodyId = "${msg.payload.mindbodyId}" AND participantType = "host"`;
} else { msg.topic = `UPDATE conferenceDetailsNew SET meetingStatus = "STARTED", hostStartTime = ${msg.payload.hostStartTime} WHERE mindbodyId = "${msg.payload.mindbodyId}" AND participantType = "host"`;
}
return msg;
4) /getcurrentconferencedatails fetches and gives the responces on recieving current conference details
Node.js function 1
var require = context.global.get('require');
msg.mindbodyId = msg.req.query.mindbodyId;
msg.topic = `SELECT startTime, participantId, hostName, mindbodyId, hostStartTime, hostEndTime, className, artistName, hostThankyouUrl, guestThankyouUrl, guestThankyouUrl, productSkus FROM conferenceDetailsNew WHERE mindbodyId = "${ msg.req.query.mindbodyId }" AND participantType = "host"`;
return msg;
Node.js function 2
var require = context.global.get('require');
let parsedProductSkus = [];
if ( msg.payload.length > 0 ) { if (msg.payload[0].productSkus !== null && msg.payload[0].productSkus !== undefined) {
let cleanedProductSkusString =msg.payload[0].productSkus.replace(/\"\[/g, "\[").replace(/\]\"/g, "\]");
parsedProductSkus = JSON.parse(cleanedProductSkusString);
}
// Delete string key & add Json key
delete msg.payload[0]["productSkus"];
msg.payload[0].productSkus = parsedProductSkus;
msg.payload = msg.payload[0];
} else {
msg.statusCode = 400;
msg.payload = {
error: `No Details found for ${ msg.mindbodyId }`
};
}
return msg;
5) /UpdateroomId updates the twilio room ID for hosts and participients
var require = context.global.get('require');
let updateDetails = msg.payload;
msg.topic = ` UPDATE conferenceDetailsNew SET roomSid = "${updateDetails.roomSid}" WHERE mindbodyId = "${updateDetails.mindbodyId}" AND participantType = "host"`;
return msg;
6) the /update/subscription makes the POST requests updating all the participient`
Nodejs function
var require = context.global.get('require');
let res = msg.res;
let req = msg.req;
const {Twilio} = require('twilio');
let rulesArray = [];
// Default Include all Audio rulesArray.push({"type": "include", "kind": "audio"});
// Include-Rules
for (let i = 0; i < msg.payload.includeNames.length; i++) { rulesArray.push({"type": "include", "publisher": msg.payload.includeNames[i], "kind": "video"});
}
const apiKeySid = 'Your_API_ID';
const apiKeySecret = 'Your_API_Key_ID';
const accountSid = 'Your_Account_SID';
// console.log(`${apiKeySid} , ${apiKeySecret} , ${accountSid}`); const client = new Twilio(apiKeySid, apiKeySecret, {accountSid: accountSid});
// console.log(rulesArray);return;
client.video.rooms(msg.payload.roomSid)
.participants.get(msg.payload.subscriberIdentity)
.subscribeRules.update({
rules: rulesArray
}).then(result => {
res.status(200).send({"msg": "Subscription Updated"})
// console.log(`Subscribe Rules updated successfully for
${payload.subscriberIdentity}`);
})
.catch(error => {
console.error('Error updating rules ' + error);
res.status(400).send({"error_code": "failed_to_", "error_msg": error});
});
return msg;
7) Fetching JWT Tokens
First create a tab called 'Twilio web APIs' you can rename as your preference but for this, we like to stick to the first one, also create 'Main' tab, Hereafter they will referred as 'Twilio web APIs' and 'Main'
switch to 'Twilio web APIs' tab
For fetching and using Twilio services, a JWT token is needed for authorize and initiate the room
as in this project, the fetch the token with frontend '/tokenIV'8) Taking web recording of the meet
So sometimes we need to record our meeting instance and save to our databases for our future reference, now in this project we are retrieving the stream of our current meeting and saving to database.Note: as for this application , we prefers to keep a single MySQL database to carry the database-related operations and analysis
For first 'NodeJS function'
var require = context.global.get('require');
let res = msg.res;
const jwt = require("jsonwebtoken");
let req = msg.req; let inputBody = msg.payload;
let apikey = inputBody.API_Key;
if (!apikey) {
return res.status(403).send({
err_code: "unauthorized" });
} else {
//validating jwt
try {
let decoded = jwt.verify(apikey, "Your_key");
} catch (err) {
return res.status(403).send({
err_code: "Authentication failure",
});
}
// continue if validated
// Call to Get Conference Recording start here
let input = inputBody.mindbodyId;
if (input === undefined || input === null || input === "") {
return res.status(404).send({
err_code: "missing_mindbodyId",
});
}
}
msg.orig = msg.payload;
msg.topic = `SELECT * FROM conferenceDetailsNew WHERE mindbodyId = "${msg.payload.mindbodyId}" AND participantType = "host"`;
return msg;
For second 'NodeJS function'
var require = context.global.get('require');
if (msg.payload) {
msg.orig.roomSid = msg.payload[0].roomSid; msg.conferenceDetails = msg.payload[ 0 ];
}
return msg;
For third 'NodeJS function'
var require = context.global.get('require');
if (msg.payload.length > 0) {
compositionList = msg.payload;
let composition = compositionList[0];
if (composition.status !== 'completed') { msg.payload = { "Err_code": "conference_composition_in_progress" };
msg.statusCode = 400;
}
msg.composition = composition;
msg.payload.roomSid = msg.orig.roomSid;
return msg;
For fourth Node.js function
var require = context.global.get('require');
let conferenceLink = (msg.conferenceDetails.conferenceLink) ?msg.conferenceDetails.conferenceLink : "NOT_AVAILABLE";
let hostParticipantId = (msg.conferenceDetails.participantId) ? msg.conferenceDetails.participantId : "NOT_AVAILABLE";
let hostParticipantName = (msg.conferenceDetails.hostName) ? msg.conferenceDetails.hostName : "NOT_AVAILABLE";
let guestList = [];
if ( msg.payload.participants ) {
guestList = msg.payload.participants.map((obj) => {
return { "participantId": obj.sid, "participantName": obj.identity, "date_created": obj.date_created };
});
}
msg.payload = {
"roomId": msg.composition.room_sid,
"conferenceDuration": msg.composition.duration,
"host": {"participantId": hostParticipantId,
"participantName": hostParticipantName},
"guestList": guestList, "date": msg.composition.date_completed,
"conferenceLink": conferenceLink,
"compositionDownloadLink": msg.composition.links.media };
return msg;
9) Starting Room and connect participants
i) Updating host conference details and user roles
ii) Updating the other
participient in current running meeting
create the flow diagram by using necessary components like this:
This flow work when /startIV is get triggered
Node.js Function1 : Verifying JWT and API credentials for assigning rooms
var require = context.global.get('require')
let body = msg.payload; const jwt = require("jsonwebtoken");
const uniqid = require('uniqid');
const apiKey = body.API_Key;
response = msg.res;
// Checking for API KEY
// ------------------------------------------------------------------
if (checkForMissingParam(body, 'API_Key')) {
return response.status(403) .send({ err_code: "Unauthorized", });
}
// Validating JWT Token
// ------------------------------------------------------------------
try { const decoded = jwt.verify(apiKey, "Your_key"); }
catch (err) {
return response.status(403)
.send({ err_code: "Authentication failure", });
}
// Checking for REQUIRED Body Params
// ------------------------------------------------------------------
let mindbodyId = body.roomName;
let token = body.token;
let type = body.type;
let className = body.class_name;
let artistName = body.artist_name;
let hostName = body.host_name;
let timeStart = body.time_start;
let sessionInfo = body.session_info;
// let redirectUrl = body.redirect_url;
let userName = body.username;
let hostThankyouUrl = body.host_thankyou_url;
let guestThankyouUrl = body.guest_thankyou_url;
let missingKeys = [];
if (checkForMissingParam(body, 'roomName')) {
missingKeys.push('roomName')
}
if (checkForMissingParam(body, 'token')) {
missingKeys.push('token') }
if (checkForMissingParam(body, 'type')) {
missingKeys.push('type')
}
if (checkForMissingParam(body, 'class_name')) {
missingKeys.push('class_name') }
if (checkForMissingParam(body, 'artist_name')) {
missingKeys.push('artist_name') }
if (checkForMissingParam(body, 'host_name')) {
missingKeys.push('host_name') }
if (checkForMissingParam(body, 'time_start')) {
missingKeys.push('time_start') }
if (checkForMissingParam(body, 'username')) {
missingKeys.push('username') }
if (checkForMissingParam(body, 'host_thankyou_url')) {
missingKeys.push('host_thankyou_url') }
if (checkForMissingParam(body, 'guest_thankyou_url')) {
missingKeys.push('guest_thankyou_url') }
// Returning 400 Error if any of keys is missing
// eg: { "err_code":"missing keys ' roomName, userName '" }
// ------------------------------------------------------------------
if (missingKeys.length > 0) {
let keys = '';
missingKeys.forEach((key, index) => {
keys = index < missingKeys.length - 1 ? `${keys}${key}, ` : `${keys}
${key}`;
})
return response.status(400).send({
err_code: `Missing Required keys ' ${keys} '`, });
}
// Check for Valid Participant Type
// Removing this type && type !== 'moderator' && type !== 'staff'
// ------------------------------------------------------------------
if (type !== 'artist' && type !== 'host' && type !== 'guest')
{
return response.status(400).send({
err_code: `Invalid Participant Type`, });
}
let artistPhoto = '';
if (!checkForMissingParam(body, 'artist_photo_url')) {
artistPhoto = body.artist_photo_url;
}
else if (!checkForMissingParam(body, 'artist_photo')) {
artistPhoto = body.artist_photo; }
let participantId = uniqid();
msg.payload.insertDataForHost = {
className,
hostName,
artistName,
startTime: timeStart, sessionInfo,
mindbodyId,
hostThankyouUrl,
guestThankyouUrl,
artistPhoto,
userName,
participantId
};
msg.payload.insertDataOtherThanHost = {
className,
hostName,
artistName,
startTime:
timeStart,
sessionInfo,
type,
// redirectUrl,
mindbodyId,
hostThankyouUrl,
guestThankyouUrl,
artistPhoto,
userName,
token,
participantType: type, participantId };
//let PROTOCOL = "https";
//if (request.get("host").includes("localhost") ||
request.get("host").includes("127.0.0.1")) PROTOCOL = "http";
//let insertUrl = `${PROTOCOL}:
//${request.get("host")}`;
function checkForMissingParam(requestBody, paramName) {
return !(requestBody.hasOwnProperty(paramName) &&
requestBody[paramName] !== null && requestBody[paramName] !== '');
}
return msg;
Node.js function 2 Insert Data and display room participant for host
var require = context.global.get('require');
msg.orig = msg.payload.insertDataForHost;
let firstNameAndLastNameInitial = msg.payload.insertDataForHost.hostName;
msg.topic = `SELECT Full_Name from staff WHERE First_Name_Last_Initial = "${firstNameAndLastNameInitial.trim()}"`;
return msg;
Node.js function 3
var require = context.global.get('require');
msg.orig.fullName = fullName;
if (msg.payload.length > 0) {
fullName = msg.payload[0].Full_Name;
msg.orig.fullName = fullName; }
let firstNameAndLastNameInitial = msg.orig.artistName;
msg.topic = `SELECT Full_Name from staff WHERE First_Name_Last_Initial = "${firstNameAndLastNameInitial.trim()}"`;
node.warn(msg);
return msg;
Node.js Function 4
var require = context.global.get('require');
let data = msg.orig; node.warn(msg);
data.artistName = msg.orig.artistName.trim();
let payload = msg.payload;
if(payload.length>0){
msg.orig.newqq = msg.payload[0] artistName = msg.payload[0] data.artistName = msg.payload[0].fullName.trim(); }
data.receivedArtistName = msg.orig.artistName.trim();
// Set the actual name received from Payload
msg.topic = `UPDATE conferenceDetailsNew SET className = "${data.className}", participantId = "${data.participantId}", artistName = "${data.artistName}", hostName = "${data.hostName}", startTime = ${data.startTime}, sessionInfo = "${data.sessionInfo}", hostThankyouUrl = "${data.hostThankyouUrl}", guestThankyouUrl = "${data.guestThankyouUrl}", artistPhotoUrl = "${data.artistPhotoUrl}", participantName = "${data.participantName}", receivedArtistName = "${data.receivedArtistName}", receivedHostName = "${data.receivedHostName}" WHERE mindbodyId = "${data.mindbodyId}" AND participantType = "host"`;
return msg;
Check for userRoles
var require = context.global.get('require');
//node.warn(msg) msg.payload = msg.orig;
if (msg.payload.hostName === msg.payload.userName) {
msg.payload.isHost = true;
} else if (msg.payload.artistName === msg.payload.userName) {
msg.payload.isArtist = true;
} else { msg.payload.isGuest = true; }
msg.statusCode = 200;
return msg;
Now we made the flow for our normal start our rooms, now we modify our flows where participant (artists) can join in room based of authentication.Node.js funtion 5
var require = context.global.get('require');
msg.orig = msg.payload.insertDataOtherThanHost;
let firstNameAndLastNameInitial = msg.payload.insertDataOtherThanHost.hostName; msg.topic = `SELECT Full_Name from staff WHERE First_Name_Last_Initial = "${firstNameAndLastNameInitial.trim()}"`;
return msg;
Node.js function 6var require = context.global.get('require');
//msg.orig.newq = msg.payload[0];
if ( msg.payload.length > 0 ) {
fullName = msg.payload[0];
msg.orig.participantName = fullName.Full_Name.trim();
msg.orig.hostName = fullName.Full_Name.trim();
msg.orig.receivedHostName = msg.orig.hostName.trim();
// Set the actual name received from Payload }
let firstNameAndLastNameInitial = msg.orig.artistName; msg.topic = `SELECT Full_Name from staff WHERE First_Name_Last_Initial = "${firstNameAndLastNameInitial.trim()}"`;
return msg;
Node.js function 7
"var require = context.global.get('require');
let data = msg.orig;
let values = "(";
if (data.roomSid) {
values += `,"${data.roomSid}"`; }
if (data.participantId) {
values += `,"${data.participantId}"`; }
if (data.participantName) {
values += `,"${data.participantName}"`; }
if (data.participantType) {
values += `,"${data.participantType.toLowerCase()}"`; }
if (data.conferenceLink) {
values += `,"${data.conferenceLink}"`; }
if (data.token) {
values += `,"${data.token}"`; }
if (data.productSkus) {
values += `,"${data.token}"`; }
if (data.timestamp) {
values += ",now()"; }
if (data.mindbodyId) {
values += `,"${data.mindbodyId}"`; }
if (data.className) {
values += `,"${data.className}"`; }
if (data.artistName) {
values += `,"${data.artistName}"`; }
if (data.hostName) {
values += `,"${data.hostName}"`; }
if (data.startTime) {
values += `,${data.startTime}`; }
if (data.endTime) {
values += `,"${data.endTime}"`; }
if (data.sessionInfo) {
values += `,"${data.sessionInfo}"`; }
if (data.meetingStatus) {
values += `,"NOT_STARTED"`; }
if (data.hostThankyouUrl) {
values += `,"${data.hostThankyouUrl}"`; }
if (data.guestThankyouUrl) {
values += `,"${data.guestThankyouUrl}"`; }
if (data.artistPhotoUrl) {
values += `,"${data.artistPhotoUrl}"`; }
if (data.receivedHostName) {
values += `,"${data.receivedHostName}"`; }
if (data.receivedArtistName) {
values += `,"${data.receivedArtistName}"`; }
values += ")";
values = values.replace("(,", "(");
let fields = "(";
if (data.roomSid) {
fields += "roomSid"; }
if (data.participantId) {
fields += ",participantId"; }
if (data.participantName) {
fields += ",participantName"; }
if (data.participantType) {
fields += ",participantType"; }
if (data.conferenceLink) {
fields += ",conferenceLink"; }
if (data.token) {
fields += ",token"; }
if (data.productSkus) {
fields += ",productSkus"; }
if (data.timestamp) {
fields += ",timestamp"; }
if (data.mindbodyId) {
fields += ",mindbodyId"; }
if (data.className) {
fields += ",className"; }
if (data.artistName) {
fields += ",artistName"; }
if (data.hostName) {
fields += ",hostName"; }
if (data.startTime) {
fields += ",startTime"; }
if (data.endTime) {
fields += ",endTime"; }
if (data.sessionInfo) {
fields += ",sessionInfo"; }
if (data.meetingStatus) {
fields += ",meetingStatus"; }
if (data.hostThankyouUrl) {
fields += ",hostThankyouUrl"; }
if (data.guestThankyouUrl) {
fields += ",guestThankyouUrl"; }
if (data.artistPhotoUrl) {
fields += ",artistPhotoUrl"; }
if (data.receivedHostName) {
fields += ",receivedHostName"; }
if (data.receivedArtistName) {
fields += ",receivedArtistName"; }
fields += ")";
fields = fields.replace("(,", "(");
msg.topic = `INSERT INTO conferenceDetailsNew ${fields} VALUES ${values}`;
return msg;
function generateFields(data) {
let fields = "(";
if (data.roomSid) {
fields += "roomSid"; }
if (data.participantId) {
fields += ",participantId"; }
if (data.participantName) {
fields += ",participantName"; }
if (data.participantType) {
fields += ",participantType"; }
if (data.conferenceLink) {
fields += ",conferenceLink"; }
if (data.token) { fields += ",token"; }
if (data.productSkus) { fields += ",productSkus"; }
if (data.timestamp) { fields += ",timestamp"; }
if (data.mindbodyId) { fields += ",mindbodyId"; }
if (data.className) { fields += ",className"; }
if (data.artistName) { fields += ",artistName"; }
if (data.hostName) { fields += ",hostName"; }
if (data.startTime) { fields += ",startTime"; }
if (data.endTime) { fields += ",endTime"; }
if (data.sessionInfo) { fields += ",sessionInfo"; }
if (data.meetingStatus) { fields += ",meetingStatus"; }
if (data.hostThankyouUrl) { fields += ",hostThankyouUrl"; }
if (data.guestThankyouUrl) { fields += ",guestThankyouUrl"; }
if (data.artistPhotoUrl) { fields += ",artistPhotoUrl"; }
if (data.receivedHostName) { fields += ",receivedHostName"; }
if (data.receivedArtistName) { fields += ",receivedArtistName"; }
fields += ")";
fields = fields.replace("(,", "("); return fields; }
/* Generating Values */
function generateValues(data) {
let values = "("; if (data.roomSid) {
values += `,"${data.roomSid}"`; }
if (data.participantId) {
values += `,"${data.participantId}"`; }
if (data.participantName) {
values += `,"${data.participantName}"`; }
if (data.participantType) {
values += `,"${data.participantType.toLowerCase()}"`; }
if (data.conferenceLink) { values += `,"${data.conferenceLink}"`; }
if (data.token) { values += `,"${data.token}"`; }
if (data.productSkus) { values += `,"${data.token}"`; }
if (data.timestamp) { values += ",now()"; }
if (data.mindbodyId) { values += `,"${data.mindbodyId}"`; }
if (data.className) { values += `,"${data.className}"`; }
if (data.artistName) { values += `,"${data.artistName}"`; }
if (data.hostName) { values += `,"${data.hostName}"`; }
if (data.startTime) { values += `,${data.startTime}`; }
if (data.endTime) { values += `,"${data.endTime}"`; }
if (data.sessionInfo) { values += `,"${data.sessionInfo}"`; }
if (data.hostThankyouUrl) { values += `,"${data.hostThankyouUrl}"`; }
if (data.guestThankyouUrl) { values += `,"${data.guestThankyouUrl}"`; }
if (data.artistPhotoUrl) { values += `,"${data.artistPhotoUrl}"`; }
if (data.receivedHostName) { values += `,"${data.receivedHostName}"`; }
if (data.receivedArtistName) {
values += `,"${data.receivedArtistName}"`; } values += ")";
values = values.replace("(,", "(");
return values;
}
11) sometimes we need to eliminate participant(for obvious reasons)
12) Ending meeting by host
For Nodejs Funtion
var require = context.global.get('require');
let endTime = parseInt((new Date().getTime() / 1000).toFixed(0));
msg.orig = msg.payload;
msg.payload.roomSid = msg.req.query.roomSid;
msg.topic = `UPDATE conferenceDetailsNew SET meetingStatus = "CLOSED", hostEndTime = ${ endTime } WHERE mindbodyId = "${ msg.payload.mindbodyId }"`;
node.warn( msg );
return msg;
13) Complete end of class
var require = context.global.get('require');
let res = msg.res;
let req = msg.req;
let updateDetails = msg.payload; // get mindbodyId & type
if (req.query.roomName === undefined || req.query.roomName === null ||
req.query.roomName === "") {
return res.status(400).send({
error: `'roomName' cannot be Empty!`,
});
}
if (req.query.type === undefined || req.query.type === null || req.query.type === "") { return res.status(400).send({
error: `'type' cannot be Empty!`,
});
}
msg.topic = `SELECT startTime, participantId, hostName, mindbodyId, hostStartTime, hostEndTime, className, artistName, hostThankyouUrl, guestThankyouUrl, guestThankyouUrl, productSkus FROM conferenceDetailsNew WHERE mindbodyId = "${req.query.roomName}" AND participantType = "host"`;
return msg;
After Host exits and meeting gets ended, we should request Twilio API to retrieve the participants, recording and other supplementary data retrieved and stored in database14) Insert local CSV to databasevar require = context.global.get('require');
var fs = require('fs');
const XLSX = require('xlsx');
let axios = require('axios');
node.warn(msg.payload.filePath)
// let PROTOCOL = "https";
// node.warn(msg);
// if (msg.req.get("host").includes("localhost") || msg.req.get("host").includes("127.0.0.1")) PROTOCOL = "http";
// let insertUrl = `${PROTOCOL}://${msg.req.get("host")}`;
// node.warn(insertUrl);
/**
* Read Static file and Insert Staff Data
*
* @param filePath
*/
var mysql = require('mysql');
const HOST = "localhost";
const USER = "interplay";
const PASSWORD = "password";
const DATABASE = "chanel";
const CONNECTION_LIMIT = 100;
const QUEUE_LIMIT = 50;
let mysqlConnection;
/**
* Connect to DB
* @return {Connection}
*/
function connectDb() {
// Create Mysql Connection
mysqlConnection = mysql.createConnection({
host: HOST,
user: USER,
password: PASSWORD,
database: DATABASE,
connectionLimit: CONNECTION_LIMIT,
queueLimit: QUEUE_LIMIT,
});
// mysqlConnection.connect();
mysqlConnection.connect();
return mysqlConnection;
}
function disconnectFromDB() {
if (mysqlConnection !== null)
mysqlConnection.destroy();
}
function readFileFromStaticLocation(filePath) {
let rawData = fs.readFileSync(filePath);
let workbook = XLSX.read(rawData, {type: "array", cellDates: true, dateNF: 'YYYY-MM-DD HH:mm:ss'});
let first_sheet_name = workbook.SheetNames[0];
let worksheet = workbook.Sheets[first_sheet_name];
let jsonData = XLSX.utils.sheet_to_json(worksheet, {raw: false});
for (let i = 0; i < jsonData.length; i++) {
let data = jsonData[i];
let values = " (";
if (data.Name_in_Mindbody) {
values += `"${data.Name_in_Mindbody.trim()}"`;
}
if (data.First_Name) {
values += `, "${data.First_Name.trim()}"`;
}
if (data.First_Name_Last_Initial) {
values += `, "${data.First_Name_Last_Initial.trim()}"`;
} if (data.Full_Name) {
values += `, "${data.Full_Name.trim()}"`;
}
values += ")";
let insertStaffQuery = `INSERT INTO staff(Name_in_Mindbody, First_Name, First_Name_Last_Initial, Full_Name) VALUES${values}`;
connectDb().query(insertStaffQuery, function (error, result) { if (error) return reject(error);
// Disconnect DB
disconnectFromDB();
return resolve(result);
});
//axios.post(`https://devchanel.interplay.iterate.ai/insertStaffToDB`, jsonData[i]) }
}
readFileFromStaticLocation(msg.payload.filePath);
return msg;