{"flow":{"id":81,"summary":"Azure Event Grid flow with preprocessor template","versions":[299],"created_by":"hugo989","created_at":"2026-04-23T09:04:14.512Z","votes":0,"approved":true,"apps":["windmill"],"value":{"modules":[{"id":"a","value":{"type":"rawscript","content":"/**\n * Main flow step — replace with your own handler.\n */\nexport async function main(\n\tpayload: any,\n\teventType: string,\n\tsubject: string | undefined,\n\tsource: string,\n\teventId: string,\n\ttime: string | undefined,\n\tdeliveryType: 'push' | 'pull'\n) {\n\tconsole.log(`[${deliveryType}] ${eventType} from ${source} (${eventId})`)\n\treturn { received: payload, type: eventType, subject }\n}\n","language":"bun","input_transforms":{"time":{"expr":"flow_input.time","type":"javascript"},"source":{"expr":"flow_input.source","type":"javascript"},"eventId":{"expr":"flow_input.eventId","type":"javascript"},"payload":{"expr":"flow_input.payload","type":"javascript"},"subject":{"expr":"flow_input.subject","type":"javascript"},"eventType":{"expr":"flow_input.eventType","type":"javascript"},"deliveryType":{"expr":"flow_input.deliveryType","type":"javascript"}}},"summary":"Handle the Azure Event Grid event"}],"preprocessor_module":{"id":"preprocessor","value":{"type":"rawscript","content":"/**\n * Flow Preprocessor for Azure Event Grid.\n *\n * Runs BEFORE the rest of the flow and remaps the raw trigger event into\n * flow inputs. The returned object becomes the flow's input arguments.\n *\n * @param event - Azure Event Grid trigger data.\n */\nexport async function preprocessor(event: {\n\tpayload: any\n\tkind: 'azure'\n\tid: string\n\tsource: string\n\ttype: string\n\tsubject?: string\n\ttime?: string\n\tspecversion: string\n\tdatacontenttype?: string\n\tdataschema?: string\n\theaders?: Record<string, string>\n\tdelivery_type: 'push' | 'pull'\n\ttrigger_path: string\n}) {\n\tif (event.kind !== 'azure') {\n\t\tthrow new Error(`Expected azure trigger kind got: ${event.kind}`)\n\t}\n\treturn {\n\t\tpayload: event.payload,\n\t\teventType: event.type,\n\t\tsubject: event.subject,\n\t\tsource: event.source,\n\t\teventId: event.id,\n\t\ttime: event.time,\n\t\tdeliveryType: event.delivery_type\n\t}\n}\n","language":"bun","input_transforms":{}}}},"schema":{"type":"object","order":["payload","eventType","subject","source","eventId","time","deliveryType"],"$schema":"https://json-schema.org/draft/2020-12/schema","required":["payload","eventType","source","eventId","deliveryType"],"properties":{"time":{"type":"string","default":null,"description":"Event time (RFC 3339)."},"source":{"type":"string","default":null,"description":"CloudEvents source (producer resource)."},"eventId":{"type":"string","default":null,"description":"Unique event id."},"payload":{"type":"object","default":null,"description":"CloudEvents `data` field, already parsed."},"subject":{"type":"string","default":null,"description":"CloudEvents subject."},"eventType":{"type":"string","default":null,"description":"e.g. Microsoft.Storage.BlobCreated"},"deliveryType":{"enum":["push","pull"],"type":"string","default":null,"description":"'push' or 'pull'."}}},"description":"Flow triggered by Azure Event Grid events. The first step is a preprocessor that unpacks the CloudEvents envelope into individual fields; the second step is a placeholder handler you can replace with your own logic. The flow argument `payload` is the already-parsed CloudEvents `data` field (or the base64 string if the publisher used `data_base64`).","recording":null,"vcreated_at":"2026-04-23T09:04:14.512Z","vcreated_by":"hugo989","comments":[]}}