Sleep
Wait for an event
A run can hold until someone answers, however long it takes:- Pick a key that names what you wait for, like the order it belongs to.
step.waitreturns the payload of the event that woke it.- A run can wait up to a year.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Sleep for a while, or wait for an event, for as long as it takes.
await nelkap.step.sleep('3 days');
export async function refundOrder(orderId: string) {
await nelkap.step.run('approval request', () => askManager(orderId));
const review = await nelkap.step.wait<{ approved: boolean }>(`refund_${orderId}`);
if (review.approved) {
await nelkap.step.run('refund', () => refund(orderId));
}
}
await nelkap.emit({ event: 'refund.reviewed', payload: { approved: true }, wakeOn: `refund_${orderId}` });
step.wait returns the payload of the event that woke it.