Run the workflow as a background process
Learn how to execute the workflow fully in the background, without displaying any user interface.
1
Set up the server
Create a Workflow Execution
const express = require('express');
const axios = require('axios');
const { v4: uuidv4 } = require('uuid');
const app = express();
app.use(express.json());
async function getAccessToken() {
const response = await axios.post("/authorize" .....)
return response;
}
app.post('/create-workflow-embedded', async (req, res) => {
const executionPayload = {
recordId: uuidv4(),
workflowDefinitionId: uuidv4(),
};
const execution = await axios.post(
'https://api.transactionlink.io/token',
executionPayload,
{
headers: {
Authorization: `Bearer ${response.data.accessToken}`,
'Content-Type': 'application/json',
},
}
);
res.send({
token: execution.data.token,
});
});
app.get('/workflow-status', async (req, res) => {
const executionId = req.query.execution_id;
const workflow = await axios.get(
`https://api.transactionlink.io/workflows/${executionId}`,
{
headers: {
Authorization: `Bearer ${ACCESS_TOKEN}`,
},
}
);
res.send({
status: workflow.data.status,
executionId: execution.data.id,
});
});
app.listen(8080, () => console.log('Running on port 8080'));Last updated