Zendesk App Hosting
I am working on a server-side app using the React scaffold. I used the Event Timeline app example from here as a starting point. So my app.js code is very similar to that example.
While testing, I have also successfully displayed sample data from my Databricks SQL warehouse into my Zendesk app. The following is some code I am using in my backend.js file to get that data from Databricks:
const express = require('express');
const { DBSQLClient } = require('@databricks/sql');
const cors = require('cors');
const app = express();
const port = process.env.PORT || 3000;
const corsOptions = {
origin: 'http://localhost:4567'
}
app.use(cors(corsOptions));
var token = process.env.DATABRICKS_TOKEN;
var serverHostname = process.env.DATABRICKS_SERVER_HOSTNAME;
var httpPath = process.env.DATABRICKS_HTTP_PATH;
if (!token || !serverHostname || !httpPath) {
throw new Error("Cannot find Server Hostname, HTTP Path, or personal access token. " +
"Check the environment variables DATABRICKS_TOKEN, " +
"DATABRICKS_SERVER_HOSTNAME, and DATABRICKS_HTTP_PATH.");
}
const client = new DBSQLClient();
app.get('/api/query', async (req, res) => {
try {
await client.connect({
token: token,
host: serverHostname,
path: httpPath
});
const session = await client.openSession();
const queryOperation = await session.executeStatement(
statement = `SELECT fare_amount FROM samples.nyctaxi.trips LIMIT 3`,
options = {
runAsync: true,
maxRows: 10000 // This option enables the direct results feature.
}
);
... // other code here
});
app.listen(port, () => {
console.log(`Server started on port ${port}`);
});
In my frontend (app.js), I make a GET request to the endpoint here in my backend.js (http://localhost:3000/api/query) and the results of the SQL query are fetched and displayed in my Zendesk App.
If my understanding is correct, I can host the backend part of my app in AWS, Heroku or a similar service.
My question is, could I host the backend in Zendesk instead? If so, how would I implement and configure this?
Also, if I should edit some part of my code to implement this, please provide an example or suggestion.
-
Hi there! At this time, we do not have an option to host a backend service like this within Zendesk. Since apps are only running within the respective agent interfaces, there would be no way to have an "always on" option like a server.
Just to see if I can offer some other options, is there a reason you're looking to avoid the standard hosting services?
-
Hi, thank you for your reply.
I'm not looking to avoid the standard hosting services, I just wanted to be aware of all available options for my implementation.Thank you!
-
Got it, makes sense!
Please sign in to leave a comment.
3 Comments