import { createWebhook, sleep } from 'workflow'; export async function handleUserSignup(email: string) { 'use workflow'; const user = await createUser(email); await sendWelcomeEmail(user); await sleep('5s'); const webhook = createWebhook(); await sendOnboardingEmail(user, webhook.url); await webhook; console.log('Webhook Resolved'); return { userId: user.id, status: 'onboarded' }; } async function createUser(email: string) { 'use step'; console.log(`Creating a new user with email: ${email}`); return { id: crypto.randomUUID(), email }; } async function sendWelcomeEmail(user: { id: string; email: string }) { 'use step'; console.log(`Sending welcome email to user: ${user.id}`); } async function sendOnboardingEmail( user: { id: string; email: string }, callback: string ) { 'use step'; console.log(`Sending onboarding email to user: ${user.id}`); console.log(`Click this link to resolve the webhook: ${callback}`); }