Back to jobs
Trigger: eventTrigger
Logs a joke, waits 5 seconds, and then logs the punchline.
Integrations:
None
/src/delayExampleJoke
Scheduled
1import { TriggerClient, eventTrigger } from "@trigger.dev/sdk";23const client = new TriggerClient({ id: "jobs-showcase" });45// This Job will be triggered by an event, log a joke, and then wait 5 seconds before logging the punchline6client.defineJob({7// This is the unique identifier for your Job, it must be unique across all Jobs in your project8id: "delay-example-joke",9name: "Delay example joke",10version: "1.0.0",11trigger: eventTrigger({12name: "example.event",13}),14run: async (payload, io, ctx) => {15await io.logger.info("🧪 Example Job: a joke with a delay");16await io.logger.info("How do you comfort a JavaScript bug?");17await io.wait("Wait 5 seconds for the punchline...", 5);18await io.logger.info("You console it! 🤦");19await io.logger.info(20"✨ Congratulations, You just ran your first successful Trigger.dev Job! ✨"21);22// To learn how to write much more complex (and probably funnier) Jobs,23// check out our docs: https://trigger.dev/docs/documentation/guides/create-a-job24},25});2627// These lines can be removed if you don't want to use express28import { createExpressServer } from "@trigger.dev/express";29createExpressServer(client);