i had a problem i add a hook before outputing a message to my studio
i need it to jump to a specefic node after an interval of time 8s
the problem is without the timer it works fin and with it does not
console.log('Setting up a timer with Luxon.');
// Define the target flow and node
const targetFlow = 'wf-main'; // Replace with your flow file name
const targetNode = 'nd-0a04f3874a'; // Replace with your target node name
// Check if the current node is the one where you want to start the timer
if (event.state.context.currentNode === 'nd-0864c36fa7') {
// Set up a future time using Luxon
const futureTime = luxon.DateTime.now().plus({ seconds: 8 }).toISO();
// Set a non-blocking timer
const checkTime = () => {
if (luxon.DateTime.now() >= luxon.DateTime.fromISO(futureTime)) {
console.log('8 seconds have passed. Performing the action.');
try {
// Update the event state to jump to the specified node in the specified flow
event.state.context = {
...event.state.context,
currentFlow: targetFlow,
currentNode: targetNode
};
// Log the update
console.info(
Updated event state to jump to node ${targetNode} in flow ${targetFlow}
);
} catch (error) {
console.error(
Failed to update event state: ${error.message}
);
}
} else {
// If the time has not yet passed, check again in a short interval
setTimeout(checkTime, 1000);
}
};
// Start the initial check
setTimeout(checkTime, 1000);
}
console.log('Timer set. Flow continues without waiting.');