#Run jobs without a trigger

1 messages · Page 1 of 1 (latest)

copper swift
#

How can I manually invoke a job on Trigger.dev without using an automatic trigger? Is this possible, and if so, how can it be done?

Ex: Can we do something like this?
curl -X POST 'https://api.trigger.dev/jobs/YOUR_JOB_ID/run'
-H 'Authorization: Bearer YOUR_API_TOKEN'
-H 'Content-Type: application/json'
-d '{
"param1": "value1",
"param2": "value2"
}'

My requirement is as follows:
I'm currently using a trigger from trigger.dev to process tasks after adding a new record to my Supabase table, and it's working well.
However, the payload I'm receiving contains only the data of the newly added record.

I need data related to foreign tables as well. Is there a way to achieve this with trigger.dev?
I haven't found anything related to this, so I have decided to create a Supabase trigger to construct the JSON I need, including data from foreign tables, and then call the trigger.dev job. Is that possible?

Thank you for your help!

torn kraken
#

Hey Malindu,

There are a couple of ways of doing this:

  1. Exactly as you propose, you can POST data to trigger a job. To do that you would use an eventTrigger() where you can also specify the schema of the incoming data if you want to add some type safety and inference.

If you're sending the data from JS/TS you can use client.sendEvent(), if you're not you just POST that data to us (that's all that's happening under-the-hood).

  1. You could subscribe to the Supabase row change using the Supabase database changed trigger and then do the queries just inside your run.
#

We're going to add documentation for POSTing data as a request, but for now you can look at this code to see how it works: https://github.com/triggerdotdev/trigger.dev/blob/e48c9b5e69e8d8aa425e241ff7e00f0a47c98d7e/packages/trigger-sdk/src/apiClient.ts#L198

GitHub

✨ Trigger.dev is the open source background jobs framework for TypeScript. With features like API integrations, webhooks, scheduling and delays. - triggerdotdev/trigger.dev

copper swift
#

Thanks again @torn kraken

copper swift
#

Hey @torn kraken ,

I tried calling the /api/v1/events endpoint to trigger a created event, but I encountered a CORS blocking issue in the browser. (Screenshots attached)

Then I tried deploying on Vercel, but it also failed due to CORS blocking.

#

Then, I attempted to call the event using client.sendEvent(), but unfortunately, this resulted in an error from the trigger.dev SDK.

The error is as follows: './node_modules/@trigger.dev/sdk/dist/index.js:555:0 - Module not found: Can't resolve 'async_hooks'.

torn kraken
#

It looks like you’re trying to send an event from the browser. CORS errors and that async hook error are both caused by that.

You shouldn’t send events from the browser. The Server API key is private and should not be used from the browser. It would allow people to use your account to trigger jobs.