Can you share your account ID here? (it’s safe to share publicly)
Can you share your account ID here? (it’s safe to share publicly)
1ac93aea0842f2d3ef10111b5bf7bb11



const maxFutureDays = await step.do(`get ${key} max days`, async () => 330);while (somecondition){
await step.do(`some action `${somekey}`, async () => {});
} async tail(events, env, ctx) {
// Check if events array exists and has items
if (!Array.isArray(events) || events.length === 0) {
return new Response("No events found", { status: 200 });
}
// Only proceed if there's an exception AND exceptions array is not empty
const event = events[0];
if (event.outcome !== "exception" || !event.exceptions?.length) {
return new Response("No exception found", { status: 200 });
}
// Log the event structure to help us understand the data
console.log("Tail worker event:", JSON.stringify(events, null, 2));
... const payload = await step.do('prepares payload', async () => {
const isDev = this.env.ENVIRONMENT === 'dev';
const data = isDev ? mockData : event.payload;
console.log("Received payload:", JSON.stringify(data, null, 2));
throw new Error("Testing error handling with payload data");
return data;
});export class NeverGonnaWorkflow extends WorkflowEntrypoint<Env, NeverGonnaParams> {
async run(event: WorkflowEvent<NeverGonnaParams>, step: WorkflowStep) {
const { to, host, content } = event.payload;
await step.sleep('wait for the right moment', '135 seconds');
const callSid = await step.do('call person back', async () => {
const client = new Twilio(this.env.TWILIO_ACCOUNT_SID, this.env.TWILIO_AUTH_TOKEN);
// Say verb here does text to speech
// Play allows you to play media.
// The mp3 file is hosted on Cloudflare Workers using dynamic assets
const twiml = `
<Response>
<Say>Hello from a Cloudflare Workflow!</Say>
<Say>You said "${content}".</Say>
<Say>Check out this classic:</Say>
<Play>https://${host}/classic.mp3</Play>
</Response>`;
const call = await client.calls.create({
to,
from: this.env.TWILIO_PHONE_NUMBER,
twiml,
});
return call.sid;
});
return { success: true, callSid }; // <------ How to use this?
}
}