Compare commits

...

278 Commits

Author SHA1 Message Date
Eric Allam cab222ac4b Changeset:verion Feb 7 2023 2023-02-07 14:45:03 +00:00
Eric Allam 667a60a551 Remove uploading source maps to sentry for now 2023-02-07 14:42:18 +00:00
Eric Allam 710bcc2c47 Handle errors when calling listen and provide some log feedback 2023-02-07 14:40:59 +00:00
D-K-P d1d34da9b2 Added a link to the self-hosting guide GH issue from the readme 2023-02-07 12:56:29 +00:00
James Ritchie 0c476093d7 Fix for the time not displaying correctly 2023-02-07 12:46:55 +00:00
James Ritchie ba2c895e53 Smaller icon 2023-02-07 11:36:57 +00:00
James Ritchie 764dd21613 Added a refresh button when a run is in progress 2023-02-07 11:08:03 +00:00
Eric Allam 78c3e1060d Try and get sourcemaps uploading 2023-02-07 10:20:16 +00:00
Eric Allam 96a180f26e Add sentry env vars to the staging webapp 2023-02-07 09:44:57 +00:00
Eric Allam 35718033bd Upload source maps to sentry during Docker build 2023-02-07 09:29:15 +00:00
Eric Allam 5501a927bf Update to latest @sentry/remix package 2023-02-07 09:29:15 +00:00
D-K-P 17568a0aec Made the code font smaller and reduced the left padding 2023-02-06 21:59:44 +00:00
D-K-P 563a535b56 Added notion / openai integration logos 2023-02-06 21:59:12 +00:00
Matt Aitken 2a2652d3aa Removed docs. They now live in the triggerdotdev/docs repo 2023-02-06 19:07:09 +00:00
Matt Aitken aca9081e64 Added internal packages to the CLI tsconfig 2023-02-06 17:12:33 +00:00
Eric Allam d9ad006550 Changset: created release version 2023-02-06 15:29:08 +00:00
Eric Allam eacee88f45 Prefill the API key on start from scratch examples 2023-02-06 15:25:37 +00:00
Eric Allam 51432feb74 Fixed issue with lastRunAt being null 2023-02-06 15:11:23 +00:00
Eric Allam 2398f85081 Added initial roadmap 2023-02-06 15:04:25 +00:00
Eric Allam b1fb567c28 Added changelog docs 2023-02-06 14:50:11 +00:00
Eric Allam 8c89ed3334 Document including tsx files when using jsx-slack 2023-02-06 14:50:11 +00:00
James Ritchie 32b9dbcf94 Removed console.log 2023-02-06 14:43:58 +00:00
James Ritchie 7d84f59c1e Fixed the info panel on overview page 2023-02-06 14:35:58 +00:00
James Ritchie d22ef06525 Updated the information panel to include an optional message 2023-02-06 14:35:05 +00:00
James Ritchie 595df9ae62 Settings page now shows the workflow 2023-02-06 14:21:40 +00:00
James Ritchie ceb862f484 Step numbers on onboarding slightly smaller 2023-02-06 13:52:21 +00:00
James Ritchie 49846df811 Display warning message on Settings page if API needs connecting 2023-02-06 13:49:57 +00:00
James Ritchie 5fec008f09 Fixed broken primary connect api button 2023-02-06 13:49:57 +00:00
James Ritchie 90f8b088ff Copy update 2023-02-06 13:49:57 +00:00
James Ritchie a1d464325d Updated the panel when you don’t have any runs yet 2023-02-06 13:49:57 +00:00
James Ritchie a17442b016 Improved how the Warning panel works so it can include an optional button 2023-02-06 13:49:57 +00:00
Eric Allam cb3b068fab Added slack view submission interaction event docs 2023-02-06 13:49:29 +00:00
Eric Allam 26a5913734 Added docs for slack.openView 2023-02-06 13:09:05 +00:00
James Ritchie 078beb1689 Made the NEW badge less clumsy looking 2023-02-06 12:56:01 +00:00
James Ritchie 05a2f6f8e1 New copy added 2023-02-06 12:42:39 +00:00
James Ritchie 7fc6358e40 Layout shuffle to include a line between each step 2023-02-06 12:42:39 +00:00
James Ritchie 70ce15b271 Visual tweak to onboarding 2023-02-06 12:42:39 +00:00
James Ritchie 97b0019d99 Layout improvements to onboarding 2023-02-06 12:42:39 +00:00
Matt Aitken c419101750 WhatsApp is available to everyone 2023-02-06 11:57:58 +00:00
Matt Aitken fdb2944380 Changeset: created a version with WhatsApp import problem fixed 2023-02-06 11:52:41 +00:00
Matt Aitken 13b6d96f8c Changeset: Switch to main mode and created fix for WhatsApp import of internal file 2023-02-06 11:51:53 +00:00
Matt Aitken feae0b3c08 WhatsApp package was linking to the sdk/index file 2023-02-06 11:51:53 +00:00
Matt Aitken 64854b128f Added scripts and documentation for doing pre-release changeset versions 2023-02-06 11:51:53 +00:00
Eric Allam 46fc33ca15 Downgrade mintlify to 2.0.16, add more to blockActionInteraction, and fix pnpm install commands 2023-02-06 10:45:08 +00:00
Matt Aitken f02eeb0af9 Changeset:pre enter next 2023-02-06 09:22:59 +00:00
Matt Aitken f95938d2ac Changeset:add Initial WhatsApp 2023-02-06 09:21:31 +00:00
Eric Allam c3f2f61982 Added some additional slack docs (WIP, still need to cover views and view interactions) 2023-02-05 21:54:29 +00:00
Eric Allam 124751e62a Fixed the sendEvent API ref page and update mintlify to 2.0.17 2023-02-05 20:36:07 +00:00
Eric Allam 81569eb66e Added some additional info about why users should use our fetch over the platform fetch 2023-02-05 20:30:07 +00:00
Matt Aitken 66d959282d Improved the message when you have no runs 2023-02-03 18:30:29 +00:00
Matt Aitken b0a06f8a9d “NEW” banner only displays for workflows without runs 2023-02-03 17:28:53 +00:00
Matt Aitken 07f0144354 Downgraded remix back to previous version 2023-02-03 17:28:32 +00:00
James Ritchie 11beadfb7d Fixed success panel layout 2023-02-03 16:54:11 +00:00
Matt Aitken 54faa44e84 Added Intercom back 2023-02-03 16:52:48 +00:00
Matt Aitken f121a48466 Run install 2023-02-03 16:44:13 +00:00
Matt Aitken 92436308c0 Merge remote-tracking branch 'origin/dev' into onboarding
# Conflicts:
#	apps/webapp/package.json
#	pnpm-lock.yaml
2023-02-03 16:43:20 +00:00
James Ritchie 8ba20d8fa3 Updated the Connect Workflow layout 2023-02-03 16:40:35 +00:00
Matt Aitken 92a37ae3a5 Fix for Remix hydration issues 2023-02-03 16:36:16 +00:00
Matt Aitken db9d9d93df Fis for missing key in map 2023-02-03 16:36:16 +00:00
Matt Aitken 506dfe6860 Attempt at using remix-island to fix React 18 issues 2023-02-03 16:36:16 +00:00
Matt Aitken 813c3622e9 Updated remix and added remix-island 2023-02-03 16:36:16 +00:00
James Ritchie d0208e698b Scrollbars hidden on carousel 2023-02-03 16:24:08 +00:00
Eric Allam 2a51c5a1a3 Generate fake test data from custom and webhook event schemas 2023-02-03 16:19:49 +00:00
Matt Aitken ee9125ff02 Add a button to check for new workflows and if there are any link to the workflow 2023-02-03 15:41:59 +00:00
James Ritchie 6caadf5da5 Added a NEW badge for a workflow 2023-02-03 14:44:47 +00:00
James Ritchie c98b7c4e24 Title fixes 2023-02-03 14:21:57 +00:00
James Ritchie 489c40c847 Examples tabs now a carousel 2023-02-03 14:19:43 +00:00
Eric Allam 0d2d9a043c Implement runOnce and runOnceLocalOnly functions 2023-02-03 13:50:59 +00:00
James Ritchie 9bb9c1cdbe Updated tabs style 2023-02-03 13:32:09 +00:00
James Ritchie 81d6fbfdaa Changed the Create New Workflow component to be inline 2023-02-03 13:23:40 +00:00
James Ritchie b72d63bdd2 Moved inline tab style to new component 2023-02-03 13:23:40 +00:00
James Ritchie 1319651079 Consolidated duped Tabs component 2023-02-03 13:23:40 +00:00
Matt Aitken f6fbd5e5b7 Remove logging of the Slack interactivity payload 2023-02-03 12:51:44 +00:00
Matt Aitken 9d5e24dac5 Added code comments to the WhatsApp to Slack example 2023-02-03 12:51:36 +00:00
D-K-P 4ad2702e4d remove line number from prism 2023-02-03 12:41:12 +00:00
D-K-P 2a2da8fa7a Changed icon colour to rose 2023-02-03 12:41:12 +00:00
James Ritchie 64ccb0cf11 Updated the create new workflow buttons at the bottom of the workflow list 2023-02-03 12:28:04 +00:00
D-K-P 8b3abd6a06 Updated samples and removed packagesCopy and testCode sections 2023-02-03 12:26:42 +00:00
Matt Aitken 63b3d82c2f Repeat the original message in the modal so you have context 2023-02-03 12:24:34 +00:00
Matt Aitken 358e9af01d Exposed more types from the WHatsApp Integration 2023-02-03 12:24:17 +00:00
James Ritchie f9cab846b9 Removed final step 2023-02-03 12:23:07 +00:00
James Ritchie 8a66983f63 Removed authentication step 2023-02-03 12:22:46 +00:00
James Ritchie b45a176c4f Button copy change 2023-02-03 12:22:35 +00:00
D-K-P 86d1a2413a More copy updates 2023-02-03 11:44:21 +00:00
Matt Aitken 763ee294ba Slack messages can now be threaded, and you can pass data through 2023-02-03 11:40:20 +00:00
James Ritchie 9a7db7bcff Copy updates for the scratch section 2023-02-03 11:38:56 +00:00
D-K-P 2c2de7b236 Added api key comments to all the workflows 2023-02-03 11:37:11 +00:00
D-K-P b9b49a8733 Copy updates 2023-02-03 11:32:46 +00:00
James Ritchie 32f09d59e6 Added content to the From Scratch section 2023-02-03 11:31:59 +00:00
James Ritchie ddb8b131c0 Deselected tab now more visible 2023-02-03 11:17:29 +00:00
James Ritchie ab8e1f0d06 Copy tweak 2023-02-03 11:07:32 +00:00
D-K-P 3f25622abf Removed extra line 2023-02-03 10:58:14 +00:00
D-K-P 9692ef5ceb fixed slack 2023-02-03 10:57:35 +00:00
D-K-P 2c29687712 Moved the package installation instructions to the individual examples 2023-02-03 10:51:58 +00:00
James Ritchie a392e6a00c Now using the external samplesList file 2023-02-03 10:49:47 +00:00
James Ritchie 59a5c2df51 Lots of copy improvements 2023-02-03 10:44:56 +00:00
James Ritchie 9872afcf98 Improved the page titles 2023-02-03 10:44:56 +00:00
D-K-P 55fd404449 Added new user slack message / custom event / webhook / scheduled - rec / schedule cron 2023-02-03 10:38:28 +00:00
James Ritchie faa844efa1 New steps added for authenticating with APIs 2023-02-03 10:23:32 +00:00
James Ritchie 1d02ffaf18 Organised imports 2023-02-03 10:23:32 +00:00
D-K-P 859a31e08b Added gh / resend / shopify / whatsapp to the samples list 2023-02-03 10:22:28 +00:00
Eric Allam a5f18cf45a Fixed issue with old slack workflow source parsing 2023-02-03 10:12:01 +00:00
James Ritchie c669c61ba7 Blank Workflows state now points to the new onboarding 2023-02-03 09:53:25 +00:00
James Ritchie ec1df6d476 Made samples list file a tsx 2023-02-03 09:24:59 +00:00
James Ritchie 50ecc88b99 Added samples list file 2023-02-03 09:24:23 +00:00
James Ritchie 605e34b6ad More copy 2023-02-03 09:16:39 +00:00
James Ritchie 780cd7fcef Added a new side menu link for New Workflow 2023-02-03 09:09:38 +00:00
James Ritchie f447cb1ca0 Content improvement 2023-02-02 22:07:00 +00:00
James Ritchie ee28eca61c Added icons to the example boxes 2023-02-02 21:57:54 +00:00
D-K-P d629e3cca1 Converted the samples into functions 2023-02-02 21:28:58 +00:00
James Ritchie 43a320253d Added more steps to the onboarding 2023-02-02 20:30:34 +00:00
Matt Aitken 5ffababfe5 Added thread support to posting messages 2023-02-02 19:46:49 +00:00
James Ritchie e77bfc77e0 more style improvements 2023-02-02 19:38:17 +00:00
James Ritchie 93903bf072 Moved the env variables up to the workspace 2023-02-02 19:38:09 +00:00
James Ritchie 2b4a74f672 WIP adding api keys to the code samples 2023-02-02 19:10:22 +00:00
Matt Aitken 8ffb612496 Removed extraneous UI in Slack message 2023-02-02 18:54:51 +00:00
Matt Aitken 34f86dda3b WhatsApp slack example working 2023-02-02 18:51:11 +00:00
James Ritchie 81d3d324e2 More progress on the onboarding 2023-02-02 18:41:20 +00:00
D-K-P 6d8100d200 Added whatsapp sample 2023-02-02 18:18:53 +00:00
D-K-P 3e53699b05 Added shopify sample 2023-02-02 18:11:50 +00:00
D-K-P 8cca0f520b added sample code and renamed files 2023-02-02 18:08:46 +00:00
D-K-P 908fff6fe3 Added package installation instructions to all of the examples 2023-02-02 17:55:28 +00:00
James Ritchie da7742985f Mapping over projects 2023-02-02 17:40:08 +00:00
James Ritchie 4077d014e4 Added placeholder pages for more code examples 2023-02-02 17:39:53 +00:00
James Ritchie ab0938e91b Added an external code example 2023-02-02 17:22:21 +00:00
Matt Aitken 547f619112 Just show a link for videos for now 2023-02-02 16:37:06 +00:00
Eric Allam 4008e1d7ed Comments for the whatsapp flow 2023-02-02 16:32:04 +00:00
James Ritchie 910a8d3651 WIP updated onboarding page 2023-02-02 16:18:39 +00:00
Eric Allam 0e4ec8d8e6 Added views and view submission support to Slack integration 2023-02-02 16:18:32 +00:00
James Ritchie 2d08718389 Updated headless ui package 2023-02-02 16:18:28 +00:00
D-K-P 96306eb5e0 Added intercom 2023-02-02 15:35:17 +00:00
James Ritchie 517d50242f Updated whatsapp icon 2023-02-02 14:25:23 +00:00
James Ritchie cf8163ef5c Fixed the Integrations button layout so they’re all the same height 2023-02-02 14:15:40 +00:00
Matt Aitken d6c7648bf1 WhatsApp media urls and geting files is working 2023-02-02 13:44:31 +00:00
Matt Aitken 05b0bd9fb4 Add jsx-slack to the WhatsApp example package 2023-02-02 10:51:49 +00:00
Matt Aitken 6495b67d1f Make image, document, video etc use the EventMediaObjectSchema 2023-02-02 10:50:41 +00:00
Matt Aitken c37edf970d Added workflowId and appOrigin to the @trigger.dev/sdk run metadata 2023-02-02 10:49:54 +00:00
Matt Aitken b38961205a Merge pull request #39 from triggerdotdev/integrations/whatsapp
WhatsApp integration
2023-02-02 08:49:48 +00:00
Matt Aitken 7e1c04ae71 Removed console.log 2023-02-02 08:33:13 +00:00
Matt Aitken 49a4b0ce11 Removed changeset files that pulled from dev 2023-02-02 08:31:06 +00:00
Matt Aitken 42c2a87238 Improved the text 2023-02-02 08:28:11 +00:00
Matt Aitken aefbba1f37 Added an index page to the reference 2023-02-02 08:27:25 +00:00
Matt Aitken b8b032a5fb Added docs for contact messages and template messages 2023-02-02 08:23:00 +00:00
Matt Aitken 2eea62c3ce Added lots of the docs for messages 2023-02-01 23:24:39 +00:00
Matt Aitken 22327886ac Added message event docs 2023-02-01 22:55:13 +00:00
Matt Aitken 3126d890dc Added a WhatsApp example 2023-02-01 21:54:41 +00:00
D-K-P 60abac1bc0 Updated mint.json 2023-02-01 15:32:02 +00:00
D-K-P 37d331588d Added package instructions for the integrations to the docs 2023-02-01 15:24:20 +00:00
D-K-P 6ddaf067a9 Added posthog to mint.json 2023-02-01 15:21:23 +00:00
Matt Aitken e281297da5 Merge remote-tracking branch 'origin/dev' into integrations/whatsapp 2023-02-01 14:47:10 +00:00
Matt Aitken f46436b903 Added “prettier-plugin-tailwindcss”: correct order for classes 2023-02-01 14:46:04 +00:00
Matt Aitken 6442576a38 Added audio, video, document and sticker messages 2023-02-01 13:43:18 +00:00
Matt Aitken 93f1814fd2 Improved errors handling, added sendContacts 2023-02-01 13:15:15 +00:00
James Ritchie d97b82e572 Added an impersonation banner 2023-02-01 13:11:03 +00:00
Eric Allam 5e15aaadc3 Try going back to frozen lockfile 2023-02-01 13:06:44 +00:00
Eric Allam 5fce178cc0 Try some more stuff 2023-02-01 12:56:58 +00:00
D-K-P 2938a11685 Removed quick start and changed it to ‘anatomy of a workflow’ and ‘viewing runs’ 2023-02-01 12:55:53 +00:00
Eric Allam 3dc8751189 Try using —no-frozen-lockfile 2023-02-01 12:41:26 +00:00
D-K-P fe8b8a7131 Fixed links 2023-02-01 12:34:18 +00:00
D-K-P d7f59db79e Centered badges and sites and added tagline 2023-02-01 12:34:18 +00:00
Eric Allam a98dfecd17 Try using the latest version of pnpm in dockerfiles 2023-02-01 12:34:00 +00:00
Eric Allam 84053d5a20 Try setting a specific pnpm version in dockerfiles 2023-02-01 12:31:11 +00:00
Eric Allam 3365bf26dc Log out pnpm version in wss dockerfile as well 2023-02-01 12:28:55 +00:00
Eric Allam 3d5c646a1c Changed where the pnpm version is output 2023-02-01 12:26:03 +00:00
Eric Allam 2d97d20b37 Log out the version of pnpm during the buld process 2023-02-01 12:23:53 +00:00
Matt Aitken 731b6308e0 Sending locations is working 2023-02-01 12:14:32 +00:00
Matt Aitken c1742f0d1b Sending images working 2023-02-01 11:59:59 +00:00
Matt Aitken d57339a7c1 Reactions and replying is working 2023-02-01 11:48:48 +00:00
Eric Allam 0833d402f2 Emojify the README 2023-02-01 11:36:16 +00:00
Matt Aitken 4054571929 Metadata required for the run page 2023-02-01 11:34:13 +00:00
Matt Aitken afc47d328f Send “text” WhatsApp messages 2023-02-01 11:31:06 +00:00
Eric Allam d6925ff4b6 Fixed welcome email drip campaign subtitle 2023-02-01 11:28:43 +00:00
D-K-P a372a179d1 Added quick start and examples to the docs 2023-02-01 11:21:33 +00:00
D-K-P f8c39e3446 New welcome copy in the docs 2023-02-01 11:21:22 +00:00
Matt Aitken 868e5f4ed1 Changed the WhatsApp package exports to match the other integrations 2023-02-01 11:00:54 +00:00
Matt Aitken e6ce7ea859 WhatsApp basic template message is sending 2023-02-01 11:00:43 +00:00
Eric Allam e6d1ddc5d8 Remove exports and add main and types to package.json 2023-02-01 10:45:05 +00:00
Eric Allam 8124930841 Fixed call to getIntegrations in new workflow route 2023-02-01 10:45:00 +00:00
Eric Allam 421bd9f757 Fixed broken integration creation route 2023-02-01 10:45:00 +00:00
Matt Aitken b3bc70baa3 Instead of switch statement, grab the integrations object 2023-02-01 10:44:25 +00:00
Matt Aitken dbfff6b5f4 WhatsApp send template message 2023-02-01 10:44:09 +00:00
Matt Aitken 69004cdcf4 Revert "Match the connection using the slug"
This reverts commit c1511f233c.
2023-02-01 10:42:33 +00:00
Matt Aitken c1511f233c Match the connection using the slug 2023-02-01 10:36:34 +00:00
James Ritchie 56d23efcfa Made the onboarding page slightly easier to read 2023-01-31 18:57:30 +00:00
James Ritchie 31c6da3be4 Added a NoMobileOverlay component that displays on small screens 2023-01-31 18:37:03 +00:00
Matt Aitken 6acda311db Added lots of message types to the schemas 2023-01-31 16:48:21 +00:00
Matt Aitken 9a529492d0 WhatsApp text messages are coming through 2023-01-31 16:24:05 +00:00
D-K-P f05cfc9895 Added new readme 2023-01-31 16:14:34 +00:00
D-K-P 659637c6a5 Added workflow gif 2023-01-31 16:06:23 +00:00
D-K-P 37bf4dcadd Docs updates - added viewing runs / updated welcome / added vid to resend example 2023-01-31 16:02:48 +00:00
Matt Aitken 950138bd72 More work on WhatsApp messages 2023-01-31 16:02:02 +00:00
Matt Aitken c578891947 Removed webhook payload validation 2023-01-31 14:42:23 +00:00
Eric Allam b852731fbb Move to dual license 2023-01-31 14:32:47 +00:00
Eric Allam 5c350e216a Releasing fix for missing types 2023-01-31 13:56:06 +00:00
Eric Allam 8ac7414bba Remove exports and add main and types to package.json 2023-01-31 13:55:49 +00:00
Matt Aitken 6e8d9b4c9a WIP on webhook verification 2023-01-31 13:14:47 +00:00
Eric Allam 1dc9e1253a Set sentry to use staging env in staging 2023-01-31 12:47:03 +00:00
Eric Allam 24afe630ec Fixed call to getIntegrations in new workflow route 2023-01-31 12:42:49 +00:00
Eric Allam 5bd1f12c0d Fixed broken integration creation route 2023-01-31 12:39:14 +00:00
Eric Allam 7e3dfcdfb1 Add staging provider auth 2023-01-31 12:36:16 +00:00
Matt Aitken 24b57e026b Added support for verifying webhooks, with WhatsApp working 2023-01-31 11:57:15 +00:00
Matt Aitken 3dd0af6157 Installed @trigger.dev/whatsapp 2023-01-31 11:56:15 +00:00
Eric Allam cdaa5dfe3b Update staging to use staging auth 2023-01-31 10:25:32 +00:00
Matt Aitken a4a64affd4 Make the generic webhook input fields readonly so to get rid of React error 2023-01-31 10:18:21 +00:00
Matt Aitken a20a26e748 Updated settings for WhatsApp to match other integration packages 2023-01-31 09:53:24 +00:00
Matt Aitken 4fb9091870 Merge branch 'dev' into integrations/whatsapp
# Conflicts:
#	apps/webapp/package.json
#	apps/webapp/tsconfig.json
#	integrations/github/package.json
#	integrations/github/tsup.config.ts
#	integrations/resend/package.json
#	integrations/resend/tsup.config.ts
#	integrations/shopify/package.json
#	integrations/shopify/tsup.config.ts
#	integrations/slack/package.json
#	integrations/slack/tsup.config.ts
#	integrations/whatsapp/package.json
#	packages/integration-catalog/package.json
#	packages/integration-catalog/src/index.ts
#	packages/integration-catalog/tsconfig.json
#	packages/integration-sdk/package.json
#	pnpm-lock.yaml
2023-01-31 09:48:20 +00:00
Matt Aitken 7b29422a57 Initial setup on new WhatsApp integration 2023-01-31 09:46:34 +00:00
Eric Allam 1ef4243aaf Fixed workflow list blank state 2023-01-31 09:03:00 +00:00
D-K-P 1b696cabc1 Changed ‘login’ to ‘continue’ and updated text 2023-01-31 08:46:15 +00:00
Matt Aitken 3496053e11 Updated the CLI to point at the internal integrations metadata 2023-01-31 08:42:35 +00:00
Eric Allam fd54c86240 Updated s-webapp watch paths 2023-01-31 08:42:35 +00:00
Eric Allam 064e27f05d Update all the docs for the new packages 2023-01-31 08:42:35 +00:00
Eric Allam 89d38c04aa Added changesets for the new packages 2023-01-31 08:42:35 +00:00
Eric Allam 6c027c3c8f Remove trigger-providers, trigger-integrations, and internal-integrations and replace with integrations-catalog 2023-01-31 08:42:35 +00:00
Eric Allam fad8f44ad1 Breakout shopify into it’s own package 2023-01-31 08:42:35 +00:00
Eric Allam 5f517a5c70 Breakout resend into it’s own package 2023-01-31 08:42:35 +00:00
Eric Allam 09142cedd1 Moved internal only dependencies to devDependencies 2023-01-31 08:42:35 +00:00
Eric Allam 2bb7bad947 Breakout slack into it’s own package 2023-01-31 08:42:35 +00:00
Eric Allam d71c61fc56 Break out github into it’s own package 2023-01-31 08:42:35 +00:00
Eric Allam 3f9e7f4bda Cleanup the github stars example 2023-01-31 08:42:35 +00:00
Eric Allam e2261942a0 Added openapi spec doc and a reference page for the POST /events endpoint 2023-01-31 08:42:35 +00:00
D-K-P a015e535f0 Added github star example to the docs 2023-01-31 08:42:35 +00:00
Eric Allam 6c3c99123b Make it easier to start ngrok in different regions 2023-01-31 08:42:35 +00:00
Eric Allam c96f9f10b4 Rename Reference to SDK Reference 2023-01-31 08:42:35 +00:00
James Ritchie 23fc242dde Typo 2023-01-31 08:42:35 +00:00
James Ritchie c1ca53f513 Typo 2023-01-31 08:42:35 +00:00
James Ritchie b8dc408f0f Title improvement 2023-01-31 08:42:35 +00:00
James Ritchie b129381cf2 Improved docs title for github star example 2023-01-31 08:42:35 +00:00
James Ritchie 0141643b66 Updated the github docs example 2023-01-31 08:42:35 +00:00
James Ritchie 36cdf50c7c Removed dead link 2023-01-31 08:42:35 +00:00
D-K-P f660810fb8 Added 2 more integration logos 2023-01-31 08:42:35 +00:00
James Ritchie 8372cf71d4 Fixed a dead link in the docs 2023-01-31 08:42:35 +00:00
James Ritchie 4adad0041a Fixed typo 2023-01-31 08:42:35 +00:00
Eric Allam 887f9d1091 Try moving some shopify dependencies to prod deps 2023-01-30 21:23:04 +00:00
Eric Allam 91130472a9 Try moving @octokit/webhooks into normal deps 2023-01-30 20:55:31 +00:00
Eric Allam 7554b48948 Pushes to dev will now trigger staging deploys 2023-01-30 20:54:29 +00:00
Eric Allam 91b1edba7b Try bundling @octokit/webhooks 2023-01-30 20:46:09 +00:00
Eric Allam be86c3d45d Create a separate build entry for internal packages 2023-01-30 18:10:59 +00:00
Eric Allam 7f2fd9b1b3 Update the github client id for staging 2023-01-30 17:54:36 +00:00
Matt Aitken 4c23370735 Merge pull request #33 from triggerdotdev/dev
Fix for refresh causing server/client mismatch. Using Remix's latest entry.*.ts files
2023-01-29 09:21:36 -08:00
Matt Aitken da948c4f4b Merge pull request #32 from triggerdotdev/dev
Pass the providers into the no workflows component – it isn’t a page
2023-01-29 08:51:22 -08:00
Eric Allam c1b9aee818 Merge pull request #31 from triggerdotdev/dev
Fix issue with zod schemas getting serialized through loaders and causing errors
2023-01-29 07:07:27 +00:00
Matt Aitken 0f187803ae Merge pull request #30 from triggerdotdev/dev
Made the Slack interactivity zod schema any (to see if this is causin…
2023-01-28 17:54:07 -08:00
Matt Aitken 5423d5464f Merge pull request #29 from triggerdotdev/dev
Removed the @trigger.dev/sdk and /integrations packages from webapp
2023-01-27 23:26:17 -08:00
Matt Aitken 251b64ccf2 Revert "Revert "Merge pull request #28 from triggerdotdev/dev""
This reverts commit d6512b2ba5.
2023-01-27 23:24:26 -08:00
Matt Aitken 3e9e743751 Revert "Revert "Merge pull request #27 from triggerdotdev/dev""
This reverts commit 888c8a7460.
2023-01-27 23:24:20 -08:00
Matt Aitken 1fc7020b84 Revert "Revert "Merge pull request #26 from triggerdotdev/dev""
This reverts commit 35aedadfe9.
2023-01-27 23:24:15 -08:00
Matt Aitken 0137dac540 Revert "Revert "Merge pull request #25 from triggerdotdev/dev""
This reverts commit ba617fa7d7.
2023-01-27 23:24:11 -08:00
Matt Aitken 95d594457c Revert "Revert "Merge pull request #24 from triggerdotdev/dev""
This reverts commit 416c46d4cf.
2023-01-27 23:24:07 -08:00
Matt Aitken 416c46d4cf Revert "Merge pull request #24 from triggerdotdev/dev"
This reverts commit 56e5a5c8a4, reversing
changes made to a1b16400d5.
2023-01-27 22:13:54 -08:00
Matt Aitken ba617fa7d7 Revert "Merge pull request #25 from triggerdotdev/dev"
This reverts commit ef149bd260, reversing
changes made to 56e5a5c8a4.
2023-01-27 22:13:50 -08:00
Matt Aitken 35aedadfe9 Revert "Merge pull request #26 from triggerdotdev/dev"
This reverts commit 26c1c9f4b2, reversing
changes made to ef149bd260.
2023-01-27 22:13:47 -08:00
Matt Aitken 888c8a7460 Revert "Merge pull request #27 from triggerdotdev/dev"
This reverts commit c954b3743f, reversing
changes made to 26c1c9f4b2.
2023-01-27 22:13:35 -08:00
Matt Aitken d6512b2ba5 Revert "Merge pull request #28 from triggerdotdev/dev"
This reverts commit 92391c48cb, reversing
changes made to c954b3743f.
2023-01-27 22:13:19 -08:00
Matt Aitken 92391c48cb Merge pull request #28 from triggerdotdev/dev
Added an error boundary and set the remix-typedjson version to 0.1.3
2023-01-27 20:13:48 -08:00
Matt Aitken c954b3743f Merge pull request #27 from triggerdotdev/dev
Removed TypeForm, pull types of UseOrganizations from the loader
2023-01-27 19:29:14 -08:00
Matt Aitken 26c1c9f4b2 Merge pull request #26 from triggerdotdev/dev
Try catch the date formatting and return “unknown”
2023-01-27 18:27:45 -08:00
Matt Aitken ef149bd260 Merge pull request #25 from triggerdotdev/dev
Dev
2023-01-27 18:05:48 -08:00
Matt Aitken 56e5a5c8a4 Merge pull request #24 from triggerdotdev/dev
Added support for Slack blocks and interactivity. Docs improvements
2023-01-27 17:05:27 -08:00
Eric Allam a1b16400d5 Merge pull request #23 from triggerdotdev/dev
Fixed issue where workflow runs weren’t starting
2023-01-26 16:30:11 +00:00
Eric Allam 6bc46a8b90 Merge pull request #22 from triggerdotdev/dev
Remove internal triggers, fixed issue with react being required by @trigger.dev/integrations
2023-01-26 14:56:26 +00:00
Eric Allam 519293ca03 Merge pull request #21 from triggerdotdev/dev
Using explicit workspace: reference so we can use live packages in the monorepo
2023-01-26 14:22:10 +00:00
Eric Allam e8dfa4bea7 Merge pull request #20 from triggerdotdev/dev
Move internal triggers into their own service
2023-01-26 13:57:05 +00:00
Eric Allam fb6d254898 Merge pull request #19 from triggerdotdev/dev
More internal triggers
2023-01-26 11:52:35 +00:00
Eric Allam 7faf4312b1 Merge pull request #18 from triggerdotdev/dev
Support schedule window queries, context.isTest, and a fix for GitHub webhooks
2023-01-26 10:50:53 +00:00
Matt Aitken 3710f99270 Merge pull request #17 from triggerdotdev/dev
Added Resend docs example, removed more private beta references #17
2023-01-25 22:59:51 -08:00
Matt Aitken ea9a839886 Merge pull request #16 from triggerdotdev/dev
Fix for webhook url being built with undefined if APP_ORIGIN env var isn't set
2023-01-25 19:25:35 -08:00
Matt Aitken 94f2de81ea Merge pull request #15 from triggerdotdev/dev
Better handling of custom webhook parsing, improved webhook receive error handling
2023-01-25 18:33:24 -08:00
Matt Aitken 5ea825f5eb Merge pull request #14 from triggerdotdev/dev
Fix for integration webhook url, improved types for Resend integration
2023-01-25 17:13:16 -08:00
Matt Aitken 88306d6a63 Removed private beta message at the start of the README 2023-01-25 15:33:20 -08:00
Matt Aitken 80ebc1b1fa Merge pull request #13 from triggerdotdev/dev
Added generic webhook, fetch with retry options and updated docs
2023-01-25 15:28:40 -08:00
James Ritchie f10dadbd9f Fixed Toast widths 2023-01-24 16:53:55 -08:00
Matt Aitken 4085ad983c Merge pull request #12 from triggerdotdev/dev
Resend.com integration, fix for github webhooks, and more
2023-01-24 12:00:43 -08:00
Eric Allam 63776c7702 Merge pull request #8 from triggerdotdev/dev
Generic fetch support, and more docs
2023-01-23 14:13:52 +00:00
Matt Aitken ce8d146ed4 Merge pull request #7 from triggerdotdev/dev
Better local TypeScript support, added GitHub stars webhook and small web app improvements
2023-01-22 18:33:50 -08:00
Matt Aitken b45a5c60f7 Merge remote-tracking branch 'origin/dev' 2023-01-20 17:45:56 -08:00
Matt Aitken 1c62f16117 Merge remote-tracking branch 'origin/dev' 2023-01-20 14:24:55 -08:00
Matt Aitken 67a0d54f74 Merge pull request #6 from triggerdotdev/dev
Slack postMessage now takes channelId or channelName
2023-01-20 14:17:43 -08:00
223 changed files with 8373 additions and 8863 deletions
+2 -6
View File
@@ -7,9 +7,5 @@
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": [
"wss",
"webapp",
"docs"
]
}
"ignore": ["wss", "webapp"]
}
+2 -1
View File
@@ -44,4 +44,5 @@ yarn-error.log*
.env
.output
apps/**/public/build
.tests-container-id.txt
.tests-container-id.txt
.sentryclirc
+5
View File
@@ -19,3 +19,8 @@ Based on the instructions [here](https://github.com/changesets/changesets/blob/m
1. Run `pnpm run changeset:version`
2. Run `pnpm run changeset:release`
## Pre-release instructions
- Switch into pre-release mode by running `pnpm run changeset:next`.
- Switch back into normal mode by running `pnpm run changeset:normal`.
+20 -196
View File
@@ -1,201 +1,25 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Copyright (c) 2022 API Hero Inc.
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
Portions of this software are licensed as follows:
1. Definitions.
- All content that resides under any "ee/" directory of this repository, if such directories exists, are licensed under the license defined in "ee/LICENSE".
- All third party components incorporated into the Trigger.dev Software are licensed under the original license provided by the owner of the applicable component.
- Content outside of the above mentioned directories or restrictions above is available under the "MIT Expat" license as defined below.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+142 -314
View File
@@ -1,377 +1,205 @@
<div align="center">
![Hero](https://raw.githubusercontent.com/triggerdotdev/trigger.dev/eebe37109e33beae6390ee19029fce8a5934c84b/apps/webapp/public/images/logo-banner.png)
[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/triggerdotdev.svg?style=social&label=Follow%20%40trigger.dev)](https://twitter.com/triggerdotdev) [![YouTube Channel Subscribers](https://img.shields.io/youtube/channel/subscribers/UCu-PdxpWtIrrd7vW0N5T6ZA?style=social)](https://www.youtube.com/@triggerdotdev)
[![GitHub Repo stars](https://img.shields.io/github/stars/triggerdotdev/trigger.dev?style=social)](https://github.com/triggerdotdev/trigger.dev)
[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/triggerdotdev.svg?style=social&label=Follow%20%40trigger.dev)](https://twitter.com/triggerdotdev)
[![Docs](https://img.shields.io/badge/-Documentation-blueviolet)](https://docs.trigger.dev)
[Website](https://trigger.dev) | [Community](https://discord.gg/JtBAxBr2m3) | [Docs](https://docs.trigger.dev)
</div>
# **⚡️ Trigger.dev**
### **The developer-first open source Zapier alternative.**
# ⚙️ Effortless automation built for developers
Trigger workflows from APIs, on a schedule, or on demand. API calls are easy with authentication handled for you. Add durable delays that survive server restarts.
![Hero](https://trigger.dev/_next/static/media/hero-image.4c367bbf.png?imwidth=1920)
# 💻 Developer-first features
## In your codebase
Trigger.dev is code-first so you can create workflows where they belong: in your codebase. Version control, localhost, test, review, and deploy like you're used to.
## Secure by design
Your workflows run on your servers, not ours. We only receive the data you choose to send to us.
Trigger.dev is an open source platform that makes it easy for developers to create event-driven background tasks directly in their code. Build, test and run workflows locally using our SDK. Subscribe to webhooks, schedule jobs, run background jobs and add long delays easily and reliably. In our web app you get full visibility of every run your workflow has ever made making it easier to monitor and debug.
&nbsp;
# Hundreds of Integrations
# **⭐️ Features:**
Subscribe to API changes and make requests, well handle authentication for you.
- 👂 Easily subscribe to [webhooks](https://docs.trigger.dev/triggers/webhooks)
— they work locally without tunnelling.
- 🔥 Fire your own [custom events](https://docs.trigger.dev/triggers/custom-events)—a single event can trigger multiple workflows.
- 📆 [Schedule workflows](https://docs.trigger.dev/triggers/scheduled)—easily repeat tasks or use CRON syntax for advanced cases.
- 🚦 Add [long delays](https://docs.trigger.dev/functions/delays) inside workflows (up to a year) and they will pick up where they left off.
- 🤝 When your server goes down [its not a problem](https://docs.trigger.dev/guides/resumability), workflows will reconnect and continue.
- 🪧 [View every step of every run](https://docs.trigger.dev/viewing-runs), with data, previews and errors.
- 👋 Connect to and authenticate with APIs using our custom integrations.
- 🚗 If you have a custom use case, we support [Fetch for calling any HTTP endpoint](https://docs.trigger.dev/functions/fetch) or [webhooks](https://docs.trigger.dev/triggers/webhooks) for subscribing to events from APIs.
- 📡 All API calls are automatically retried with exponential back off.
- 😀 TypeScript SDK, so whether youre using JavaScript or TypeScript you will have a great experience.
&nbsp;
# 🚀 Workflow examples
# **🌱 Documentation:**
## 🔄 Sync GitHub issues to Linear
- [Getting Started with Trigger.dev](https://docs.trigger.dev/getting-started)
- Example workflows
- [Welcome email drip campaign using Resend and Slack](https://docs.trigger.dev/examples/resend)
- [Post to Slack when a GitHub issue is created or modified](https://docs.trigger.dev/examples/slack)
- [Create a new product on Shopify](https://docs.trigger.dev/examples/shopify)
- [When a GitHub repo is starred, post information about the user to Slack](https://docs.trigger.dev/examples/github)
- Triggers:
- [Webhooks](https://docs.trigger.dev/triggers/webhooks)
- [Custom events](https://docs.trigger.dev/triggers/custom-events)
- [Scheduled](https://docs.trigger.dev/triggers/scheduled)
- Functions:
- [Fetch](https://docs.trigger.dev/functions/fetch)
- [Logging](https://docs.trigger.dev/functions/logging)
- [Delays](https://docs.trigger.dev/functions/delays)
- [Send event](https://docs.trigger.dev/functions/send-event)
- [Loops, conditionals, etc](https://docs.trigger.dev/functions/loops-conditionals-etc)
![GitHub](https://img.shields.io/badge/-GitHub-gray) ![Linear](https://img.shields.io/badge/-Linear-blue)
&nbsp;
Triggered when a GitHub issue is created or updated. Query your database to map GitHub user ids to Linear user ids. Then create or update Linear issues.",
# 🔬 **Anatomy of a workflow**
```Typescript
* You create workflows in code on your server using our SDK
* Each API integration is a separate package, e.g. `@trigger.dev/slack`
* Each workflow has an event that triggers it, e.g. `github.events.newStarEvent`, `scheduleEvent`, `customEvent`
* Each workflow has a `run` function that is called when the event is triggered
* If we don't have an integration for the API you want to use, you can use `fetch` to call any HTTP endpoint and `webhookEvent` to subscribe to webhooks
import { Trigger, github, linear } from "@trigger.dev/sdk";
## **Example workflows**
<details open><summary> Post to Slack when a GitHub issue is created or modified
</summary>
_Integrations required: Slack, GitHub_
```ts
import { Trigger } from "@trigger.dev/sdk";
import * as github from "@trigger.dev/github";
import * as slack from "@trigger.dev/slack";
new Trigger({
name: "Sync Github issues to Linear",
on: github.issueEvent({
repo: "acme/website",
}),
run: async (event, ctx) => {
const { issue, action } = event;
// Find the user in our local database
const assignee = await findUserByGithubId(issue.assignee?.id);
if (action === "opened") {
await linear.issueCreate({
id: issue.id,
title: issue.title,
description: issue.body,
assigneeId: assignee?.linearId,
teamId: ctx.env.LINEAR_TEAM_ID,
id: "new-github-star-to-slack",
name: "New GitHub Star: triggerdotdev/trigger.dev",
apiKey: "<my_api_key>",
on: github.events.newStarEvent({
repo: "triggerdotdev/trigger.dev",
}),
run: async (event) => {
await slack.postMessage("github-stars", {
channelName: "github-stars",
text: `New GitHub star from \n<${event.sender.html_url}|${event.sender.login}>`,
});
} else {
await linear.issueUpdate(issue.id, {
assigneeId: assignee?.linearId,
stateId:
action === "closed"
? ctx.env.LINEAR_CLOSED_STATE_ID
: ctx.env.LINEAR_OPEN_STATE_ID,
});
}
},
},
}).listen();
```
&nbsp;
</details>
## ✉️ Send emails to new users
<details><summary>Welcome email drip campaign
</summary>
![User](https://img.shields.io/badge/-User-gray) ![Email](https://img.shields.io/badge/-Email-gray) ![Slack](https://img.shields.io/badge/-Slack-purple)
_Integrations required: Slack, Resend_
Triggered on demand by your other code when a user is created. We wait for 3 hours then send a follow-up email if the user hasnt completed onboarding yet.
```Typescript
import { Trigger, customEvent, slack, mailgun } from "@trigger.dev/sdk";
```ts
import { customEvent, Trigger, sendEvent } from "@trigger.dev/sdk";
import * as resend from "@trigger.dev/resend";
import * as slack from "@trigger.dev/slack";
import React from "react";
import { z } from "zod";
import { getUser } from "../db";
import { InactiveEmail, TipsEmail, WelcomeEmail } from "./email-templates";
new Trigger({
name: "Send Email to New Users",
on: customEvent<UserEvent>({ name: "user.created" }),
run: async (event, ctx) => {
// Wait for 3 hours before continuing
await ctx.waitFor({ hours: 3 });
id: "welcome-email-campaign",
name: "Welcome email drip campaign",
apiKey: "<my_api_key>",
on: customEvent({
name: "user.created",
schema: z.object({
userId: z.string(),
}),
}),
async run(event, context) {
//get the user data from the database
const user = await getUser(event.userId);
// Lookup user in the database
const user = await findUserById(event.id);
await slack.postMessage("send-to-slack", {
channelName: "new-users",
text: `New user signed up: ${user.name} (${user.email})`,
});
// only send email if user has not onboarded
if (!user.hasOnboarded) {
await mailgun.send({
to: user.email,
subject: "Welcome to our app!",
body: `Welcome to our app ${user.name}!}`,
});
//Send the first email
const welcomeResponse = await resend.sendEmail("welcome-email", {
from: "Trigger.dev <james@email.trigger.dev>",
replyTo: "James <james@trigger.dev>",
to: user.email,
subject: "Welcome to Trigger.dev",
react: <WelcomeEmail name={user.name} />,
});
await context.logger.debug(
`Sent welcome email to ${welcomeResponse.to} with id ${welcomeResponse.id}`
);
await slack.sendMessage({
text: `Welcome email sent to ${user.email}`,
//wait 1 day, check if the user has created a workflow and send the appropriate email
await context.waitFor("wait-a-while", { days: 1 });
const updatedUser = await getUser(event.userId);
if (updatedUser.hasOnboarded) {
await resend.sendEmail("onboarding-complete", {
from: "Trigger.dev <james@email.trigger.dev>",
replyTo: "James <james@trigger.dev>",
to: updatedUser.email,
subject: "Pro tips for workflows",
react: <TipsEmail name={updatedUser.name} />,
});
} else {
await slack.sendMessage({
text: `User ${user.email} has already onboarded`,
await resend.sendEmail("onboarding-incomplete", {
from: "Trigger.dev <james@email.trigger.dev>",
replyTo: "James <james@trigger.dev>",
to: updatedUser.email,
subject: "Help with your first workflow",
react: <InactiveEmail name={updatedUser.name} />,
});
}
},
}).listen();
```
&nbsp;
</details>
## 🚨 Escalate critical incidents
![Intercom](https://img.shields.io/badge/-Intercom-blue) ![Linear](https://img.shields.io/badge/-Linear-blue) ![Slack](https://img.shields.io/badge/-Slack-purple) ![PagerDuty](https://img.shields.io/badge/-PagerDuty-green)
Triggered when an Intercom incident happens. We create a Linear issue, send a Slack message and, if its an urgent incident, we alert whoever is on call.
```Typescript
import { Trigger, intercom, linear, slack, pagerduty } from "@trigger.dev/sdk";
new Trigger({
name: "Intercom Incident",
on: intercom.newIncident(),
run: async (event, ctx) => {
// Find the customer in the database
const customer = await db.query("SELECT * FROM users WHERE email = $1", [
event.email,
]);
// Create linear ticket
const ticket = await linear.issueCreate({
title: event.title,
description: event.description,
assigneeId: ctx.env.LINEAR_ASSIGNEE_ID,
teamId: ctx.env.LINEAR_TEAM_ID,
});
// notify account manager
await slack.sendMessage({
text: `New incident for ${customer.name} in Linear: ${ticket.url}`,
});
if (event.severity === "urgent") {
// Create a pagerduty incident
await pagerduty.createIncident({
title: event.title,
description: event.description,
severity: "critical",
serviceId: ctx.env.PAGERDUTY_SERVICE_ID,
});
}
},
}).listen();
```
[More examples here](https://docs.trigger.dev/examples/examples)
&nbsp;
# ⚡️ Trigger happy
# 👀 **Viewing runs:**
Install our SDK and get instant access to an arsenal of triggers you can use in your code:
One of the most powerful features of Trigger.dev is the [runs page](https://docs.trigger.dev/viewing-runs). All of the steps in a workflow, including the initial event, can be viewed in detail. See the status / output of each step, the logs, rich previews, errors and much more.
![Viewing runs](https://mintlify.s3-us-west-1.amazonaws.com/api-hero/images/run-succeeded.png)
### **Webhooks**
Subscribe to webhooks without creating API endpoints. Plus they work locally without tunneling.
```Typescript
github.issueEvent({ repo: "acme/website" })
```
### **Scheduled (CRON)**
Easily subscribe to a recurring schedule using human readable code or CRON syntax.
```Typescript
scheduleEvent({ every: { minutes: 30 } })
```
### **Custom Events**
Trigger workflows from any event in your app. Send us your events, and we'll do the rest.
```Typescript
customEvent<YourType>({ name: "your.event" })
```
### **HTTP Endpoint**
Expose a HTTP endpoint to trigger your workflows with the method and path of your choice.
```Typescript
httpEvent<User>({ method: "POST", path: "/users/:id" })
```
### **Receive Emails**
Receive emails from your custom domain and trigger a workflow with the email metadata and content.
```Typescript
emailEvent({ address: "support@help.customdomain.io" })
```
### **AWS Event Bridge**
Integrate with AWS Event Bridge to trigger workflows on your own Event Bridge events.
```Typescript
eventBridge<SupportRequest>({ bus: "customer-support" })
```
&nbsp;
# 🔋 Batteries included
# **🏠 Running Trigger.dev locally:**
### **Debugging and visibility**
We provide a full history of all runs, so you can see exactly what happened.
To run Trigger.dev locally, [follow these steps](https://github.com/triggerdotdev/trigger.dev/blob/main/DEVELOPMENT.md).
&nbsp;
<img src="https://trigger.dev/_next/static/media/runs-diagram.c9ce4213.png" alt="Runs" width="400"/>
# **👏 Contributing:**
We are open source and love contributions!
- Request a feature in our [Discord community](https://discord.gg/JtBAxBr2m3)
- Open a PR
&nbsp;
---
# **🧘‍♂️ Self-hosting guide:**
Please subscribe to the [GitHub issue](https://github.com/triggerdotdev/trigger.dev/issues/48) to be notified when it's live.
&nbsp;
### **Survives downtime**
Workflows pick up where they left off when your server or external APIs go down.
# **📧 Support & contact:**
&nbsp;
<img src="https://trigger.dev/_next/static/media/retries-diagram.d90a00d9.png
" alt="Retries" width="400"/>
&nbsp;
# Go from idea to production in minutes
## **1. Code**
Write workflows by creating triggers directly in your code. These can be 3rd-party integrations, custom events or on a schedule.
## **2. Connect**
When your server runs, your workflow will be registered and you can authenticate with any APIs youre using.
## **3. Test**
When your server runs, your workflow will be registered and you can authenticate with any APIs youre using.
## **3. Deploy**
Deploy your new workflow as you would any other code commit and inspect each workflow run in real time.
&nbsp;
# ✅ We ❤️ Open Source!
Youll always be able to host and run Trigger.dev yourself.
We've also created [JSON Hero](https://github.com/triggerdotdev/jsonhero-web), an open source JSON viewer used by around 55,000 developers per month.
&nbsp;
# 🙋 FAQs
<details><summary> Does my data get sent to your servers?</summary><br>
Only what you choose to send. The main body of your workflow code runs on your infrastructure.
For example when you do a database query, that never touches us.
Data we will receive (and store to display on the Runs page in your dashboard):
- Any data that triggers the start of a workflow
- Any data you pass to one of our API integrations • Any data you choose to log using our logging function
</details>
<details><summary> How is this different to Zapier, Pipedream etc?</summary><br>
Trigger.dev is a code-first workflow tool that lets you create workflows directly in your code, rather than using a UI builder like Zapier. This means you can stay in your own IDE and keep your internal data secure.
</details>
<details><summary>How long does this take to set up?</summary><br>
Setting up Trigger.dev is simple and takes 2 minutes. Install our SDK to get started and check out the Getting Started documentation to start creating your first workflow.
</details>
<details><summary>Can I use version control or roll-backs?</summary><br>
Yes. You create workflows directly in your own code so its version controlled with everything else.
</details>
<details><summary>How long does it take to code up a workflow?</summary><br>
A simple workflow triggering two events from different services will take about 5 minutes to create.
</details>
<details><summary>Do you have all the integrations I need?</summary><br>
Probably. Trigger.dev includes over 100 integrations including the most popular services. If you need a specific service thats not available, you can request it, or create it yourself. Were open source, so create an issue or Pull Request.
</details>
<details><summary>Can I build complex workflows?</summary><br>
Yes. Theres no limit to the complexity on workflows you can create. Workflows are created in code so you can write conditional, looping, branching or time delayed logic.
</details>
<details><summary> Can I run Trigger.dev locally?</summary><br>
Yes. Workflows are created in your code locally and, unlike webhooks, you dont need to use tunneling to receive triggers.
</details>
<details><summary>How does the pricing model work?</summary><br>
Our hosted product gives you free runs each month, after that you will need to select a paid tier. You can also self-host, view the open source repository for instructions.
</details>
<details><summary>Is Trigger.dev open source?</summary><br>
Yes, Trigger.dev is open source. We are strong supporters of open source software, and our first product, [jsonhero.io](https://jsonhero.io), has a thriving open source community. Trigger.dev follows in that tradition.
</details>
<details><summary>Is Trigger.dev a no/low-code tool?</summary><br>
No. Trigger.dev is designed for developers who want to create workflows directly in code, without using a UI builder like Zapier. This allows developers to stay in their familiar development environment and customise their workflows with code.
</details>
<details><summary>What languages / frameworks do you support?</summary><br>
Currently there is support for Node.js. More frameworks will be added soon.
</details>
<details><summary>Can I use an API which doesnt have webhooks?</summary><br>
Yes. You can use a polling trigger to subscribe is no webhook exists.
</details>
<details><summary>Can non-coders use this product?</summary><br>
Developers will need to create workflows. Anyone on the team can monitor running workflows in the Trigger dashboard.
</details>
&nbsp;
---
&nbsp;
If you have any other questions about Trigger.dev, [drop us an email](mailto:hello@trigger.dev), and one of the founders will get back to you.
- Join our [Discord community](https://discord.gg/JtBAxBr2m3)
- If you have any other questions, get in touch at [hello@trigger.dev](mailto:hello@trigger.dev)
-34
View File
@@ -1,34 +0,0 @@
# Mintlify Starter Kit
Click on `Use this template` to quickstarter your documentation setup with Mintlify. The starter kit contains examples including
- Guide pages
- Navigation
- Customizations
- API Reference pages
- Use of popular components
### 👩‍💻 Development
Run these from the root of the repository
```
pnpm install --filter docs
```
```
pnpm run dev --filter docs
```
Go to http://localhost:3050
### 😎 Publishing Changes
Changes will be deployed to production automatically after pushing to the default branch.
You can also preview changes using PRs, which generates a preview link of the docs.
#### Troubleshooting
- Mintlify dev isn't running - Run `mintlify install` it'll re-install dependencies.
- Mintlify dev is updating really slowly - Run `mintlify clear` to clear the cache.
-6
View File
@@ -1,6 +0,0 @@
---
title: "Send Event"
openapi: "POST /events"
sidebarTitle: "Send Event"
description: "Send a custom event to Trigger through the API."
---
-23
View File
@@ -1,23 +0,0 @@
---
title: "Example workflows"
sidebarTitle: "Overview"
description: "Example workflows to use in your projects."
---
Not sure what to build? Take a look through our examples for inspiration.
You can use these workflows in your product by following the instructions on each page.
<CardGroup>
<Card title="GitHub" icon="github" href="/examples/github">
When a GitHub repo is starred, post information about the user to Slack
</Card>
<Card title="Shopify" icon="shopify" href="/examples/shopify">
Create a new product in my Shopify store.
</Card>
<Card title="Slack" icon="slack" href="/examples/slack">
Post to Slack when a GitHub issue is created or modified.
</Card>
<Card title="Resend" icon="envelope" href="/examples/resend">
Create a welcome email drip campaign.
</Card>
</CardGroup>
-62
View File
@@ -1,62 +0,0 @@
---
title: "GitHub"
sidebarTitle: "GitHub"
description: "Here are some example workflows you could create using the GitHub integration."
---
You can explore all the supported GitHub functions [here](/integrations/apis/github/events/push).
## When a GitHub repo is starred, post information about the user to Slack
Integrations required: GitHub, Slack
```ts
import { Trigger } from "@trigger.dev/sdk";
import * as github from "@trigger.dev/github";
import * as slack from "@trigger.dev/slack";
new Trigger({
id: "new-github-star-to-slack",
name: "New GitHub Star: triggerdotdev/trigger.dev",
apiKey: "<my_api_key>",
on: github.events.newStarEvent({
repo: "triggerdotdev/trigger.dev",
}),
run: async (event) => {
await slack.postMessage("github-stars", {
channelName: "github-stars",
text: `New GitHub star from \n<${event.sender.html_url}|${event.sender.login}>`,
});
},
}).listen();
```
## When a GitHub issue is created or modified, post to Slack
Integrations required: GitHub, Slack
```ts
import { Trigger } from "@trigger.dev/sdk";
import * as github from "@trigger.dev/github";
import * as slack from "@trigger.dev/slack";
new Trigger({
id: "my-workflow-1",
name: "Posts to Slack when GitHub Issue created or modified",
apiKey: "<my_api_key>",
on: github.events.issueEvent({
repo: "my-github-org/my-github-repo",
}),
run: async (event, ctx) => {
const response = await slack.postMessage("send-to-slack", {
channelName: "my-slack-channel-name",
text: `A new issue has been created or modified. ${event.action}`,
});
return response.message;
},
}).listen();
```
You can explore all the supported GitHub functions [here](/integrations/apis/github/events/push).
-205
View File
@@ -1,205 +0,0 @@
---
title: "Shopify"
sidebarTitle: "Shopify"
description: "Here are some example workflows you could create using the Shopify integration."
---
## Create a new product
Integrations required: Shopify
```ts
import { Trigger, customEvent } from "@trigger.dev/sdk";
import { z } from "zod";
import * as shopify from "@trigger.dev/shopify";
new Trigger({
id: "shopify-products",
name: "Shopify products",
apiKey: "<my_api_key>",
on: customEvent({
name: "shopify.products",
schema: z.object({}),
}),
run: async (event, ctx) => {
const newProduct = await shopify.createProduct("create-product", {
descriptionHtml: "This is my brilliant <i>product description</i>.",
title: `Fantastic product ${Math.floor(Math.random() * 1000)}`,
productType: "t-shirt",
vendor: "Nike",
options: ["Color", "Size"],
standardizedProductType: {
productTaxonomyNodeId: "gid://shopify/ProductTaxonomyNode/352",
},
variants: [
{
price: "99.99",
sku: "variant-1",
inventoryItem: {
tracked: true,
},
inventoryQuantities: [
{
availableQuantity: 1,
locationId: "gid://shopify/Location/76187369773",
},
],
options: ["Maroon", "Tiny"],
},
],
});
const newImages = await shopify.appendProductImages("append-images", {
id: newProduct.id,
images: [
{
src: "https://via.placeholder.com/600/92c952.png",
altText: "Image 1",
},
{
src: "https://via.placeholder.com/600/d32776.png",
altText: "Image 2",
},
],
});
return newProduct;
},
}).listen();
```
## Update a product
Integrations required: Shopify
```ts
import { Trigger, customEvent } from "@trigger.dev/sdk";
import { z } from "zod";
import * as shopify from "@trigger.dev/shopify";
new Trigger({
id: "shopify-update-product",
name: "Shopify update product",
apiKey: "<my_api_key>",
on: customEvent({
name: "product.update",
schema: z.object({
id: z.string(),
}),
}),
run: async (event, ctx) => {
const product = await shopify.updateProduct("update-product", {
id: event.id,
descriptionHtml: `<h1>Awesome product title</h1><p>With incredible description</p>`,
});
return product;
},
}).listen();
```
## Add a product to a collection
Integrations required: Shopify
```ts
import { Trigger, customEvent } from "@trigger.dev/sdk";
import { z } from "zod";
import * as shopify from "@trigger.dev/shopify";
new Trigger({
id: "shopify-add-product-to-collection",
name: "Shopify add product to collection",
apiKey: "<my_api_key>",
on: customEvent({
name: "product.new",
schema: z.object({
id: z.string(),
}),
}),
run: async (event, ctx) => {
const collection = await shopify.addProductsToCollection(
"add-products-to-collection",
{
collectionId: "gid://shopify/Collection/431864578349",
productIds: [event.id],
}
);
return collection;
},
}).listen();
```
## Create new product variants with images
Integrations required: Shopify
```ts
import { Trigger, customEvent } from "@trigger.dev/sdk";
import { z } from "zod";
import * as shopify from "@trigger.dev/shopify";
const sizes = ["Small", "Medium", "Large"];
const colors = [
"Red",
"Orange",
"Yellow",
"Green",
"Blue",
"Purple",
"Pink",
"Brown",
"Black",
"White",
"Gray",
"Silver",
"Gold",
"Beige",
];
const materials = ["Cotton", "Polyester", "Lycra", "Wool", "Silk", "Leather"];
function pickRandom(array: string[]): string {
return array[Math.floor(Math.random() * array.length)];
}
new Trigger({
id: "shopify-product-variants",
name: "Shopify product variants",
apiKey: "<my_api_key>",
on: customEvent({
name: "shopify.product-variants",
schema: z.object({}),
}),
run: async (event, ctx) => {
await ctx.logger.info("Get Shopify products variants");
const results = await shopify.searchProductVariants(
"get-shopify-variants",
{
filter: {
productId: ["gid://shopify/Product/8098295546157"],
sku: ["variant-1"],
},
}
);
const newVariant = await shopify.createProductVariant("create-variant", {
productId: results.productVariants[0].product.id,
inventoryQuantities: [
{
availableQuantity: 10,
locationId: "gid://shopify/Location/76187369773",
},
],
price: "12.34",
sku: `variant-${Math.floor(Math.random() * 1000)}`,
options: [pickRandom(sizes), pickRandom(materials)],
});
await ctx.logger.debug("Debug message");
return newVariant;
},
}).listen();
```
-33
View File
@@ -1,33 +0,0 @@
---
title: "Slack"
sidebarTitle: "Slack"
description: "Here are some example workflows you could create using the Slack integration."
---
## Post to Slack when a GitHub issue is created or modified
Integrations required: Slack, GitHub
```ts
import { Trigger, customEvent } from "@trigger.dev/sdk";
import * as slack from "@trigger.dev/slack";
import * as github from "@trigger.dev/github";
import { z } from "zod";
new Trigger({
id: "my-workflow-1",
name: "Posts to Slack when GitHub Issue created or modified",
apiKey: "<my_api_key>",
on: github.events.issueEvent({
repo: "my-github-org/my-github-repo",
}),
run: async (event, ctx) => {
const response = await slack.postMessage("send-to-slack", {
channelName: "my-slack-channel-name",
text: `A new issue has been created or modified. ${event.action}`,
});
return response.message;
},
}).listen();
```
-91
View File
@@ -1,91 +0,0 @@
---
title: "Delays"
sidebarTitle: "Delays"
description: "You can trigger workflow steps to fire before and after a delay. There are 2 types of delay, waitFor and waitUntil."
---
## `waitFor` delay
`waitFor` takes a unique key and an object that sets the desired time as a key value pair.
```ts
await ctx.waitFor("wait-for-1", { seconds: 30 });
```
<Note>Reminder: Ensure all keys are unique across all triggers.</Note>
### Example
This example posts a message to Slack after a 30 second delay:
```ts
import { Trigger, customEvent } from "@trigger.dev/sdk";
import * as slack from "@trigger.dev/slack";
import * as github from "@trigger.dev/github";
import { z } from "zod";
new Trigger({
id: "wait-for-example",
name: "Post to Slack after delay",
apiKey: "<my_api_key>",
on: customEvent({
name: "waitForExample",
schema: z.object({
id: z.string(),
}),
}),
run: async (event, ctx) => {
await ctx.waitFor("initial-wait", { seconds: 30 });
const response = await slack.postMessage("send-to-slack", {
channel: "my-slack-channel",
text: `This message posted after a 30 second delay.`,
});
return response.message;
},
}).listen();
```
## `waitUntil` delay
`waitUntil` takes a unique key and a date function to set desired time.
```ts
await ctx.waitUntil("wait-until-1", new Date(Date.now() + 1000 * 60 * 1));
```
<Note>Reminder: Ensure all keys are unique across all triggers.</Note>
### Example
This example posts a message to Slack 1 hour after the workflow triggers:
```ts
import { Trigger, customEvent } from "@trigger.dev/sdk";
import * as slack from "@trigger.dev/slack";
import * as github from "@trigger.dev/github";
import { z } from "zod";
new Trigger({
id: "wait-until-example",
name: "Post to Slack after 1hr delay",
apiKey: "<my_api_key>",
on: customEvent({
name: "waitUntilExample",
schema: z.object({
id: z.string(),
}),
}),
run: async (event, ctx) => {
await ctx.waitUntil("wait-until", new Date(Date.now() + 1000 * 60 * 1));
const response = await slack.postMessage("send-to-slack", {
channel: "my-slack-channel",
text: `This message posted after a 30 second delay.`,
});
return response.message;
},
}).listen();
```
-248
View File
@@ -1,248 +0,0 @@
---
title: "Generic Fetch"
sidebarTitle: "Fetch"
description: "A generic fetch function that can be used to call any HTTP endpoint"
---
## Usage
A `fetch` function is available to use inside a `Trigger.run` function through the `context` argument, and should be familiar for anyone who has used the standard [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) API, with a few modifications.
```ts
import { Trigger } from "@trigger.dev/sdk";
new Trigger({
id: "fetch-example",
name: "Fetch Example",
on: customEvent({
name: "example.fetch",
}),
run: async (event, ctx) => {
await ctx.fetch("Example Key", "http://httpbin.org/get");
},
}).listen();
```
Notice the first parameter to `fetch` is a `key` that is used to identify this call to fetch to support resumability. Please see the [Resumability](/guides/resumability) guide for more information.
You can also import `fetch` and use it outside of a `Trigger.run` function:
```ts httpBin.ts
import { fetch } from "@trigger.dev/sdk";
export function httpBinGet() {
return fetch("Example Key", "http://httpbin.org/get");
}
```
Now you can use the exported `httpBinGet` function inside your `Trigger.run` function:
```ts
import { Trigger } from "@trigger.dev/sdk";
import { httpBinGet } from "./httpBin";
new Trigger({
id: "fetch-example",
name: "Fetch Example",
on: customEvent({
name: "example.fetch",
}),
run: async (event, ctx) => {
await httpBinGet();
},
}).listen();
```
This is useful if you want to wrap `fetch` to provide an SDK like experience inside your workflows.
<Warning>
Calling `fetch` when not inside of a workflow run will result in a thrown
Error.
</Warning>
## Response
<Tip>
Make sure to check `response.ok`, as non-2xx status codes will not throw an
error and will instead return a response with `ok` set to `false`.
</Tip>
The return value of `fetch` is a similar to a normal fetch response, but we will automatically parse the response body as JSON and provide it as `body`, like so:
```ts
const response = await ctx.fetch("Example Key", "http://httpbin.org/get");
if (response.body) {
console.log(response.body.url); // http://httpbin.org/get
}
```
By default, the `body` is typed as `any`, but you can provide a [Zod](/guides/zod) schema to validate the response body and get a more specific type:
```ts
import { z } from "zod";
const response = await ctx.fetch("Get HTTPBin", "http://httpbin.org/get", {
responseSchema: z.object({
url: z.string(),
origin: z.string(),
headers: z.record(z.string()),
}),
});
```
Now the `body` will be typed as:
```ts
{
url: string;
origin: string;
headers: Record<string, string>;
}
```
It's okay to not be comprehensive with the schema, as long as the response body matches the schema, it will be valid. Do note that any properties not included in the schema will be excluded, unless you use `.passthrough()`:
```ts
const response = await ctx.fetch("Get HTTPBin", "http://httpbin.org/get", {
responseSchema: z.object({
url: z.string(),
origin: z.string(),
headers: z.record(z.string()),
}),
});
console.log(response.body); // Only includes url, origin, and headers
// Using passthrough():
const response = await ctx.fetch("Get HTTPBin", "http://httpbin.org/get", {
responseSchema: z
.object({
url: z.string(),
origin: z.string(),
headers: z.record(z.string()),
})
.passthrough(),
});
console.log(response.body); // Includes url, origin, headers, and everything else
```
<Note>
The fetch function currently only supports JSON request and response bodies.
</Note>
## Secret values
If you are using a header with a secret value, you can use our `secureString` [tagged template](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates) to ensure that the value is not logged in the trigger.dev logs:
```ts
import { Trigger, secureString } from "@trigger.dev/sdk";
new Trigger({
id: "fetch-example",
name: "Fetch Example",
on: customEvent({
name: "example.fetch",
}),
run: async (event, ctx) => {
await ctx.fetch("🔑 Secret API", "http://httpbin.org/post", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: secureString`Bearer ${process.env.SECRET_API_KEY}`,
},
});
},
}).listen();
```
Which will show in the trigger.dev app as:
![title](/images/secure-string.png)
## Retrying
By default, we will retry a failed request up to 10 times if it has one of the following status codes: `408`, `429`, `500`, `502`, `503`, `504`. You can override this behavior by providing a `retry` option:
```ts
await ctx.fetch("Example Key", "http://httpbin.org/get", {
retry: {
maxAttempts: 5,
statusCodes: [408, 429, 500, 502, 503, 504, 521, 522, 524],
minTimeout: 1000,
maxTimeout: 10000,
factor: 1.2,
},
});
```
| Property | Description | Default |
| ----------- | ---------------------------------------- | ---------------------------------------- |
| enabled | Enables retrying of failed requests | true |
| factor | The exponential factor of backoff | 1.8 |
| minTimeout | The minimum amount of ms between retries | 1000 |
| maxTimeout | The maximum amount of ms between retries | 60000 |
| statusCodes | The HTTP Status Codes that are retryable | `408`, `429`, `500`, `502`, `503`, `504` |
If you'd like to disable retrying, simple pass in the `retry` option with `enabled` set to `false`:
```ts
await ctx.fetch("Example Key", "http://httpbin.org/get", {
retry: {
enabled: false,
},
});
```
## Params
<ParamField path="key" type="string" required={true}>
A unique string. Please see the [Keys and Resumability](/guides/resumability)
doc for more info.
</ParamField>
<ParamField path="url" type="string | URL" required={true}>
The URL to fetch.
</ParamField>
<ParamField path="options" type="object" required={false}>
<Expandable title="properties">
<ParamField path="method" type="string" required={false}>
The HTTP method to use. Defaults to `GET`.
</ParamField>
<ParamField path="headers" type="record" required={false}>
An object of headers to send with the request.
</ParamField>
<ParamField path="responseSchema" type="zod Schema" required={false}>
A [Zod](/guides/zod) schema to validate the response body.
</ParamField>
<ParamField path="body" type="json" required={false}>
The body to send with the request. Only valid for `POST`, `PUT`, and `PATCH`. You don't need to `JSON.stringify` before passing it in.
</ParamField>
</Expandable>
</ParamField>
## Response
<ParamField path="ok" type="boolean">
Whether the response was successful. Non-2xx status codes will have `ok =
false`.
</ParamField>
<ParamField path="body" type="object" required={false}>
The response body, parsed with the `responseSchema` if provided. Can be
undefined if the response body is empty.
</ParamField>
<ParamField path="status" type="number">
The HTTP status code.
</ParamField>
<ParamField path="headers" type="Record<string, string>">
The response headers.
</ParamField>
-41
View File
@@ -1,41 +0,0 @@
---
title: "Logging"
sidebarTitle: "Logging"
description: "There are 4 different types of logs you can add as workflow steps."
---
If you'd like to add additional logging to your workflow run, you can use our built-in logging utility
## Usage
```ts
import { Trigger } from "@trigger.dev/sdk";
new Trigger({
id: "my-trigger",
on: scheduleEvent({ rateOf: { minutes: 5 } }),
run: async (event, ctx) => {
await ctx.logger.info("It's been 5 minutes since the last run!");
},
}).listen();
```
This will log the message to your workflow run page in the Trigger dashboard
There are 4 different types of logs you can add as workflow steps:
```ts
await ctx.logger.info("It's been 5 minutes since the last run!");
await ctx.logger.debug("This is a debug log");
await ctx.logger.warn("This is a warning");
await ctx.logger.error("This is an error");
```
You can also include a second argument to the logger to add additional metadata to the log:
```ts
await ctx.logger.info("It's been 5 minutes since the last run!", {
foo: "bar",
baz: 123,
});
```
@@ -1,50 +0,0 @@
---
title: "Loops, Conditionals…"
sidebarTitle: "Loops, Conditionals…"
description: "Write any type of code."
---
Currently, we don't have anything special for loops or conditionals. You can just write plain-old TypeScript code and it will Just Work™.
## Loops
When you perform an action (sendEvent, delays, etc.) inside of a loop, make sure to create unique keys for each action to make sure that your workflows are [Resumable](/guides/resumability):
```ts
for (let i = 0; i < 10; i++) {
await ctx.waitFor(`Wait ${i}`, { seconds: 30 });
await slack.postMessage(`⭐️ New Star ${i}`, {
channelName: "github-stars",
text: `@${starredBy} just starred ${repoName}!`,
});
}
```
## Parallel Execution
You can run actions in parallel using `Promise.all`, like so:
```ts
await Promise.all(
messages.map((message) =>
slack.postMessage(message.id, {
channelName: "github-stars",
text: message.text,
})
)
);
```
## Conditionals
You can use `if` statements to conditionally execute code, just like normal code:
```ts
if (ctx.event.payload.action === "opened") {
await slack.postMessage("New Issue", {
channelName: "github-issues",
text: `@${ctx.event.payload.sender.login} just opened an issue!`,
});
}
```
-201
View File
@@ -1,201 +0,0 @@
---
title: "Send event"
sidebarTitle: "Send event"
description: "Send events to trigger your custom events workflows."
---
## Send an event
You can easily send an event from anywhere, including from inside another workflow. Events don't have to come from the same server as your workflow and can be sent as HTTP requests from any language (see our cURL example below for the format).
<Tabs>
<Tab title="Our Node.js SDK">
```ts
import { sendEvent } from "@trigger.dev/sdk";
//send an event with the name "user.created"
//and the payload
await sendEvent("start-fire-2", {
name: "user.created",
payload: { userId: "123456" },
});
```
</Tab>
<Tab title="cURL">
```bash
curl --request POST \
--url https://app.trigger.dev/api/v1/events \
--header 'Authorization: Bearer <insert_api_key_here>' \
--header 'Content-Type: application/json' \
--data '{
"id": "<optional unique event id>",
"event": {
"name": "user.created",
"payload": {
"userId": "123456"
}
}
}'
```
</Tab>
</Tabs>
If you are calling this from inside a workflow, ensure that the first parameter is unique inside your workflow.
## Sending events from other workflows
It is useful to send events from workflows because you can split your logic into smaller chunks and reuse them. The below example shows how a scheduled workflow delegates the work via sending a custom event:
<CodeGroup>
```ts check-scheduler.ts
new Trigger({
id: "check-scheduler",
name: "Check Scheduler",
on: scheduleEvent({ rateOf: { minutes: 10 } }),
run: async (event, context) => {
await context.sendEvent("health.check trigger.dev", {
name: "health.check",
payload: {
url: "https://trigger.dev",
host: "trigger.dev",
},
});
await context.sendEvent("health.check docs.trigger.dev", {
name: "health.check",
payload: {
url: "https://docs.trigger.dev",
host: "docs.trigger.dev",
},
});
await context.sendEvent("health.check app.trigger.dev", {
name: "health.check",
payload: {
url: "https://app.trigger.dev/healthcheck",
host: "app.trigger.dev",
},
});
},
}).listen();
```
```ts health-check.ts
export const healthCheck = new Trigger({
id: "health-check",
name: "Health Check",
on: customEvent({
name: "health.check",
schema: z.object({
url: z.string().url(),
host: z.string(),
}),
}),
run: async (event, context) => {
const response = await context.fetch("fetch site", event.url, {
method: "GET",
retry: {
enabled: false,
},
});
if (response.ok) {
await context.logger.info(`${event.host} is up!`);
return;
}
await slack.postMessage("Site is down", {
channelName: "health-checks",
text: `${event.host} is down: ${response.status}`,
});
},
}).listen();
```
</CodeGroup>
## Delaying event delivery
Through both our Node.js SDK and our HTTP API, you can delay the delivery of an event. This is useful if you want to send an event to trigger a workflow, but you want to wait for a certain amount of time before the event is delivered.
Using the health check example above, we can delay the delivery of the `health.check` event in various ways:
```ts
new Trigger({
id: "check-scheduler",
name: "Check Scheduler",
on: scheduleEvent({ rateOf: { minutes: 10 } }),
run: async (event, context) => {
await context.sendEvent("health.check trigger.dev", {
name: "health.check",
payload: {
url: "https://trigger.dev",
host: "trigger.dev",
},
delay: { until: new Date(Date.now() + 1000 * 60 * 5) }, // Delay until a specific date
});
await context.sendEvent("health.check docs.trigger.dev", {
name: "health.check",
payload: {
url: "https://docs.trigger.dev",
host: "docs.trigger.dev",
},
delay: { minutes: 5 }, // Delay for a specific amount of time
});
await context.sendEvent("health.check app.trigger.dev", {
name: "health.check",
payload: {
url: "https://app.trigger.dev/healthcheck",
host: "app.trigger.dev",
},
delay: { seconds: 30 }, // Delay for a specific amount of time
});
},
}).listen();
```
<Note>
When sending events in the context of a workflow run, adding a delay DOES NOT
add a delay to the workflow run, as sending a custom event is a
fire-and-forget action.
</Note>
You can add delays via the HTTP API by adding a `delay` object to the event:
```bash
curl --request POST \
--url https://app.trigger.dev/api/v1/events \
--header 'Authorization: Bearer <insert_api_key_here>' \
--header 'Content-Type: application/json' \
--data '{
"id": "<optional unique event id>",
"event": {
"name": "user.created",
"payload": {
"userId": "123456"
},
"delay": {
"seconds": 30
}
}
}'
```
## Event deduplication
When sending events, you can specify an `id` for the event. If you send an event with the same `id` multiple times, only the first event will be delivered. This is useful if you want to ensure that an event is only delivered once, even if you send it multiple times.
```ts
sendEvent({
id: "my-event-id",
name: "my-event",
payload: { foo: "bar" },
});
```
-26
View File
@@ -1,26 +0,0 @@
---
title: "Get in touch with us!"
sidebarTitle: "Get help"
description: "Contact us if you have any questions, or would like help with any issues."
---
<Note>We are active in the community and will respond to all messages.</Note>
Please email us at <a href="mailto:help@trigger.dev">help@trigger.dev</a> or choose one of the options below:
<CardGroup>
<Card
title="Join the communty"
icon="discord"
href="https://discord.gg/nkqV9xBYWy"
>
The place to meet other users, the team and to get product updates.
</Card>
<Card
title="Schedule a call"
icon="video"
href="https://cal.com/team/triggerdotdev/support"
>
A call with someone from our support team. We are happy to help.
</Card>
</CardGroup>
-239
View File
@@ -1,239 +0,0 @@
---
title: "Getting started with Trigger.dev"
sidebarTitle: "Quick start"
description: "Get your first workflow running in just a few minutes"
---
Trigger.dev workflows are written in your codebase and run in your existing infrastructure. This means:
- They are version controlled with the rest of your code.
- They run locally and don't require you to use tunnels.
<Note>
Currently we require you to have a long-running Node.js server, e.g. Express.
Support for serverless is coming soon.
</Note>
## 1. Installing @trigger.dev packages
In your existing project install the packages:
<Tabs>
<Tab title="npm">
```bash
npm install @trigger.dev/sdk @trigger.dev/slack zod
```
</Tab>
<Tab title="pnpm">
```bash
pnpm install @trigger.dev/sdk @trigger.dev/slack zod
```
</Tab>
<Tab title="yarn">
```bash
yarn add @trigger.dev/sdk @trigger.dev/slack zod
```
</Tab>
</Tabs>
What do the packages do?
- `@trigger.dev/sdk` is required to use Trigger.dev, it allows you to run workflows.
- `@trigger.dev/slack` is the official Slack integration, which allows you to interact with the Slack API.
- `zod` is used to define schemas (the expected shape of an object).
## 2. Sign in to your Trigger.dev dashboard
Go to [trigger.dev](https://app.trigger.dev) and sign up or login to your account.
## 3. Get your API keys
In the bottom-left corner of an Organization page you can find your API keys.
![API Keys](/images/api-keys.png)
## 4. Creating your first workflow
Workflows are triggered by events. In this example, we have defined a custom event called `user.created`. We support many different types of events including webhooks, scheduled, and more coming soon.
```ts first-workflow.ts
import { Trigger, customEvent } from "@trigger.dev/sdk";
import { postMessage } from "@trigger.dev/slack";
import { z } from "zod";
new Trigger({
id: "new-user",
name: "New user slack message",
apiKey: "<your_api_key>",
on: customEvent({
name: "user.created",
schema: z.object({
name: z.string(),
email: z.string(),
paidPlan: z.boolean(),
}),
}),
run: async (event, ctx) => {
await ctx.logger.info("This log will appear on the Trigger.dev run page");
//send a message to the #new-users Slack channel with user details
const response = await postMessage("send-to-slack", {
channel: "new-users",
text: `New user: ${event.name} (${event.email}) signed up. ${
event.paidPlan ? "They are paying" : "They are on the free plan"
}.`,
});
return response.message;
},
}).listen();
```
You'll notice that when we subscribe to the custom event we have to say the name of the event and provide a schema. Schemas are created using Zod. In this case events must send an object that has `name`, `email`, and `paidPlan`.
<Note>
If the event is triggered with an object that doesn't match this schema, the
workflow won't run.
</Note>
<Note>
Above we set the API key inside the Trigger object. We recommend instead that
you add an environment variable called `TRIGGER_API_KEY`. That way you can use
your development API key locally and the production one when you deploy.
</Note>
## 6. Run your web server
Run your server how you normally would, e.g. `npm run dev`. This will connect your workflow to Trigger.dev, so we can start sending you events. You should see some log messages in your server console (tip: you can turn these off by removing the `logLevel: "info"` from the code above).
## 5. Testing your workflow from the dashboard
Now that the workflow is connected to Trigger.dev we need to trigger it. You can easily test your workflow from [your Trigger.dev dashboard](https://app.trigger.dev).
On the organization page you should see that the Workflow has now appeared (you may need to refresh the page from last time).
!["New user slack message" workflow](/images/workflow.png)
Move to the "New user slack message" and you will see the workflow page. There have been no runs yet.
Move to the "Test" page and input a valid test event, remember the workflow expects a name, email and paidPlan. You can copy this:
```json
{
"name": "Rick Astley",
"email": "nevergonn@giveyou.up",
"paidPlan": true
}
```
Hit the "Run test" button and it will take us to our first run 🚀!
![Test a run](/images/run-test.png)
## 6. The run page
All of the steps in a workflow, including the initial event, can be viewed in detail. You will need to refresh the page if it's running to see it move between steps.
But there's a problem, we've used Slack in our code and we haven't authenticated.
![Test run failed](/images/run-failed.png)
## 7. Authenticating with Slack
When a workflow step uses an API integration that you haven't already authenticated with, it will pause until you've authenticated.
Simply click the "Connect to Slack" button and sign-in with your desired Slack workspace. As soon as you do, the workflow will pick up where it left off.
Test complete!
![Test a run](/images/run-succeeded.png)
## 8. Triggering this workflow from code
As this workflow uses a custom event, we need to manually trigger it from our code. Anywhere in your code you can do this:
```ts
import { sendEvent } from "@trigger.dev/sdk";
/*
...your other code
*/
await sendEvent(uuidv4(), {
name: "user.created"
payload: {
name: "Eleven",
email: "jane@hawksmoorhigh.edu",
paidPlan: true,
},
});
```
<Note>
If you are using `sendEvent` outside of a Trigger, make sure and set your API
key to the `TRIGGER_API_KEY` environment variable. See the
[sendEvent](/functions/send-event) docs for more info.
</Note>
When you run your server and this code executes, it will trigger the workflow. You will see this in the run list on your workflow page.
You can also use our API to send events from other programming languages. See the [sendEvent](/api/events/sendEvent) API reference for more info.
## Next steps
<Card
title="Join the communty"
icon="discord"
href="https://discord.gg/nkqV9xBYWy"
>
Meet other users, get help and product updates. We will respond to all
messages and will help with any issues.
</Card>
There are many things we didn't cover here, including Webhook and Scheduled triggers. Below are a some more features to explore:
### Triggers
Triggers are what cause your workflows to run.
<CardGroup>
<Card title="Webhooks" icon="rectangle-terminal" href="/triggers/webhooks">
Easily subscribe to the APIs you're using
</Card>
<Card title="Scheduled" icon="clock" href="/triggers/scheduled">
Trigger your workflows on a repeating schedule
</Card>
<Card title="Custom events" icon="code" href="/triggers/custom-events">
More details on custom events
</Card>
<Card title="More coming soon" icon="bookmark">
On received email, HTTP endpoint and AWS Event Bridge
</Card>
</CardGroup>
### Functions
<CardGroup>
<Card
title="API integrations"
icon="rectangle-terminal"
href="/integrations/apis"
>
We are making it easy to use lots of APIs by adding integrations.
</Card>
<Card title="Fetch" icon="server" href="/functions/fetch">
Call any API from your workflow
</Card>
<Card title="Delays" icon="alarm-clock" href="/functions/delays">
Add delays to your workflows. They're resilient so it doesn't matter if your
server goes down.
</Card>
<Card title="Send event" icon="code" href="/functions/send-event">
Send an event, to trigger a custom event workflow
</Card>
</CardGroup>
-64
View File
@@ -1,64 +0,0 @@
---
title: "Event Driven Architecture"
sidebarTitle: "Event Driven"
description: "How to build an event driven architecture using Trigger.dev"
---
## Event-driven Patterns in Trigger.dev
### Claim check pattern
Inspired by [this post](https://serverlessland.com/event-driven-architecture/visuals/claim-check-pattern) by [@boyney123](https://twitter.com/boyney123), here is how you could implement the claim check pattern using Trigger.dev:
```ts
import { Trigger } from "@trigger.dev/sdk";
import * as github from "@trigger.dev/github";
import { db } from "./db.server";
new Trigger({
id: "issue-producer",
on: github.events.issueEvent({
repo: "triggerdotdev/trigger.dev",
}),
run: async (event, ctx) => {
// 1. Store the event in a database (e.g. MongoDB, DynamoDB, etc.)
const id = await db.insert(ctx.id, event);
// 2. Send a new event with the id of the stored event
await ctx.sendEvent("📧 Send Event", {
name: "github.issue",
payload: {
id,
action: event.payload.action,
},
});
},
}).listen();
```
The above workflow will store any issue events from the trigger.dev repo in a database. Then, it will send a new event with the name `github.issue` and the id and action of the stored event. This event can then trigger another workflow and be used to retrieve the original event from the database:
```ts
import { Trigger, customEvent } from "@trigger.dev/sdk";
import { db } from "./db.server";
import { z } from "zod";
new Trigger({
id: "opened-issue-consumer",
on: customEvent({
name: "github.issue",
filter: {
action: ["opened"],
}
schema: z.object({ id: z.string() }),
}),
run: async (event, ctx) => {
// 3. Retrieve the event from the database
const event = await db.get(ctx.id);
// 4. Do something with the event
},
}).listen();
```
As you can see above we filtered the event to only trigger when the action is `opened`. This is because we only want to do something when an issue is opened. We also used a schema to validate the event payload (which in this pattern is pretty simple).
-53
View File
@@ -1,53 +0,0 @@
---
title: "Event Filters"
sidebarTitle: "Event Filters"
description: "Event filters are used to filter events based on their attributes."
---
Event filters are used to filter events based on their attributes in the [customEvent](/reference/custom-event) and [webhookEvent](/reference/webhook-event) triggers.
They are declarative pattern-matching rules, modeled after [AWS EventBridge patterns](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns.html).
Given the following custom event payload:
```json
{
{
"uid": "jexAgaeJFJsrGfans1pxqm",
"type": "15 Min Meeting",
"price": 0,
"title": "15 Min Meeting between Eric Allam and John Doe",
"length": 15,
"status": "ACCEPTED",
"endTime": "2023-01-25T16:00:00Z",
"bookingId": 198052,
"organizer": {
"id": 32794,
"name": "Eric Allam",
"email": "eric@trigger.dev",
"language": { "locale": "en" },
"timeZone": "Europe/London"
},
}
}
```
The following event filter would match the event:
```json
{
"type": ["15 Min Meeting"],
"status": ["ACCEPTED", "REJECTED"],
"organizer": {
"name": ["Eric Allam"]
}
}
```
For an event pattern to match an event, the event must contain all the field names listed in the event pattern. The field names must also appear in the event with the same nesting structure.
The value of each field name in the event pattern must be an array of strings, numbers, or booleans. The event pattern matches the event if the value of the field name in the event is equal to any of the values in the array.
Effectively, each array is an OR condition, and the entire event pattern is an AND condition.
So the above event filter will match because `status == "ACCEPTED"`, and it would also match if `status == "REJECTED"`.
-72
View File
@@ -1,72 +0,0 @@
---
title: "Resumability"
sidebarTitle: "Keys and Resumability"
description: "Understand how keys work to ensure resumability of long-running workflows in Trigger.dev"
---
## Intro
In this article, we'll cover how Trigger.dev handles resumability of long-running workflows. We'll also cover how to use keys to ensure that your workflows are resumable.
## What is resumability?
Resumability is the ability of a workflow run to continue from where it left off after a failure or interruption. For example, if a workflow run is interrupted due to a network failure, it should be able to resume from where it left off when the network is back up.
We accomplish this by storing the state of the workflow run in a database, and when a workflow run is resumed we will call the `Trigger.run` function again.
We use step "keys" to determine which steps have already been executed. If a step has already been executed, we will skip it and move on to the next step.
## How to use keys
Like we mentioned above, we use step keys to determine which steps have already been executed. They are defined by you inside your `Trigger.run` function, for example when you call `slack.postMessage`:
```ts
await slack.postMessage("⭐️ New Star", {
channelName: "github-stars",
text: `@${starredBy} just starred ${repoName}!`,
});
```
In this example, the key is the string `"⭐️ New Star"`. This means that if the workflow is interrupted and then resumed, the `slack.postMessage` step will be skipped because it has already been executed.
If you make multiple calls to `slack.postMessage`, you should use different keys for each call. For example:
```ts
await slack.postMessage("⭐️ New Star", {
channelName: "github-stars",
text: `@${starredBy} just starred ${repoName}!`,
});
await slack.postMessage("🚨 Critical Issue", {
channelName: "critical-issues",
text: `@${assignee} just opened a critical issue in ${repoName}!`,
});
```
If you are calling a step multiple times with the same key, it will only be executed once. For example, if you call `slack.postMessage` with the key `"⭐️ New Star"` twice, it will only be executed once.
## How to use keys with loops
If you are using a loop, you should use the loop index as the key. For example:
```ts
for (let i = 0; i < 10; i++) {
await ctx.waitFor(`Wait ${i}`, { seconds: 30 });
await slack.postMessage(`⭐️ New Star ${i}`, {
channelName: "github-stars",
text: `@${starredBy} just starred ${repoName}!`,
});
}
```
## When to use keys
The following functions in Trigger.dev require a `key` parameter:
- Integration actions (e.g. `slack.postMessage`)
- [delays](/functions/delays)
- [sendEvent](/functions/send-event)
- [fetch](/functions/fetch)
[Logging](/functions/logging) does not require a key, as we are currently using the log message as the key.
-312
View File
@@ -1,312 +0,0 @@
---
title: "Zod Guide"
sidebarTitle: "Zod"
description: "TypeScript-first schema validation with static type inference"
---
## Intro
Zod is a fantastic utility package by [@colinhacks](https://twitter.com/colinhacks) that allows for defining runtime schema validation and type-safety.
We use it [extensively](https://github.com/search?q=repo%3Atriggerdotdev%2Ftrigger.dev+%22zod%22%3B&type=code) internally at Trigger.dev to ensure we never trigger your workflows with invalid data (and more).
But there are a few places where we ask you to provide us with a Zod schema, for example when defining a [Custom Event Trigger](/triggers/custom-events):
```ts
import { Trigger, customEvent } from "@trigger.dev/sdk";
import * as slack from "@trigger.dev/slack";
import { z } from "zod";
//this workflow will run when a "user.created" event is sent
new Trigger({
id: "zod",
name: "Zod custom event",
//this is the custom event subscription
on: customEvent({
name: "user.created",
schema: z.object({
name: z.string(),
email: z.string(),
paidPlan: z.boolean(),
}),
}),
//this function is run when the custom event is received
run: async (event, ctx) => {
console.log(event); // Has name, email, paidPlan
},
}).listen();
```
So it will help to know a little about Zod and how to use it. We definitely recommend the well written [Zod README](https://github.com/colinhacks/zod#readme) but we've included a short primer below.
<Tip>
Wherever we require you to pass in a Zod schema, you can always start with
`z.any()` which accepts `any` type and then add more strict validations later.
</Tip>
## Basic Usage
There are three main steps to using Zod:
1. Define a schema
```ts
import { z } from "zod";
const mySchema = z.object({
name: z.string(),
email: z.string(),
paidPlan: z.boolean(),
});
```
2. Infer TypeScript types from the schema
```ts
type MySchema = z.infer<typeof mySchema>;
```
3. Validate data against the schema
```ts
const data: unknown = {
name: "Eric",
email: "eric@trigger.dev",
paidPlan: true,
};
const result = mySchema.parse(data);
```
When using Zod with Trigger.dev, you'll only really need to do the first step, and by passing it to us (through the `schema` property of the `customEvent` function), we'll do the second and third steps for you.
## Defining Schemas
### Primitives
Zod schemas are a way to define the shape of an object. They can be as simple as a single type, or as complex as a nested object.
```ts
// Primitives
z.string();
z.number();
z.boolean();
z.date();
z.undefined();
z.null();
```
Any schema can be marked as optional, which means the schema can be `undefined` or `null`:
```ts
z.string().optional();
```
Schemas can also be marked optional by providing a default value:
```ts
const optionalString = z.string().default("default value");
const value = optionalString.parse(undefined); // value === "default value"
```
If you need to allow a value to be `null`, you can use `nullable()`:
```ts
const nullableString = z.string().nullable();
const value = nullableString.parse(null);
```
You can also use Zod to coerce primites into other types. For example, you can coerce a string into a number:
```ts
const numberString = z.coerce.number();
const value = numberString.parse("123"); // value === 123
```
The following primitives are supported:
```ts
z.coerce.string();
z.coerce.number();
z.coerce.boolean();
z.coerce.bigint();
z.coerce.date();
```
Coercing dates are especially useful when you are receiving a `string` from an API and want to convert it to a JavaScript `Date` object:
```ts
const date = z.coerce.date();
const value = date.parse("2021-01-01T00:00:00.000Z"); // value === Date object
```
### Objects
Object schemas are the most common type of schema. They allow you to define the shape of an object, and the types of each property.
```ts
const mySchema = z.object({
name: z.string(),
email: z.string(),
paidPlan: z.boolean(),
});
```
All properties are required by default, although you can make them all optional using `partial()`:
```ts
const mySchema = z
.object({
name: z.string(),
email: z.string(),
paidPlan: z.boolean(),
})
.partial();
```
You can also make individual properties optional:
```ts
const mySchema = z.object({
name: z.string(),
email: z.string(),
paidPlan: z.boolean().optional(),
});
```
By default an object schema will strip out any extra properties that are not defined in the schema. You can disable this behavior using `passthrough()`:
```ts
const mySchema = z.object({
name: z.string(),
});
mySchema.parse({ name: "Eric", email: "eric@trigger.dev" }); // { name: "Eric" }
mySchema.passthrough().parse({ name: "Eric", email: "eric@trigger.dev" }); // { name: "Eric", email: "eric@trigger.dev" }
```
Or you can use `strict()` to make the schema throw an error if there are any extra properties:
```ts
const mySchema = z
.object({
name: z.string(),
})
.strict();
mySchema.parse({ name: "Eric", email: "eric@trigger.dev" }); // throws error
```
Zod includes a few useful object schema utilities to help with reusing schemas, `extends()` and `merge()`:
```ts
const baseSchema = z.object({
name: z.string(),
});
const extendedSchema = baseSchema.extend({
email: z.string(),
});
const mergedSchema = baseSchema.merge(
z.object({
email: z.string(),
})
);
```
You can also use `pick()` and `omit()` to create a new schema that only includes or excludes certain properties:
```ts
const mySchema = z.object({
name: z.string(),
email: z.string(),
paidPlan: z.boolean(),
});
const pickedSchema = mySchema.pick({ name: true, email: true });
const omittedSchema = mySchema.omit({ paidPlan: true });
```
### Arrays
You can specify the schema of an array using `z.array()`:
```ts
z.array(z.string()); // string[]
z.array(z.number()); // number[]
z.array(z.object({ name: z.string() })); // Array<{ name: string }>
```
You can also specify the type of array that has a fixed number of elements using `z.tuple()`:
```ts
z.tuple([z.string(), z.number(), z.boolean()]); // [string, number, boolean]
```
### Unions
You can specify a union of schemas using `z.union()`:
```ts
z.union([z.string(), z.number(), z.boolean()]); // string | number | boolean
```
Discriminating unions are also supported, and especially useful when paired with type narrowing:
```ts
const mySchema = z.discriminatingUnion("type", [
z.object({
type: z.literal("a"),
data: z.string(),
}),
z.object({
type: z.literal("b"),
data: z.number(),
}),
]);
const value = mySchema.parse({ type: "a", data: "hello" });
if (type.a) {
// value is { type: "a", data: string }
} else if (type.b) {
// value is { type: "b", data: number }
}
```
### Records
You can specify a record of schemas using `z.record()`, useful for when you have a map of values but don't care about the keys:
```ts
z.record(z.string()); // Record<string, string>
z.record(z.number()); // Record<string, number>
```
### JSON type
If you want to accept any valid JSON value, you can use the following schema:
```ts
const literalSchema = z.union([z.string(), z.number(), z.boolean(), z.null()]);
type Literal = z.infer<typeof literalSchema>;
type Json = Literal | { [key: string]: Json } | Json[];
const jsonSchema: z.ZodType<Json> = z.lazy(() =>
z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)])
);
jsonSchema.parse(data);
```
Hat tip to [ggoodman](https://github.com/ggoodman) for this one.
## Resources
Matt Pocock [@mattpocock](https://twitter.com/mattpocockuk) has a great free Zod Tutorial up on [Total Typescript](https://www.totaltypescript.com/tutorials/zod) that covers the basics of Zod.
Easily generate Zod schemas from [JSON](https://transform.tools/json-to-zod), [JSON Schemas](https://transform.tools/json-schema-to-zod), or [TypeScript](https://transform.tools/typescript-to-zod) types.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 405 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 754 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 402 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 463 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 346 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 360 KiB

-32
View File
@@ -1,32 +0,0 @@
---
title: "APIs"
sidebarTitle: "APIs"
description: "Integrations"
---
## Coming soon
We will show each API as a subpage. Each API page will break down all the functions available for each API. It will also link to the relevant sample projects.
<CardGroup>
<Card
title="GitHub"
icon="rectangle-terminal"
href="/integrations/apis/github"
></Card>
<Card
title="Shopify"
icon="rectangle-terminal"
href="/integrations/apis/shopify"
></Card>
<Card
title="Slack"
icon="rectangle-terminal"
href="/integrations/apis/slack"
></Card>
</CardGroup>
### Do you need a specific integration?
If so, [let us know](mailto:hello@trigger.dev) and we'll build it for
you.
-11
View File
@@ -1,11 +0,0 @@
---
title: "GitHub"
sidebarTitle: "GitHub"
description: "Support for the GitHub API"
---
## GitHub API integration
Full reference of all functions is coming soon.
Check out some example workflows using the GitHub API [here](/examples/github).
@@ -1,19 +0,0 @@
---
title: "GitHub Events"
sidebarTitle: "Events"
description: "GitHub Triggers"
---
## GitHub API integration
Full reference of all functions is coming soon.
Check out some example workflows using the GitHub API [here](/examples/github).
### Events
These are the events you can use to trigger a workflow
### Requests
These are the requests you can make to the GitHub API.
@@ -1,376 +0,0 @@
---
title: "Issue Comment Event"
sidebarTitle: "Issue Comments"
description: "Trigger a workflow whenever an issue_comment action is performed in a GitHub repository."
---
## Usage
```ts
import * as github from "@trigger.dev/github";
new Trigger({
id: "demo",
on: github.events.issueCommentEvent({
repo: "triggerdotdev/trigger.dev",
}),
run: async (event, ctx) => {},
}).listen();
```
## Params
<ParamField path="repo" type="string" required={true}>
The full path to the repository, including the organization
</ParamField>
## Event
<ResponseField name="action" type="string">
The issue_comment action, which can be either created, deleted, or edited.
</ResponseField>
<ResponseField name="comment" type="object" required={true}>
The comment object.
</ResponseField>
<ResponseField name="issue" type="object" required={true}>
The issue object.
</ResponseField>
<ResponseField name="repository" type="object" required={true}>
A repository on GitHub.
</ResponseField>
<ResponseField name="sender" type="object" required={true}>
The GitHub user object who performed the action.
</ResponseField>
<ResponseField name="organization" type="object">
The organization object the repository belongs to.
</ResponseField>
## Example Workflows
<CodeGroup>
```typescript Notify Slack on new Issue comment
new Trigger({
id: "github-to-slack",
name: "Notify Slack on new Issue comment",
on: github.events.issueCommentEvent({
repo: "triggerdotdev/trigger.dev",
}),
run: async (event, ctx) => {
if (event.action === "created") {
await slack.postMessage("New Comment", {
channelName: "github-issues",
text: `New comment on issue ${event.issue.title} by ${event.sender.login}: ${event.comment.html_url}`,
});
}
},
}).listen();
```
</CodeGroup>
## Example Event payload
```json
{
"issue": {
"id": 1548436712,
"url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/1",
"body": "Changed the body text once",
"user": {
"id": 10635986,
"url": "https://api.github.com/users/matt-aitken",
"type": "User",
"login": "matt-aitken",
"node_id": "MDQ6VXNlcjEwNjM1OTg2",
"html_url": "https://github.com/matt-aitken",
"gists_url": "https://api.github.com/users/matt-aitken/gists{/gist_id}",
"repos_url": "https://api.github.com/users/matt-aitken/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/10635986?v=4",
"events_url": "https://api.github.com/users/matt-aitken/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/matt-aitken/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/matt-aitken/followers",
"following_url": "https://api.github.com/users/matt-aitken/following{/other_user}",
"organizations_url": "https://api.github.com/users/matt-aitken/orgs",
"subscriptions_url": "https://api.github.com/users/matt-aitken/subscriptions",
"received_events_url": "https://api.github.com/users/matt-aitken/received_events"
},
"state": "open",
"title": "Changed test issue title",
"labels": [
{
"id": 5003355458,
"url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/labels/documentation",
"name": "documentation",
"color": "0075ca",
"default": true,
"node_id": "LA_kwDOIxVdCc8AAAABKjklQg",
"description": "Improvements or additions to documentation"
},
{
"id": 5003355474,
"url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/labels/enhancement",
"name": "enhancement",
"color": "a2eeef",
"default": true,
"node_id": "LA_kwDOIxVdCc8AAAABKjklUg",
"description": "New feature or request"
}
],
"locked": false,
"number": 1,
"node_id": "I_kwDOIxVdCc5cS0To",
"assignee": null,
"comments": 6,
"html_url": "https://github.com/triggerdotdev/trigger.dev-examples/issues/1",
"assignees": [],
"closed_at": null,
"milestone": {
"id": 8941544,
"url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/milestones/1",
"state": "open",
"title": "Test milestone",
"due_on": "2023-01-20T08:00:00Z",
"number": 1,
"creator": {
"id": 10635986,
"url": "https://api.github.com/users/matt-aitken",
"type": "User",
"login": "matt-aitken",
"node_id": "MDQ6VXNlcjEwNjM1OTg2",
"html_url": "https://github.com/matt-aitken",
"gists_url": "https://api.github.com/users/matt-aitken/gists{/gist_id}",
"repos_url": "https://api.github.com/users/matt-aitken/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/10635986?v=4",
"events_url": "https://api.github.com/users/matt-aitken/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/matt-aitken/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/matt-aitken/followers",
"following_url": "https://api.github.com/users/matt-aitken/following{/other_user}",
"organizations_url": "https://api.github.com/users/matt-aitken/orgs",
"subscriptions_url": "https://api.github.com/users/matt-aitken/subscriptions",
"received_events_url": "https://api.github.com/users/matt-aitken/received_events"
},
"node_id": "MI_kwDOIxVdCc4AiG_o",
"html_url": "https://github.com/triggerdotdev/trigger.dev-examples/milestone/1",
"closed_at": null,
"created_at": "2023-01-19T03:02:37Z",
"labels_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/milestones/1/labels",
"updated_at": "2023-01-19T17:21:25Z",
"description": "",
"open_issues": 1,
"closed_issues": 0
},
"reactions": {
"+1": 0,
"-1": 0,
"url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/1/reactions",
"eyes": 0,
"heart": 0,
"laugh": 0,
"hooray": 0,
"rocket": 0,
"confused": 0,
"total_count": 0
},
"created_at": "2023-01-19T02:50:49Z",
"events_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/1/events",
"labels_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/1/labels{/name}",
"updated_at": "2023-01-24T04:18:52Z",
"comments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/1/comments",
"state_reason": "reopened",
"timeline_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/1/timeline",
"repository_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples",
"active_lock_reason": null,
"author_association": "MEMBER",
"performed_via_github_app": null
},
"action": "created",
"sender": {
"id": 534,
"url": "https://api.github.com/users/ericallam",
"type": "User",
"login": "ericallam",
"node_id": "MDQ6VXNlcjUzNA==",
"html_url": "https://github.com/ericallam",
"gists_url": "https://api.github.com/users/ericallam/gists{/gist_id}",
"repos_url": "https://api.github.com/users/ericallam/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/534?v=4",
"events_url": "https://api.github.com/users/ericallam/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/ericallam/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/ericallam/followers",
"following_url": "https://api.github.com/users/ericallam/following{/other_user}",
"organizations_url": "https://api.github.com/users/ericallam/orgs",
"subscriptions_url": "https://api.github.com/users/ericallam/subscriptions",
"received_events_url": "https://api.github.com/users/ericallam/received_events"
},
"comment": {
"id": 1401375866,
"url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/comments/1401375866",
"body": "New comment",
"user": {
"id": 534,
"url": "https://api.github.com/users/ericallam",
"type": "User",
"login": "ericallam",
"node_id": "MDQ6VXNlcjUzNA==",
"html_url": "https://github.com/ericallam",
"gists_url": "https://api.github.com/users/ericallam/gists{/gist_id}",
"repos_url": "https://api.github.com/users/ericallam/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/534?v=4",
"events_url": "https://api.github.com/users/ericallam/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/ericallam/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/ericallam/followers",
"following_url": "https://api.github.com/users/ericallam/following{/other_user}",
"organizations_url": "https://api.github.com/users/ericallam/orgs",
"subscriptions_url": "https://api.github.com/users/ericallam/subscriptions",
"received_events_url": "https://api.github.com/users/ericallam/received_events"
},
"node_id": "IC_kwDOIxVdCc5Th0x6",
"html_url": "https://github.com/triggerdotdev/trigger.dev-examples/issues/1#issuecomment-1401375866",
"issue_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/1",
"reactions": {
"+1": 0,
"-1": 0,
"url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/comments/1401375866/reactions",
"eyes": 0,
"heart": 0,
"laugh": 0,
"hooray": 0,
"rocket": 0,
"confused": 0,
"total_count": 0
},
"created_at": "2023-01-24T04:18:52Z",
"updated_at": "2023-01-24T04:18:52Z",
"author_association": "MEMBER",
"performed_via_github_app": null
},
"repository": {
"id": 588602633,
"url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples",
"fork": false,
"name": "trigger.dev-examples",
"size": 161,
"forks": 0,
"owner": {
"id": 95297378,
"url": "https://api.github.com/users/triggerdotdev",
"type": "Organization",
"login": "triggerdotdev",
"node_id": "O_kgDOBa4fYg",
"html_url": "https://github.com/triggerdotdev",
"gists_url": "https://api.github.com/users/triggerdotdev/gists{/gist_id}",
"repos_url": "https://api.github.com/users/triggerdotdev/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/95297378?v=4",
"events_url": "https://api.github.com/users/triggerdotdev/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/triggerdotdev/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/triggerdotdev/followers",
"following_url": "https://api.github.com/users/triggerdotdev/following{/other_user}",
"organizations_url": "https://api.github.com/users/triggerdotdev/orgs",
"subscriptions_url": "https://api.github.com/users/triggerdotdev/subscriptions",
"received_events_url": "https://api.github.com/users/triggerdotdev/received_events"
},
"topics": [],
"git_url": "git://github.com/triggerdotdev/trigger.dev-examples.git",
"license": null,
"node_id": "R_kgDOIxVdCQ",
"private": false,
"ssh_url": "git@github.com:triggerdotdev/trigger.dev-examples.git",
"svn_url": "https://github.com/triggerdotdev/trigger.dev-examples",
"archived": false,
"disabled": false,
"has_wiki": false,
"homepage": null,
"html_url": "https://github.com/triggerdotdev/trigger.dev-examples",
"keys_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/keys{/key_id}",
"language": "TypeScript",
"tags_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/tags",
"watchers": 1,
"blobs_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/blobs{/sha}",
"clone_url": "https://github.com/triggerdotdev/trigger.dev-examples.git",
"forks_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/forks",
"full_name": "triggerdotdev/trigger.dev-examples",
"has_pages": false,
"hooks_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/hooks",
"pulls_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls{/number}",
"pushed_at": "2023-01-23T19:06:36Z",
"teams_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/teams",
"trees_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/trees{/sha}",
"created_at": "2023-01-13T14:26:45Z",
"events_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/events",
"has_issues": true,
"issues_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues{/number}",
"labels_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/labels{/name}",
"merges_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/merges",
"mirror_url": null,
"updated_at": "2023-01-23T14:22:40Z",
"visibility": "public",
"archive_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/{archive_format}{/ref}",
"commits_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/commits{/sha}",
"compare_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/compare/{base}...{head}",
"description": "Node.js project with multiple example Trigger.dev workflows",
"forks_count": 0,
"is_template": false,
"open_issues": 2,
"branches_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/branches{/branch}",
"comments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/comments{/number}",
"contents_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/contents/{+path}",
"git_refs_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/tags{/sha}",
"has_projects": true,
"releases_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/releases{/id}",
"statuses_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/statuses/{sha}",
"allow_forking": true,
"assignees_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/assignees{/user}",
"downloads_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/downloads",
"has_downloads": false,
"languages_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/languages",
"default_branch": "main",
"milestones_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/milestones{/number}",
"stargazers_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/stargazers",
"watchers_count": 1,
"deployments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/deployments",
"git_commits_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/commits{/sha}",
"has_discussions": false,
"subscribers_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/subscribers",
"contributors_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/contributors",
"issue_events_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/events{/number}",
"stargazers_count": 1,
"subscription_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/subscription",
"collaborators_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/collaborators{/collaborator}",
"issue_comment_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/comments{/number}",
"notifications_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/notifications{?since,all,participating}",
"open_issues_count": 2,
"web_commit_signoff_required": false
},
"organization": {
"id": 95297378,
"url": "https://api.github.com/orgs/triggerdotdev",
"login": "triggerdotdev",
"node_id": "O_kgDOBa4fYg",
"hooks_url": "https://api.github.com/orgs/triggerdotdev/hooks",
"repos_url": "https://api.github.com/orgs/triggerdotdev/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/95297378?v=4",
"events_url": "https://api.github.com/orgs/triggerdotdev/events",
"issues_url": "https://api.github.com/orgs/triggerdotdev/issues",
"description": "",
"members_url": "https://api.github.com/orgs/triggerdotdev/members{/member}",
"public_members_url": "https://api.github.com/orgs/triggerdotdev/public_members{/member}"
}
}
```
@@ -1,428 +0,0 @@
---
title: "Issue Event"
sidebarTitle: "Issues"
description: "Trigger a workflow whenever an issue action is performed in a GitHub repository."
---
## Usage
```ts
import * as github from "@trigger.dev/github";
new Trigger({
id: "demo",
on: github.events.issueEvent({
repo: "triggerdotdev/trigger.dev",
}),
run: async (event, ctx) => {},
}).listen();
```
## Params
<ParamField path="repo" type="string" required={true}>
The full path to the repository, including the organization
</ParamField>
## Event
<ResponseField name="action" type="string">
The issue action, can be one of assigned, closed, deleted, edited, labeled,
unlabeled, locked, opened, pinned, reopened, transferred, unlocked, or
unassigned.
</ResponseField>
<ResponseField name="issue" type="object" required={true}>
The issue object.
</ResponseField>
<ResponseField name="repository" type="object" required={true}>
A repository on GitHub.
</ResponseField>
<ResponseField name="sender" type="object" required={true}>
The GitHub user object who performed the action.
</ResponseField>
<ResponseField name="organization" type="object">
The organization object the repository belongs to.
</ResponseField>
## Additional event fields
### transferred issues
<ResponseField name="changes" type="object">
<Expandable title="properties">
<ResponseField name="new_issue" type="object">
The new issue object.
</ResponseField>
<ResponseField name="new_repository" type="object">
The new issue repository.
</ResponseField>
</Expandable>
</ResponseField>
### edited issues
<ResponseField name="changes" type="object">
<Expandable title="properties">
<ResponseField name="body" type="object">
<Expandable title="properties" defaultOpen={true}>
<ResponseField name="from" type="string">
The previous body text.
</ResponseField>
</Expandable>
</ResponseField>
<ResponseField name="title" type="object">
<Expandable title="properties" defaultOpen={true}>
<ResponseField name="from" type="string">
The previous title text.
</ResponseField>
</Expandable>
</ResponseField>
</Expandable>
</ResponseField>
### labeled/unlabeled issues
<ResponseField name="label" type="object">
The label object.
</ResponseField>
### assigned/unassigned issues
<ResponseField name="assignee" type="object">
The assignee object.
</ResponseField>
### opened issues
<ResponseField name="changes" type="object">
<Expandable title="properties">
<ResponseField name="old_issue" type="object">
The old issue object.
</ResponseField>
<ResponseField name="old_repository" type="object">
The old issue repository.
</ResponseField>
</Expandable>
</ResponseField>
## Example Workflows
<CodeGroup>
```typescript Notify Slack on Critical Issue
new Trigger({
id: "github-to-slack",
name: "Notify of critical issues",
on: github.events.issueEvent({
repo: "triggerdotdev/trigger.dev",
}),
run: async (event, ctx) => {
if (event.action === "labeled") {
if (event.label?.name === "critical") {
await slack.postMessage("send-to-slack", {
channelName: "serious-issues",
text: `Critical issue: ${event.issue.title} was labeled ${event.label.name}`,
});
}
}
return event;
},
}).listen();
```
</CodeGroup>
## Example Event payload
```json
{
"issue": {
"id": 1514714160,
"url": "https://api.github.com/repos/triggerdotdev/trigger.dev/issues/2",
"body": "This is the body text\r\n`const name = \"Matt\"`",
"user": {
"id": 10635986,
"url": "https://api.github.com/users/matt-aitken",
"type": "User",
"login": "matt-aitken",
"node_id": "MDQ6VXNlcjEwNjM1OTg2",
"html_url": "https://github.com/matt-aitken",
"gists_url": "https://api.github.com/users/matt-aitken/gists{/gist_id}",
"repos_url": "https://api.github.com/users/matt-aitken/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/10635986?v=4",
"events_url": "https://api.github.com/users/matt-aitken/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/matt-aitken/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/matt-aitken/followers",
"following_url": "https://api.github.com/users/matt-aitken/following{/other_user}",
"organizations_url": "https://api.github.com/users/matt-aitken/orgs",
"subscriptions_url": "https://api.github.com/users/matt-aitken/subscriptions",
"received_events_url": "https://api.github.com/users/matt-aitken/received_events"
},
"state": "open",
"title": "Test issue for webhook",
"labels": [
{
"id": 4858587614,
"url": "https://api.github.com/repos/triggerdotdev/trigger.dev/labels/documentation",
"name": "documentation",
"color": "0075ca",
"default": true,
"node_id": "LA_kwDOIiC6Ac8AAAABIZgp3g",
"description": "Improvements or additions to documentation"
},
{
"id": 5009913913,
"url": "https://api.github.com/repos/triggerdotdev/trigger.dev/labels/critical",
"name": "critical",
"color": "e99695",
"default": false,
"node_id": "LA_kwDOIiC6Ac8AAAABKp04OQ",
"description": ""
}
],
"locked": false,
"number": 2,
"node_id": "I_kwDOIiC6Ac5aSLQw",
"assignee": {
"id": 10635986,
"url": "https://api.github.com/users/matt-aitken",
"type": "User",
"login": "matt-aitken",
"node_id": "MDQ6VXNlcjEwNjM1OTg2",
"html_url": "https://github.com/matt-aitken",
"gists_url": "https://api.github.com/users/matt-aitken/gists{/gist_id}",
"repos_url": "https://api.github.com/users/matt-aitken/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/10635986?v=4",
"events_url": "https://api.github.com/users/matt-aitken/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/matt-aitken/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/matt-aitken/followers",
"following_url": "https://api.github.com/users/matt-aitken/following{/other_user}",
"organizations_url": "https://api.github.com/users/matt-aitken/orgs",
"subscriptions_url": "https://api.github.com/users/matt-aitken/subscriptions",
"received_events_url": "https://api.github.com/users/matt-aitken/received_events"
},
"comments": 2,
"html_url": "https://github.com/triggerdotdev/trigger.dev/issues/2",
"assignees": [
{
"id": 10635986,
"url": "https://api.github.com/users/matt-aitken",
"type": "User",
"login": "matt-aitken",
"node_id": "MDQ6VXNlcjEwNjM1OTg2",
"html_url": "https://github.com/matt-aitken",
"gists_url": "https://api.github.com/users/matt-aitken/gists{/gist_id}",
"repos_url": "https://api.github.com/users/matt-aitken/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/10635986?v=4",
"events_url": "https://api.github.com/users/matt-aitken/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/matt-aitken/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/matt-aitken/followers",
"following_url": "https://api.github.com/users/matt-aitken/following{/other_user}",
"organizations_url": "https://api.github.com/users/matt-aitken/orgs",
"subscriptions_url": "https://api.github.com/users/matt-aitken/subscriptions",
"received_events_url": "https://api.github.com/users/matt-aitken/received_events"
}
],
"closed_at": null,
"milestone": null,
"reactions": {
"+1": 0,
"-1": 0,
"url": "https://api.github.com/repos/triggerdotdev/trigger.dev/issues/2/reactions",
"eyes": 0,
"heart": 0,
"laugh": 0,
"hooray": 0,
"rocket": 0,
"confused": 0,
"total_count": 0
},
"created_at": "2022-12-30T18:34:01Z",
"events_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/issues/2/events",
"labels_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/issues/2/labels{/name}",
"updated_at": "2023-01-15T20:18:14Z",
"comments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/issues/2/comments",
"state_reason": null,
"timeline_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/issues/2/timeline",
"repository_url": "https://api.github.com/repos/triggerdotdev/trigger.dev",
"active_lock_reason": null,
"author_association": "MEMBER",
"performed_via_github_app": null
},
"label": {
"id": 5009913913,
"url": "https://api.github.com/repos/triggerdotdev/trigger.dev/labels/critical",
"name": "critical",
"color": "e99695",
"default": false,
"node_id": "LA_kwDOIiC6Ac8AAAABKp04OQ",
"description": ""
},
"action": "labeled",
"sender": {
"id": 7555566,
"url": "https://api.github.com/users/samejr",
"type": "User",
"login": "samejr",
"node_id": "MDQ6VXNlcjc1NTU1NjY=",
"html_url": "https://github.com/samejr",
"gists_url": "https://api.github.com/users/samejr/gists{/gist_id}",
"repos_url": "https://api.github.com/users/samejr/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/7555566?v=4",
"events_url": "https://api.github.com/users/samejr/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/samejr/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/samejr/followers",
"following_url": "https://api.github.com/users/samejr/following{/other_user}",
"organizations_url": "https://api.github.com/users/samejr/orgs",
"subscriptions_url": "https://api.github.com/users/samejr/subscriptions",
"received_events_url": "https://api.github.com/users/samejr/received_events"
},
"repository": {
"id": 572570113,
"url": "https://api.github.com/repos/triggerdotdev/trigger.dev",
"fork": false,
"name": "trigger.dev",
"size": 14727,
"forks": 2,
"owner": {
"id": 95297378,
"url": "https://api.github.com/users/triggerdotdev",
"type": "Organization",
"login": "triggerdotdev",
"node_id": "O_kgDOBa4fYg",
"html_url": "https://github.com/triggerdotdev",
"gists_url": "https://api.github.com/users/triggerdotdev/gists{/gist_id}",
"repos_url": "https://api.github.com/users/triggerdotdev/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/95297378?v=4",
"events_url": "https://api.github.com/users/triggerdotdev/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/triggerdotdev/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/triggerdotdev/followers",
"following_url": "https://api.github.com/users/triggerdotdev/following{/other_user}",
"organizations_url": "https://api.github.com/users/triggerdotdev/orgs",
"subscriptions_url": "https://api.github.com/users/triggerdotdev/subscriptions",
"received_events_url": "https://api.github.com/users/triggerdotdev/received_events"
},
"topics": [
"apis",
"automation",
"event-driven",
"events",
"orchestration",
"scheduler",
"workflows"
],
"git_url": "git://github.com/triggerdotdev/trigger.dev.git",
"license": {
"key": "apache-2.0",
"url": "https://api.github.com/licenses/apache-2.0",
"name": "Apache License 2.0",
"node_id": "MDc6TGljZW5zZTI=",
"spdx_id": "Apache-2.0"
},
"node_id": "R_kgDOIiC6AQ",
"private": false,
"ssh_url": "git@github.com:triggerdotdev/trigger.dev.git",
"svn_url": "https://github.com/triggerdotdev/trigger.dev",
"archived": false,
"disabled": false,
"has_wiki": true,
"homepage": "https://trigger.dev",
"html_url": "https://github.com/triggerdotdev/trigger.dev",
"keys_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/keys{/key_id}",
"language": "TypeScript",
"tags_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/tags",
"watchers": 58,
"blobs_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/git/blobs{/sha}",
"clone_url": "https://github.com/triggerdotdev/trigger.dev.git",
"forks_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/forks",
"full_name": "triggerdotdev/trigger.dev",
"has_pages": false,
"hooks_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/hooks",
"pulls_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/pulls{/number}",
"pushed_at": "2023-01-15T19:41:24Z",
"teams_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/teams",
"trees_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/git/trees{/sha}",
"created_at": "2022-11-30T14:59:07Z",
"events_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/events",
"has_issues": true,
"issues_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/issues{/number}",
"labels_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/labels{/name}",
"merges_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/merges",
"mirror_url": null,
"updated_at": "2023-01-15T18:49:01Z",
"visibility": "public",
"archive_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/{archive_format}{/ref}",
"commits_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/commits{/sha}",
"compare_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/compare/{base}...{head}",
"description": "The developer-first, open source Zapier Alternative. Coming soon. Give us a ⭐️ and we'll let you know",
"forks_count": 2,
"is_template": false,
"open_issues": 2,
"branches_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/branches{/branch}",
"comments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/comments{/number}",
"contents_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/contents/{+path}",
"git_refs_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/git/tags{/sha}",
"has_projects": true,
"releases_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/releases{/id}",
"statuses_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/statuses/{sha}",
"allow_forking": true,
"assignees_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/assignees{/user}",
"downloads_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/downloads",
"has_downloads": true,
"languages_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/languages",
"default_branch": "main",
"milestones_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/milestones{/number}",
"stargazers_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/stargazers",
"watchers_count": 58,
"deployments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/deployments",
"git_commits_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/git/commits{/sha}",
"has_discussions": false,
"subscribers_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/subscribers",
"contributors_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/contributors",
"issue_events_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/issues/events{/number}",
"stargazers_count": 58,
"subscription_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/subscription",
"collaborators_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/collaborators{/collaborator}",
"issue_comment_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/issues/comments{/number}",
"notifications_url": "https://api.github.com/repos/triggerdotdev/trigger.dev/notifications{?since,all,participating}",
"open_issues_count": 2,
"web_commit_signoff_required": false
},
"organization": {
"id": 95297378,
"url": "https://api.github.com/orgs/triggerdotdev",
"login": "triggerdotdev",
"node_id": "O_kgDOBa4fYg",
"hooks_url": "https://api.github.com/orgs/triggerdotdev/hooks",
"repos_url": "https://api.github.com/orgs/triggerdotdev/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/95297378?v=4",
"events_url": "https://api.github.com/orgs/triggerdotdev/events",
"issues_url": "https://api.github.com/orgs/triggerdotdev/issues",
"description": "",
"members_url": "https://api.github.com/orgs/triggerdotdev/members{/member}",
"public_members_url": "https://api.github.com/orgs/triggerdotdev/public_members{/member}"
}
}
```
@@ -1,220 +0,0 @@
---
title: "New Star Event"
sidebarTitle: "New Star"
description: "Trigger a workflow whenever a user star's the specified GitHub repository."
---
## Usage
```ts
import * as github from "@trigger.dev/github";
new Trigger({
id: "demo",
on: github.events.newStarEvent({
repo: "triggerdotdev/trigger.dev",
}),
run: async (event, ctx) => {},
}).listen();
```
## Params
<ParamField path="repo" type="string" required={true}>
The full path to the repository, including the organization
</ParamField>
## Event
<ResponseField name="action" type="string" default="created">
The star action, which in this case is always `"created"`.
</ResponseField>
<ResponseField name="starred_at" type="Date" required={true}>
The date and time the starring occurred.
</ResponseField>
<ResponseField name="repository" type="object" required={true}>
A repository on GitHub.
</ResponseField>
<ResponseField name="sender" type="object" required={true}>
The GitHub user object who starred the repository.
</ResponseField>
<ResponseField name="organization" type="object">
The organization object the repository belongs to.
</ResponseField>
## Example Workflows
<CodeGroup>
```typescript Notify Slack on New GitHub Star
import * as slack from "@trigger.dev/slack";
new Trigger({
id: "new-star",
name: "On New Star",
on: github.events.newStarEvent({
repo: "triggerdotdev/trigger.dev",
}),
run: async (event, ctx) => {
await slack.postMessage("⭐️ New Star", {
channelName: "github-stars",
text: `Repo ${event.repository.full_name} got a star from ${event.sender.login}, for a total of ${event.repository.stargazers_count} stars!`,
});
},
}).listen();
```
</CodeGroup>
## Example Event payload
```json Example
{
"action": "created",
"starred_at": "2023-01-21T23:47:38Z",
"repository": {
"id": 516315865,
"node_id": "R_kgDOHsZa2Q",
"name": "apihero-openapi-generator",
"full_name": "triggerdotdev/apihero-openapi-generator",
"private": false,
"owner": {
"login": "triggerdotdev",
"id": 95297378,
"node_id": "O_kgDOBa4fYg",
"avatar_url": "https://avatars.githubusercontent.com/u/95297378?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/triggerdotdev",
"html_url": "https://github.com/triggerdotdev",
"followers_url": "https://api.github.com/users/triggerdotdev/followers",
"following_url": "https://api.github.com/users/triggerdotdev/following{/other_user}",
"gists_url": "https://api.github.com/users/triggerdotdev/gists{/gist_id}",
"starred_url": "https://api.github.com/users/triggerdotdev/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/triggerdotdev/subscriptions",
"organizations_url": "https://api.github.com/users/triggerdotdev/orgs",
"repos_url": "https://api.github.com/users/triggerdotdev/repos",
"events_url": "https://api.github.com/users/triggerdotdev/events{/privacy}",
"received_events_url": "https://api.github.com/users/triggerdotdev/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/triggerdotdev/apihero-openapi-generator",
"description": null,
"fork": false,
"url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator",
"forks_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/forks",
"keys_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/teams",
"hooks_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/hooks",
"issue_events_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/issues/events{/number}",
"events_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/events",
"assignees_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/assignees{/user}",
"branches_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/branches{/branch}",
"tags_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/tags",
"blobs_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/statuses/{sha}",
"languages_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/languages",
"stargazers_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/stargazers",
"contributors_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/contributors",
"subscribers_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/subscribers",
"subscription_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/subscription",
"commits_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/contents/{+path}",
"compare_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/merges",
"archive_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/downloads",
"issues_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/issues{/number}",
"pulls_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/pulls{/number}",
"milestones_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/milestones{/number}",
"notifications_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/labels{/name}",
"releases_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/releases{/id}",
"deployments_url": "https://api.github.com/repos/triggerdotdev/apihero-openapi-generator/deployments",
"created_at": "2022-07-21T09:57:53Z",
"updated_at": "2023-01-21T23:47:38Z",
"pushed_at": "2022-10-20T13:21:09Z",
"git_url": "git://github.com/triggerdotdev/apihero-openapi-generator.git",
"ssh_url": "git@github.com:triggerdotdev/apihero-openapi-generator.git",
"clone_url": "https://github.com/triggerdotdev/apihero-openapi-generator.git",
"svn_url": "https://github.com/triggerdotdev/apihero-openapi-generator",
"homepage": null,
"size": 4962,
"stargazers_count": 1,
"watchers_count": 1,
"language": "TypeScript",
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": false,
"has_discussions": false,
"forks_count": 0,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 0,
"license": {
"key": "mit",
"name": "MIT License",
"spdx_id": "MIT",
"url": "https://api.github.com/licenses/mit",
"node_id": "MDc6TGljZW5zZTEz"
},
"allow_forking": true,
"is_template": false,
"web_commit_signoff_required": false,
"topics": [],
"visibility": "public",
"forks": 0,
"open_issues": 0,
"watchers": 1,
"default_branch": "main"
},
"organization": {
"login": "triggerdotdev",
"id": 95297378,
"node_id": "O_kgDOBa4fYg",
"url": "https://api.github.com/orgs/triggerdotdev",
"repos_url": "https://api.github.com/orgs/triggerdotdev/repos",
"events_url": "https://api.github.com/orgs/triggerdotdev/events",
"hooks_url": "https://api.github.com/orgs/triggerdotdev/hooks",
"issues_url": "https://api.github.com/orgs/triggerdotdev/issues",
"members_url": "https://api.github.com/orgs/triggerdotdev/members{/member}",
"public_members_url": "https://api.github.com/orgs/triggerdotdev/public_members{/member}",
"avatar_url": "https://avatars.githubusercontent.com/u/95297378?v=4",
"description": ""
},
"sender": {
"login": "ericallam",
"id": 534,
"node_id": "MDQ6VXNlcjUzNA==",
"avatar_url": "https://avatars.githubusercontent.com/u/534?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/ericallam",
"html_url": "https://github.com/ericallam",
"followers_url": "https://api.github.com/users/ericallam/followers",
"following_url": "https://api.github.com/users/ericallam/following{/other_user}",
"gists_url": "https://api.github.com/users/ericallam/gists{/gist_id}",
"starred_url": "https://api.github.com/users/ericallam/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/ericallam/subscriptions",
"organizations_url": "https://api.github.com/users/ericallam/orgs",
"repos_url": "https://api.github.com/users/ericallam/repos",
"events_url": "https://api.github.com/users/ericallam/events{/privacy}",
"received_events_url": "https://api.github.com/users/ericallam/received_events",
"type": "User",
"site_admin": false
}
}
```
@@ -1,97 +0,0 @@
---
title: "PR Review Comment Event"
sidebarTitle: "PR Review Comments"
description: "Trigger a workflow whenever an pull_request_review_comment action is performed in a GitHub repository."
---
<Note>
If you would like to trigger a workflow when a comment is made on a PR, use
the [issueCommentEvent](/integrations/apis/github/events/issue-comments)
instead
</Note>
## Usage
```ts
import * as github from "@trigger.dev/github";
new Trigger({
id: "demo",
on: github.events.pullRequestCommentEvent({
repo: "triggerdotdev/trigger.dev",
}),
run: async (event, ctx) => {},
}).listen();
```
## Params
<ParamField path="repo" type="string" required={true}>
The full path to the repository, including the organization
</ParamField>
## Event
<ResponseField name="action" type="string">
The pull_request action, can be one of: `created`, `edited`, `deleted`.
</ResponseField>
<ResponseField name="comment" type="object" required={true}>
The pull request review comment object.
</ResponseField>
<ResponseField name="pull_request" type="object" required={true}>
The pull request object.
</ResponseField>
<ResponseField name="repository" type="object" required={true}>
A repository on GitHub.
</ResponseField>
<ResponseField name="sender" type="object" required={true}>
The GitHub user object who performed the action.
</ResponseField>
<ResponseField name="organization" type="object">
The organization object the repository belongs to.
</ResponseField>
## Additional event fields
### edited PR Review Comment
<ResponseField name="changes" type="object">
<Expandable title="properties">
<ResponseField name="body" type="object">
<Expandable title="properties" defaultOpen={true}>
<ResponseField name="from" type="string">
The previous body text.
</ResponseField>
</Expandable>
</ResponseField>
</Expandable>
</ResponseField>
## Example Workflows
<CodeGroup>
```typescript Notify Slack on new PR
new Trigger({
id: "new-pr",
name: "Notify Slack on new PR Review Comment",
on: github.events.pullRequestCommentEvent({
repo: "triggerdotdev/trigger.dev",
}),
run: async (event, ctx) => {
if (event.action === "created") {
await slack.postMessage("New PR comment", {
channelName: "github-prs",
text: `New PR comment by ${event.sender.login} on PR ${event.pull_request.title} (${event.pull_request.html_url})`,
});
}
},
}).listen();
```
</CodeGroup>
@@ -1,625 +0,0 @@
---
title: "PR Review Event"
sidebarTitle: "PR Reviews"
description: "Trigger a workflow whenever an pull_request_review action is performed in a GitHub repository."
---
## Usage
```ts
import * as github from "@trigger.dev/github";
new Trigger({
id: "demo",
on: github.events.pullRequestReviewEvent({
repo: "triggerdotdev/trigger.dev",
}),
run: async (event, ctx) => {},
}).listen();
```
## Params
<ParamField path="repo" type="string" required={true}>
The full path to the repository, including the organization
</ParamField>
## Event
<ResponseField name="action" type="string">
The pull_request_review action, can be one of: `submitted`, `edited`,
`dismissed`.
</ResponseField>
<ResponseField name="review" type="object" required={true}>
The pull request review object.
</ResponseField>
<ResponseField name="pull_request" type="object" required={true}>
The pull request object.
</ResponseField>
<ResponseField name="repository" type="object" required={true}>
A repository on GitHub.
</ResponseField>
<ResponseField name="sender" type="object" required={true}>
The GitHub user object who performed the action.
</ResponseField>
<ResponseField name="organization" type="object">
The organization object the repository belongs to.
</ResponseField>
## Additional event fields
### edited PR Review
<ResponseField name="changes" type="object">
<Expandable title="properties">
<ResponseField name="body" type="object">
<Expandable title="properties" defaultOpen={true}>
<ResponseField name="from" type="string">
The previous body text.
</ResponseField>
</Expandable>
</ResponseField>
</Expandable>
</ResponseField>
## Example Workflows
<CodeGroup>
```typescript Notify Slack on new PR Review
new Trigger({
id: "new-pr",
name: "Notify Slack on new PR Review",
on: github.events.pullRequestReviewEvent({
repo: "triggerdotdev/trigger.dev",
}),
run: async (event, ctx) => {
if (event.action === "submitted") {
await slack.postMessage("New PR Review", {
channelName: "github-prs",
text: `New PR Review by ${event.sender.login} on PR ${event.pull_request.title} (${event.pull_request.html_url})`,
});
}
},
}).listen();
```
</CodeGroup>
## Example Event payload
```json
{
"action": "submitted",
"review": {
"id": 1266763458,
"body": "This is a PR review comment?",
"user": {
"id": 534,
"url": "https://api.github.com/users/ericallam",
"type": "User",
"login": "ericallam",
"node_id": "MDQ6VXNlcjUzNA==",
"html_url": "https://github.com/ericallam",
"gists_url": "https://api.github.com/users/ericallam/gists{/gist_id}",
"repos_url": "https://api.github.com/users/ericallam/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/534?v=4",
"events_url": "https://api.github.com/users/ericallam/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/ericallam/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/ericallam/followers",
"following_url": "https://api.github.com/users/ericallam/following{/other_user}",
"organizations_url": "https://api.github.com/users/ericallam/orgs",
"subscriptions_url": "https://api.github.com/users/ericallam/subscriptions",
"received_events_url": "https://api.github.com/users/ericallam/received_events"
},
"state": "commented",
"_links": {
"html": {
"href": "https://github.com/triggerdotdev/trigger.dev-examples/pull/4#pullrequestreview-1266763458"
},
"pull_request": {
"href": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls/4"
}
},
"node_id": "PRR_kwDOIxVdCc5LgUbC",
"html_url": "https://github.com/triggerdotdev/trigger.dev-examples/pull/4#pullrequestreview-1266763458",
"commit_id": "efc58e149c06f4a45ebf7a0bf34ac25cdcd34b07",
"submitted_at": "2023-01-24T04:24:58Z",
"pull_request_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls/4",
"author_association": "MEMBER"
},
"sender": {
"id": 534,
"url": "https://api.github.com/users/ericallam",
"type": "User",
"login": "ericallam",
"node_id": "MDQ6VXNlcjUzNA==",
"html_url": "https://github.com/ericallam",
"gists_url": "https://api.github.com/users/ericallam/gists{/gist_id}",
"repos_url": "https://api.github.com/users/ericallam/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/534?v=4",
"events_url": "https://api.github.com/users/ericallam/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/ericallam/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/ericallam/followers",
"following_url": "https://api.github.com/users/ericallam/following{/other_user}",
"organizations_url": "https://api.github.com/users/ericallam/orgs",
"subscriptions_url": "https://api.github.com/users/ericallam/subscriptions",
"received_events_url": "https://api.github.com/users/ericallam/received_events"
},
"repository": {
"id": 588602633,
"url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples",
"fork": false,
"name": "trigger.dev-examples",
"size": 161,
"forks": 0,
"owner": {
"id": 95297378,
"url": "https://api.github.com/users/triggerdotdev",
"type": "Organization",
"login": "triggerdotdev",
"node_id": "O_kgDOBa4fYg",
"html_url": "https://github.com/triggerdotdev",
"gists_url": "https://api.github.com/users/triggerdotdev/gists{/gist_id}",
"repos_url": "https://api.github.com/users/triggerdotdev/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/95297378?v=4",
"events_url": "https://api.github.com/users/triggerdotdev/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/triggerdotdev/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/triggerdotdev/followers",
"following_url": "https://api.github.com/users/triggerdotdev/following{/other_user}",
"organizations_url": "https://api.github.com/users/triggerdotdev/orgs",
"subscriptions_url": "https://api.github.com/users/triggerdotdev/subscriptions",
"received_events_url": "https://api.github.com/users/triggerdotdev/received_events"
},
"topics": [],
"git_url": "git://github.com/triggerdotdev/trigger.dev-examples.git",
"license": null,
"node_id": "R_kgDOIxVdCQ",
"private": false,
"ssh_url": "git@github.com:triggerdotdev/trigger.dev-examples.git",
"svn_url": "https://github.com/triggerdotdev/trigger.dev-examples",
"archived": false,
"disabled": false,
"has_wiki": false,
"homepage": null,
"html_url": "https://github.com/triggerdotdev/trigger.dev-examples",
"keys_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/keys{/key_id}",
"language": "TypeScript",
"tags_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/tags",
"watchers": 1,
"blobs_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/blobs{/sha}",
"clone_url": "https://github.com/triggerdotdev/trigger.dev-examples.git",
"forks_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/forks",
"full_name": "triggerdotdev/trigger.dev-examples",
"has_pages": false,
"hooks_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/hooks",
"pulls_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls{/number}",
"pushed_at": "2023-01-24T04:20:52Z",
"teams_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/teams",
"trees_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/trees{/sha}",
"created_at": "2023-01-13T14:26:45Z",
"events_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/events",
"has_issues": true,
"issues_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues{/number}",
"labels_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/labels{/name}",
"merges_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/merges",
"mirror_url": null,
"updated_at": "2023-01-23T14:22:40Z",
"visibility": "public",
"archive_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/{archive_format}{/ref}",
"commits_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/commits{/sha}",
"compare_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/compare/{base}...{head}",
"description": "Node.js project with multiple example Trigger.dev workflows",
"forks_count": 0,
"is_template": false,
"open_issues": 3,
"branches_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/branches{/branch}",
"comments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/comments{/number}",
"contents_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/contents/{+path}",
"git_refs_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/tags{/sha}",
"has_projects": true,
"releases_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/releases{/id}",
"statuses_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/statuses/{sha}",
"allow_forking": true,
"assignees_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/assignees{/user}",
"downloads_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/downloads",
"has_downloads": false,
"languages_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/languages",
"default_branch": "main",
"milestones_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/milestones{/number}",
"stargazers_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/stargazers",
"watchers_count": 1,
"deployments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/deployments",
"git_commits_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/commits{/sha}",
"has_discussions": false,
"subscribers_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/subscribers",
"contributors_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/contributors",
"issue_events_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/events{/number}",
"stargazers_count": 1,
"subscription_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/subscription",
"collaborators_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/collaborators{/collaborator}",
"issue_comment_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/comments{/number}",
"notifications_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/notifications{?since,all,participating}",
"open_issues_count": 3,
"web_commit_signoff_required": false
},
"organization": {
"id": 95297378,
"url": "https://api.github.com/orgs/triggerdotdev",
"login": "triggerdotdev",
"node_id": "O_kgDOBa4fYg",
"hooks_url": "https://api.github.com/orgs/triggerdotdev/hooks",
"repos_url": "https://api.github.com/orgs/triggerdotdev/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/95297378?v=4",
"events_url": "https://api.github.com/orgs/triggerdotdev/events",
"issues_url": "https://api.github.com/orgs/triggerdotdev/issues",
"description": "",
"members_url": "https://api.github.com/orgs/triggerdotdev/members{/member}",
"public_members_url": "https://api.github.com/orgs/triggerdotdev/public_members{/member}"
},
"pull_request": {
"id": 1214500311,
"url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls/4",
"base": {
"ref": "main",
"sha": "e7c0680e23fcd3e52d35ddfbb4076112c640d9fa",
"repo": {
"id": 588602633,
"url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples",
"fork": false,
"name": "trigger.dev-examples",
"size": 161,
"forks": 0,
"owner": {
"id": 95297378,
"url": "https://api.github.com/users/triggerdotdev",
"type": "Organization",
"login": "triggerdotdev",
"node_id": "O_kgDOBa4fYg",
"html_url": "https://github.com/triggerdotdev",
"gists_url": "https://api.github.com/users/triggerdotdev/gists{/gist_id}",
"repos_url": "https://api.github.com/users/triggerdotdev/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/95297378?v=4",
"events_url": "https://api.github.com/users/triggerdotdev/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/triggerdotdev/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/triggerdotdev/followers",
"following_url": "https://api.github.com/users/triggerdotdev/following{/other_user}",
"organizations_url": "https://api.github.com/users/triggerdotdev/orgs",
"subscriptions_url": "https://api.github.com/users/triggerdotdev/subscriptions",
"received_events_url": "https://api.github.com/users/triggerdotdev/received_events"
},
"topics": [],
"git_url": "git://github.com/triggerdotdev/trigger.dev-examples.git",
"license": null,
"node_id": "R_kgDOIxVdCQ",
"private": false,
"ssh_url": "git@github.com:triggerdotdev/trigger.dev-examples.git",
"svn_url": "https://github.com/triggerdotdev/trigger.dev-examples",
"archived": false,
"disabled": false,
"has_wiki": false,
"homepage": null,
"html_url": "https://github.com/triggerdotdev/trigger.dev-examples",
"keys_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/keys{/key_id}",
"language": "TypeScript",
"tags_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/tags",
"watchers": 1,
"blobs_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/blobs{/sha}",
"clone_url": "https://github.com/triggerdotdev/trigger.dev-examples.git",
"forks_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/forks",
"full_name": "triggerdotdev/trigger.dev-examples",
"has_pages": false,
"hooks_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/hooks",
"pulls_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls{/number}",
"pushed_at": "2023-01-24T04:20:52Z",
"teams_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/teams",
"trees_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/trees{/sha}",
"created_at": "2023-01-13T14:26:45Z",
"events_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/events",
"has_issues": true,
"issues_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues{/number}",
"labels_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/labels{/name}",
"merges_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/merges",
"mirror_url": null,
"updated_at": "2023-01-23T14:22:40Z",
"visibility": "public",
"archive_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/{archive_format}{/ref}",
"commits_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/commits{/sha}",
"compare_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/compare/{base}...{head}",
"description": "Node.js project with multiple example Trigger.dev workflows",
"forks_count": 0,
"is_template": false,
"open_issues": 3,
"branches_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/branches{/branch}",
"comments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/comments{/number}",
"contents_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/contents/{+path}",
"git_refs_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/tags{/sha}",
"has_projects": true,
"releases_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/releases{/id}",
"statuses_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/statuses/{sha}",
"allow_forking": true,
"assignees_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/assignees{/user}",
"downloads_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/downloads",
"has_downloads": false,
"languages_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/languages",
"default_branch": "main",
"milestones_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/milestones{/number}",
"stargazers_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/stargazers",
"watchers_count": 1,
"deployments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/deployments",
"git_commits_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/commits{/sha}",
"has_discussions": false,
"subscribers_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/subscribers",
"allow_auto_merge": false,
"contributors_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/contributors",
"issue_events_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/events{/number}",
"stargazers_count": 1,
"subscription_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/subscription",
"collaborators_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/collaborators{/collaborator}",
"issue_comment_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/comments{/number}",
"notifications_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/notifications{?since,all,participating}",
"open_issues_count": 3,
"allow_merge_commit": true,
"allow_rebase_merge": true,
"allow_squash_merge": true,
"merge_commit_title": "MERGE_MESSAGE",
"allow_update_branch": false,
"merge_commit_message": "PR_TITLE",
"delete_branch_on_merge": false,
"squash_merge_commit_title": "COMMIT_OR_PR_TITLE",
"squash_merge_commit_message": "COMMIT_MESSAGES",
"web_commit_signoff_required": false,
"use_squash_pr_title_as_default": false
},
"user": {
"id": 95297378,
"url": "https://api.github.com/users/triggerdotdev",
"type": "Organization",
"login": "triggerdotdev",
"node_id": "O_kgDOBa4fYg",
"html_url": "https://github.com/triggerdotdev",
"gists_url": "https://api.github.com/users/triggerdotdev/gists{/gist_id}",
"repos_url": "https://api.github.com/users/triggerdotdev/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/95297378?v=4",
"events_url": "https://api.github.com/users/triggerdotdev/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/triggerdotdev/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/triggerdotdev/followers",
"following_url": "https://api.github.com/users/triggerdotdev/following{/other_user}",
"organizations_url": "https://api.github.com/users/triggerdotdev/orgs",
"subscriptions_url": "https://api.github.com/users/triggerdotdev/subscriptions",
"received_events_url": "https://api.github.com/users/triggerdotdev/received_events"
},
"label": "triggerdotdev:main"
},
"body": null,
"head": {
"ref": "resend",
"sha": "efc58e149c06f4a45ebf7a0bf34ac25cdcd34b07",
"repo": {
"id": 588602633,
"url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples",
"fork": false,
"name": "trigger.dev-examples",
"size": 161,
"forks": 0,
"owner": {
"id": 95297378,
"url": "https://api.github.com/users/triggerdotdev",
"type": "Organization",
"login": "triggerdotdev",
"node_id": "O_kgDOBa4fYg",
"html_url": "https://github.com/triggerdotdev",
"gists_url": "https://api.github.com/users/triggerdotdev/gists{/gist_id}",
"repos_url": "https://api.github.com/users/triggerdotdev/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/95297378?v=4",
"events_url": "https://api.github.com/users/triggerdotdev/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/triggerdotdev/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/triggerdotdev/followers",
"following_url": "https://api.github.com/users/triggerdotdev/following{/other_user}",
"organizations_url": "https://api.github.com/users/triggerdotdev/orgs",
"subscriptions_url": "https://api.github.com/users/triggerdotdev/subscriptions",
"received_events_url": "https://api.github.com/users/triggerdotdev/received_events"
},
"topics": [],
"git_url": "git://github.com/triggerdotdev/trigger.dev-examples.git",
"license": null,
"node_id": "R_kgDOIxVdCQ",
"private": false,
"ssh_url": "git@github.com:triggerdotdev/trigger.dev-examples.git",
"svn_url": "https://github.com/triggerdotdev/trigger.dev-examples",
"archived": false,
"disabled": false,
"has_wiki": false,
"homepage": null,
"html_url": "https://github.com/triggerdotdev/trigger.dev-examples",
"keys_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/keys{/key_id}",
"language": "TypeScript",
"tags_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/tags",
"watchers": 1,
"blobs_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/blobs{/sha}",
"clone_url": "https://github.com/triggerdotdev/trigger.dev-examples.git",
"forks_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/forks",
"full_name": "triggerdotdev/trigger.dev-examples",
"has_pages": false,
"hooks_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/hooks",
"pulls_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls{/number}",
"pushed_at": "2023-01-24T04:20:52Z",
"teams_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/teams",
"trees_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/trees{/sha}",
"created_at": "2023-01-13T14:26:45Z",
"events_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/events",
"has_issues": true,
"issues_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues{/number}",
"labels_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/labels{/name}",
"merges_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/merges",
"mirror_url": null,
"updated_at": "2023-01-23T14:22:40Z",
"visibility": "public",
"archive_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/{archive_format}{/ref}",
"commits_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/commits{/sha}",
"compare_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/compare/{base}...{head}",
"description": "Node.js project with multiple example Trigger.dev workflows",
"forks_count": 0,
"is_template": false,
"open_issues": 3,
"branches_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/branches{/branch}",
"comments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/comments{/number}",
"contents_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/contents/{+path}",
"git_refs_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/tags{/sha}",
"has_projects": true,
"releases_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/releases{/id}",
"statuses_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/statuses/{sha}",
"allow_forking": true,
"assignees_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/assignees{/user}",
"downloads_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/downloads",
"has_downloads": false,
"languages_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/languages",
"default_branch": "main",
"milestones_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/milestones{/number}",
"stargazers_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/stargazers",
"watchers_count": 1,
"deployments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/deployments",
"git_commits_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/commits{/sha}",
"has_discussions": false,
"subscribers_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/subscribers",
"allow_auto_merge": false,
"contributors_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/contributors",
"issue_events_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/events{/number}",
"stargazers_count": 1,
"subscription_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/subscription",
"collaborators_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/collaborators{/collaborator}",
"issue_comment_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/comments{/number}",
"notifications_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/notifications{?since,all,participating}",
"open_issues_count": 3,
"allow_merge_commit": true,
"allow_rebase_merge": true,
"allow_squash_merge": true,
"merge_commit_title": "MERGE_MESSAGE",
"allow_update_branch": false,
"merge_commit_message": "PR_TITLE",
"delete_branch_on_merge": false,
"squash_merge_commit_title": "COMMIT_OR_PR_TITLE",
"squash_merge_commit_message": "COMMIT_MESSAGES",
"web_commit_signoff_required": false,
"use_squash_pr_title_as_default": false
},
"user": {
"id": 95297378,
"url": "https://api.github.com/users/triggerdotdev",
"type": "Organization",
"login": "triggerdotdev",
"node_id": "O_kgDOBa4fYg",
"html_url": "https://github.com/triggerdotdev",
"gists_url": "https://api.github.com/users/triggerdotdev/gists{/gist_id}",
"repos_url": "https://api.github.com/users/triggerdotdev/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/95297378?v=4",
"events_url": "https://api.github.com/users/triggerdotdev/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/triggerdotdev/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/triggerdotdev/followers",
"following_url": "https://api.github.com/users/triggerdotdev/following{/other_user}",
"organizations_url": "https://api.github.com/users/triggerdotdev/orgs",
"subscriptions_url": "https://api.github.com/users/triggerdotdev/subscriptions",
"received_events_url": "https://api.github.com/users/triggerdotdev/received_events"
},
"label": "triggerdotdev:resend"
},
"user": {
"id": 534,
"url": "https://api.github.com/users/ericallam",
"type": "User",
"login": "ericallam",
"node_id": "MDQ6VXNlcjUzNA==",
"html_url": "https://github.com/ericallam",
"gists_url": "https://api.github.com/users/ericallam/gists{/gist_id}",
"repos_url": "https://api.github.com/users/ericallam/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/534?v=4",
"events_url": "https://api.github.com/users/ericallam/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/ericallam/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/ericallam/followers",
"following_url": "https://api.github.com/users/ericallam/following{/other_user}",
"organizations_url": "https://api.github.com/users/ericallam/orgs",
"subscriptions_url": "https://api.github.com/users/ericallam/subscriptions",
"received_events_url": "https://api.github.com/users/ericallam/received_events"
},
"draft": false,
"state": "open",
"title": "Example PR",
"_links": {
"html": {
"href": "https://github.com/triggerdotdev/trigger.dev-examples/pull/4"
},
"self": {
"href": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls/4"
},
"issue": {
"href": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/4"
},
"commits": {
"href": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls/4/commits"
},
"comments": {
"href": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/4/comments"
},
"statuses": {
"href": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/statuses/efc58e149c06f4a45ebf7a0bf34ac25cdcd34b07"
},
"review_comment": {
"href": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls/comments{/number}"
},
"review_comments": {
"href": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls/4/comments"
}
},
"labels": [],
"locked": false,
"number": 4,
"node_id": "PR_kwDOIxVdCc5IY83X",
"assignee": null,
"diff_url": "https://github.com/triggerdotdev/trigger.dev-examples/pull/4.diff",
"html_url": "https://github.com/triggerdotdev/trigger.dev-examples/pull/4",
"assignees": [],
"closed_at": null,
"issue_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/4",
"merged_at": null,
"milestone": null,
"patch_url": "https://github.com/triggerdotdev/trigger.dev-examples/pull/4.patch",
"auto_merge": null,
"created_at": "2023-01-24T04:20:51Z",
"updated_at": "2023-01-24T04:24:58Z",
"commits_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls/4/commits",
"comments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/4/comments",
"statuses_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/statuses/efc58e149c06f4a45ebf7a0bf34ac25cdcd34b07",
"requested_teams": [],
"merge_commit_sha": null,
"active_lock_reason": null,
"author_association": "MEMBER",
"review_comment_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls/comments{/number}",
"requested_reviewers": [],
"review_comments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls/4/comments"
}
}
```
@@ -1,644 +0,0 @@
---
title: "Pull Request Event"
sidebarTitle: "Pull Requests"
description: "Trigger a workflow whenever an pull_request action is performed in a GitHub repository."
---
## Usage
```ts
import * as github from "@trigger.dev/github";
new Trigger({
id: "demo",
on: github.events.pullRequestEvent({
repo: "triggerdotdev/trigger.dev",
}),
run: async (event, ctx) => {},
}).listen();
```
## Params
<ParamField path="repo" type="string" required={true}>
The full path to the repository, including the organization
</ParamField>
## Event
<ResponseField name="action" type="string">
The pull_request action, which can one of assigned, unassigned,
auto_merge_enabled, auto_merge_disabled, review_requested,
review_request_removed, ready_for_review, labeled, unlabeled, opened, edited,
closed, reopened, synchronize, ready_for_review, locked, unlocked, or
converted_to_draft.
</ResponseField>
<ResponseField name="number" type="number" required={true}>
The pull request number.
</ResponseField>
<ResponseField name="pull_request" type="object" required={true}>
The pull request object.
</ResponseField>
<ResponseField name="repository" type="object" required={true}>
A repository on GitHub.
</ResponseField>
<ResponseField name="sender" type="object" required={true}>
The GitHub user object who performed the action.
</ResponseField>
<ResponseField name="organization" type="object">
The organization object the repository belongs to.
</ResponseField>
## Additional event fields
### review_requested/review_request_removed PRs
<ResponseField name="requested_reviewer" type="object">
The GitHub user object who was requested to review the PR.
</ResponseField>
<ResponseField name="requested_team" type="object">
The GitHub team object who was requested to review the PR.
</ResponseField>
### labeled/unlabeled PRs
<ResponseField name="label" type="object">
The label object.
</ResponseField>
### assigned/unassigned PRs
<ResponseField name="assignee" type="object">
The assignee object.
</ResponseField>
### edited PRs
<ResponseField name="changes" type="object">
<Expandable title="properties">
<ResponseField name="body" type="object">
<Expandable title="properties" defaultOpen={true}>
<ResponseField name="from" type="string">
The previous body text.
</ResponseField>
</Expandable>
</ResponseField>
<ResponseField name="title" type="object">
<Expandable title="properties" defaultOpen={true}>
<ResponseField name="from" type="string">
The previous title text.
</ResponseField>
</Expandable>
</ResponseField>
<ResponseField name="base" type="object">
<Expandable title="properties" defaultOpen={true}>
<ResponseField name="ref" type="object">
Use `ref.from` to get the previous base branch name.
</ResponseField>
<ResponseField name="sha" type="object">
Use `sha.from` to get the previous base branch SHA.
</ResponseField>
</Expandable>
</ResponseField>
</Expandable>
</ResponseField>
## Example Workflows
<CodeGroup>
```typescript Notify Slack on new PR
new Trigger({
id: "new-pr",
name: "Notify Slack on new PR",
on: github.events.pullRequestEvent({
repo: "triggerdotdev/trigger.dev",
}),
run: async (event, ctx) => {
if (event.action === "opened") {
await slack.postMessage("New PR", {
channelName: "github-prs",
text: `New PR: ${event.pull_request.html_url}`,
});
}
},
}).listen();
```
</CodeGroup>
## Example Event payload
```json
{
"action": "opened",
"number": 4,
"sender": {
"id": 534,
"url": "https://api.github.com/users/ericallam",
"type": "User",
"login": "ericallam",
"node_id": "MDQ6VXNlcjUzNA==",
"html_url": "https://github.com/ericallam",
"gists_url": "https://api.github.com/users/ericallam/gists{/gist_id}",
"repos_url": "https://api.github.com/users/ericallam/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/534?v=4",
"events_url": "https://api.github.com/users/ericallam/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/ericallam/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/ericallam/followers",
"following_url": "https://api.github.com/users/ericallam/following{/other_user}",
"organizations_url": "https://api.github.com/users/ericallam/orgs",
"subscriptions_url": "https://api.github.com/users/ericallam/subscriptions",
"received_events_url": "https://api.github.com/users/ericallam/received_events"
},
"repository": {
"id": 588602633,
"url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples",
"fork": false,
"name": "trigger.dev-examples",
"size": 161,
"forks": 0,
"owner": {
"id": 95297378,
"url": "https://api.github.com/users/triggerdotdev",
"type": "Organization",
"login": "triggerdotdev",
"node_id": "O_kgDOBa4fYg",
"html_url": "https://github.com/triggerdotdev",
"gists_url": "https://api.github.com/users/triggerdotdev/gists{/gist_id}",
"repos_url": "https://api.github.com/users/triggerdotdev/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/95297378?v=4",
"events_url": "https://api.github.com/users/triggerdotdev/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/triggerdotdev/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/triggerdotdev/followers",
"following_url": "https://api.github.com/users/triggerdotdev/following{/other_user}",
"organizations_url": "https://api.github.com/users/triggerdotdev/orgs",
"subscriptions_url": "https://api.github.com/users/triggerdotdev/subscriptions",
"received_events_url": "https://api.github.com/users/triggerdotdev/received_events"
},
"topics": [],
"git_url": "git://github.com/triggerdotdev/trigger.dev-examples.git",
"license": null,
"node_id": "R_kgDOIxVdCQ",
"private": false,
"ssh_url": "git@github.com:triggerdotdev/trigger.dev-examples.git",
"svn_url": "https://github.com/triggerdotdev/trigger.dev-examples",
"archived": false,
"disabled": false,
"has_wiki": false,
"homepage": null,
"html_url": "https://github.com/triggerdotdev/trigger.dev-examples",
"keys_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/keys{/key_id}",
"language": "TypeScript",
"tags_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/tags",
"watchers": 1,
"blobs_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/blobs{/sha}",
"clone_url": "https://github.com/triggerdotdev/trigger.dev-examples.git",
"forks_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/forks",
"full_name": "triggerdotdev/trigger.dev-examples",
"has_pages": false,
"hooks_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/hooks",
"pulls_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls{/number}",
"pushed_at": "2023-01-24T04:20:52Z",
"teams_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/teams",
"trees_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/trees{/sha}",
"created_at": "2023-01-13T14:26:45Z",
"events_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/events",
"has_issues": true,
"issues_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues{/number}",
"labels_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/labels{/name}",
"merges_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/merges",
"mirror_url": null,
"updated_at": "2023-01-23T14:22:40Z",
"visibility": "public",
"archive_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/{archive_format}{/ref}",
"commits_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/commits{/sha}",
"compare_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/compare/{base}...{head}",
"description": "Node.js project with multiple example Trigger.dev workflows",
"forks_count": 0,
"is_template": false,
"open_issues": 3,
"branches_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/branches{/branch}",
"comments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/comments{/number}",
"contents_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/contents/{+path}",
"git_refs_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/tags{/sha}",
"has_projects": true,
"releases_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/releases{/id}",
"statuses_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/statuses/{sha}",
"allow_forking": true,
"assignees_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/assignees{/user}",
"downloads_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/downloads",
"has_downloads": false,
"languages_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/languages",
"default_branch": "main",
"milestones_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/milestones{/number}",
"stargazers_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/stargazers",
"watchers_count": 1,
"deployments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/deployments",
"git_commits_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/commits{/sha}",
"has_discussions": false,
"subscribers_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/subscribers",
"contributors_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/contributors",
"issue_events_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/events{/number}",
"stargazers_count": 1,
"subscription_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/subscription",
"collaborators_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/collaborators{/collaborator}",
"issue_comment_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/comments{/number}",
"notifications_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/notifications{?since,all,participating}",
"open_issues_count": 3,
"web_commit_signoff_required": false
},
"organization": {
"id": 95297378,
"url": "https://api.github.com/orgs/triggerdotdev",
"login": "triggerdotdev",
"node_id": "O_kgDOBa4fYg",
"hooks_url": "https://api.github.com/orgs/triggerdotdev/hooks",
"repos_url": "https://api.github.com/orgs/triggerdotdev/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/95297378?v=4",
"events_url": "https://api.github.com/orgs/triggerdotdev/events",
"issues_url": "https://api.github.com/orgs/triggerdotdev/issues",
"description": "",
"members_url": "https://api.github.com/orgs/triggerdotdev/members{/member}",
"public_members_url": "https://api.github.com/orgs/triggerdotdev/public_members{/member}"
},
"pull_request": {
"id": 1214500311,
"url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls/4",
"base": {
"ref": "main",
"sha": "e7c0680e23fcd3e52d35ddfbb4076112c640d9fa",
"repo": {
"id": 588602633,
"url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples",
"fork": false,
"name": "trigger.dev-examples",
"size": 161,
"forks": 0,
"owner": {
"id": 95297378,
"url": "https://api.github.com/users/triggerdotdev",
"type": "Organization",
"login": "triggerdotdev",
"node_id": "O_kgDOBa4fYg",
"html_url": "https://github.com/triggerdotdev",
"gists_url": "https://api.github.com/users/triggerdotdev/gists{/gist_id}",
"repos_url": "https://api.github.com/users/triggerdotdev/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/95297378?v=4",
"events_url": "https://api.github.com/users/triggerdotdev/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/triggerdotdev/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/triggerdotdev/followers",
"following_url": "https://api.github.com/users/triggerdotdev/following{/other_user}",
"organizations_url": "https://api.github.com/users/triggerdotdev/orgs",
"subscriptions_url": "https://api.github.com/users/triggerdotdev/subscriptions",
"received_events_url": "https://api.github.com/users/triggerdotdev/received_events"
},
"topics": [],
"git_url": "git://github.com/triggerdotdev/trigger.dev-examples.git",
"license": null,
"node_id": "R_kgDOIxVdCQ",
"private": false,
"ssh_url": "git@github.com:triggerdotdev/trigger.dev-examples.git",
"svn_url": "https://github.com/triggerdotdev/trigger.dev-examples",
"archived": false,
"disabled": false,
"has_wiki": false,
"homepage": null,
"html_url": "https://github.com/triggerdotdev/trigger.dev-examples",
"keys_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/keys{/key_id}",
"language": "TypeScript",
"tags_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/tags",
"watchers": 1,
"blobs_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/blobs{/sha}",
"clone_url": "https://github.com/triggerdotdev/trigger.dev-examples.git",
"forks_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/forks",
"full_name": "triggerdotdev/trigger.dev-examples",
"has_pages": false,
"hooks_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/hooks",
"pulls_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls{/number}",
"pushed_at": "2023-01-24T04:20:52Z",
"teams_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/teams",
"trees_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/trees{/sha}",
"created_at": "2023-01-13T14:26:45Z",
"events_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/events",
"has_issues": true,
"issues_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues{/number}",
"labels_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/labels{/name}",
"merges_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/merges",
"mirror_url": null,
"updated_at": "2023-01-23T14:22:40Z",
"visibility": "public",
"archive_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/{archive_format}{/ref}",
"commits_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/commits{/sha}",
"compare_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/compare/{base}...{head}",
"description": "Node.js project with multiple example Trigger.dev workflows",
"forks_count": 0,
"is_template": false,
"open_issues": 3,
"branches_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/branches{/branch}",
"comments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/comments{/number}",
"contents_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/contents/{+path}",
"git_refs_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/tags{/sha}",
"has_projects": true,
"releases_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/releases{/id}",
"statuses_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/statuses/{sha}",
"allow_forking": true,
"assignees_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/assignees{/user}",
"downloads_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/downloads",
"has_downloads": false,
"languages_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/languages",
"default_branch": "main",
"milestones_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/milestones{/number}",
"stargazers_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/stargazers",
"watchers_count": 1,
"deployments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/deployments",
"git_commits_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/commits{/sha}",
"has_discussions": false,
"subscribers_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/subscribers",
"allow_auto_merge": false,
"contributors_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/contributors",
"issue_events_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/events{/number}",
"stargazers_count": 1,
"subscription_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/subscription",
"collaborators_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/collaborators{/collaborator}",
"issue_comment_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/comments{/number}",
"notifications_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/notifications{?since,all,participating}",
"open_issues_count": 3,
"allow_merge_commit": true,
"allow_rebase_merge": true,
"allow_squash_merge": true,
"merge_commit_title": "MERGE_MESSAGE",
"allow_update_branch": false,
"merge_commit_message": "PR_TITLE",
"delete_branch_on_merge": false,
"squash_merge_commit_title": "COMMIT_OR_PR_TITLE",
"squash_merge_commit_message": "COMMIT_MESSAGES",
"web_commit_signoff_required": false,
"use_squash_pr_title_as_default": false
},
"user": {
"id": 95297378,
"url": "https://api.github.com/users/triggerdotdev",
"type": "Organization",
"login": "triggerdotdev",
"node_id": "O_kgDOBa4fYg",
"html_url": "https://github.com/triggerdotdev",
"gists_url": "https://api.github.com/users/triggerdotdev/gists{/gist_id}",
"repos_url": "https://api.github.com/users/triggerdotdev/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/95297378?v=4",
"events_url": "https://api.github.com/users/triggerdotdev/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/triggerdotdev/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/triggerdotdev/followers",
"following_url": "https://api.github.com/users/triggerdotdev/following{/other_user}",
"organizations_url": "https://api.github.com/users/triggerdotdev/orgs",
"subscriptions_url": "https://api.github.com/users/triggerdotdev/subscriptions",
"received_events_url": "https://api.github.com/users/triggerdotdev/received_events"
},
"label": "triggerdotdev:main"
},
"body": null,
"head": {
"ref": "resend",
"sha": "efc58e149c06f4a45ebf7a0bf34ac25cdcd34b07",
"repo": {
"id": 588602633,
"url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples",
"fork": false,
"name": "trigger.dev-examples",
"size": 161,
"forks": 0,
"owner": {
"id": 95297378,
"url": "https://api.github.com/users/triggerdotdev",
"type": "Organization",
"login": "triggerdotdev",
"node_id": "O_kgDOBa4fYg",
"html_url": "https://github.com/triggerdotdev",
"gists_url": "https://api.github.com/users/triggerdotdev/gists{/gist_id}",
"repos_url": "https://api.github.com/users/triggerdotdev/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/95297378?v=4",
"events_url": "https://api.github.com/users/triggerdotdev/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/triggerdotdev/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/triggerdotdev/followers",
"following_url": "https://api.github.com/users/triggerdotdev/following{/other_user}",
"organizations_url": "https://api.github.com/users/triggerdotdev/orgs",
"subscriptions_url": "https://api.github.com/users/triggerdotdev/subscriptions",
"received_events_url": "https://api.github.com/users/triggerdotdev/received_events"
},
"topics": [],
"git_url": "git://github.com/triggerdotdev/trigger.dev-examples.git",
"license": null,
"node_id": "R_kgDOIxVdCQ",
"private": false,
"ssh_url": "git@github.com:triggerdotdev/trigger.dev-examples.git",
"svn_url": "https://github.com/triggerdotdev/trigger.dev-examples",
"archived": false,
"disabled": false,
"has_wiki": false,
"homepage": null,
"html_url": "https://github.com/triggerdotdev/trigger.dev-examples",
"keys_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/keys{/key_id}",
"language": "TypeScript",
"tags_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/tags",
"watchers": 1,
"blobs_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/blobs{/sha}",
"clone_url": "https://github.com/triggerdotdev/trigger.dev-examples.git",
"forks_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/forks",
"full_name": "triggerdotdev/trigger.dev-examples",
"has_pages": false,
"hooks_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/hooks",
"pulls_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls{/number}",
"pushed_at": "2023-01-24T04:20:52Z",
"teams_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/teams",
"trees_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/trees{/sha}",
"created_at": "2023-01-13T14:26:45Z",
"events_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/events",
"has_issues": true,
"issues_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues{/number}",
"labels_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/labels{/name}",
"merges_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/merges",
"mirror_url": null,
"updated_at": "2023-01-23T14:22:40Z",
"visibility": "public",
"archive_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/{archive_format}{/ref}",
"commits_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/commits{/sha}",
"compare_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/compare/{base}...{head}",
"description": "Node.js project with multiple example Trigger.dev workflows",
"forks_count": 0,
"is_template": false,
"open_issues": 3,
"branches_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/branches{/branch}",
"comments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/comments{/number}",
"contents_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/contents/{+path}",
"git_refs_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/tags{/sha}",
"has_projects": true,
"releases_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/releases{/id}",
"statuses_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/statuses/{sha}",
"allow_forking": true,
"assignees_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/assignees{/user}",
"downloads_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/downloads",
"has_downloads": false,
"languages_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/languages",
"default_branch": "main",
"milestones_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/milestones{/number}",
"stargazers_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/stargazers",
"watchers_count": 1,
"deployments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/deployments",
"git_commits_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/commits{/sha}",
"has_discussions": false,
"subscribers_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/subscribers",
"allow_auto_merge": false,
"contributors_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/contributors",
"issue_events_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/events{/number}",
"stargazers_count": 1,
"subscription_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/subscription",
"collaborators_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/collaborators{/collaborator}",
"issue_comment_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/comments{/number}",
"notifications_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/notifications{?since,all,participating}",
"open_issues_count": 3,
"allow_merge_commit": true,
"allow_rebase_merge": true,
"allow_squash_merge": true,
"merge_commit_title": "MERGE_MESSAGE",
"allow_update_branch": false,
"merge_commit_message": "PR_TITLE",
"delete_branch_on_merge": false,
"squash_merge_commit_title": "COMMIT_OR_PR_TITLE",
"squash_merge_commit_message": "COMMIT_MESSAGES",
"web_commit_signoff_required": false,
"use_squash_pr_title_as_default": false
},
"user": {
"id": 95297378,
"url": "https://api.github.com/users/triggerdotdev",
"type": "Organization",
"login": "triggerdotdev",
"node_id": "O_kgDOBa4fYg",
"html_url": "https://github.com/triggerdotdev",
"gists_url": "https://api.github.com/users/triggerdotdev/gists{/gist_id}",
"repos_url": "https://api.github.com/users/triggerdotdev/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/95297378?v=4",
"events_url": "https://api.github.com/users/triggerdotdev/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/triggerdotdev/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/triggerdotdev/followers",
"following_url": "https://api.github.com/users/triggerdotdev/following{/other_user}",
"organizations_url": "https://api.github.com/users/triggerdotdev/orgs",
"subscriptions_url": "https://api.github.com/users/triggerdotdev/subscriptions",
"received_events_url": "https://api.github.com/users/triggerdotdev/received_events"
},
"label": "triggerdotdev:resend"
},
"user": {
"id": 534,
"url": "https://api.github.com/users/ericallam",
"type": "User",
"login": "ericallam",
"node_id": "MDQ6VXNlcjUzNA==",
"html_url": "https://github.com/ericallam",
"gists_url": "https://api.github.com/users/ericallam/gists{/gist_id}",
"repos_url": "https://api.github.com/users/ericallam/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/534?v=4",
"events_url": "https://api.github.com/users/ericallam/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/ericallam/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/ericallam/followers",
"following_url": "https://api.github.com/users/ericallam/following{/other_user}",
"organizations_url": "https://api.github.com/users/ericallam/orgs",
"subscriptions_url": "https://api.github.com/users/ericallam/subscriptions",
"received_events_url": "https://api.github.com/users/ericallam/received_events"
},
"draft": false,
"state": "open",
"title": "Example PR",
"_links": {
"html": {
"href": "https://github.com/triggerdotdev/trigger.dev-examples/pull/4"
},
"self": {
"href": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls/4"
},
"issue": {
"href": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/4"
},
"commits": {
"href": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls/4/commits"
},
"comments": {
"href": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/4/comments"
},
"statuses": {
"href": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/statuses/efc58e149c06f4a45ebf7a0bf34ac25cdcd34b07"
},
"review_comment": {
"href": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls/comments{/number}"
},
"review_comments": {
"href": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls/4/comments"
}
},
"labels": [],
"locked": false,
"merged": false,
"number": 4,
"commits": 1,
"node_id": "PR_kwDOIxVdCc5IY83X",
"assignee": null,
"comments": 0,
"diff_url": "https://github.com/triggerdotdev/trigger.dev-examples/pull/4.diff",
"html_url": "https://github.com/triggerdotdev/trigger.dev-examples/pull/4",
"additions": 220,
"assignees": [],
"closed_at": null,
"deletions": 0,
"issue_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/4",
"mergeable": null,
"merged_at": null,
"merged_by": null,
"milestone": null,
"patch_url": "https://github.com/triggerdotdev/trigger.dev-examples/pull/4.patch",
"auto_merge": null,
"created_at": "2023-01-24T04:20:51Z",
"rebaseable": null,
"updated_at": "2023-01-24T04:20:51Z",
"commits_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls/4/commits",
"comments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/4/comments",
"statuses_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/statuses/efc58e149c06f4a45ebf7a0bf34ac25cdcd34b07",
"changed_files": 3,
"mergeable_state": "unknown",
"requested_teams": [],
"review_comments": 0,
"merge_commit_sha": null,
"active_lock_reason": null,
"author_association": "MEMBER",
"review_comment_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls/comments{/number}",
"requested_reviewers": [],
"review_comments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls/4/comments",
"maintainer_can_modify": false
}
}
```
@@ -1,311 +0,0 @@
---
title: "Push Event"
sidebarTitle: "Pushes"
description: "Trigger a workflow whenever a push action is performed in a GitHub repository."
---
## Usage
```ts
import * as github from "@trigger.dev/github";
new Trigger({
id: "demo",
on: github.events.pushEvent({
repo: "triggerdotdev/trigger.dev",
}),
run: async (event, ctx) => {},
}).listen();
```
## Params
<ParamField path="repo" type="string" required={true}>
The full path to the repository, including the organization
</ParamField>
## Event
<ResponseField name="ref" type="string">
The full git ref that was pushed. Example: refs/heads/master.
</ResponseField>
<ResponseField name="before" type="string">
The SHA of the commit before the push.
</ResponseField>
<ResponseField name="after" type="string">
The SHA of the commit after the push.
</ResponseField>
<ResponseField name="created" type="boolean">
Whether this was a created branch or tag.
</ResponseField>
<ResponseField name="deleted" type="boolean">
Whether this was a deleted branch or tag.
</ResponseField>
<ResponseField name="forced" type="boolean">
Whether this was a forced update or not.
</ResponseField>
<ResponseField name="base_ref" type="string">
If the ref is a branch, this is the branch name that the push was made to.
</ResponseField>
<ResponseField name="compare" type="string">
The HTTP URL to compare the two commits.
</ResponseField>
<ResponseField name="commits" type="array">
An array of commit objects describing the pushed commits.
</ResponseField>
<ResponseField name="head_commit" type="object">
The head commit object.
</ResponseField>
<ResponseField name="repository" type="object" required={true}>
A repository on GitHub.
</ResponseField>
<ResponseField name="sender" type="object" required={true}>
The GitHub user object who performed the action.
</ResponseField>
<ResponseField name="organization" type="object">
The organization object the repository belongs to.
</ResponseField>
## Example Workflows
<CodeGroup>
```typescript Notify Slack on new push
new Trigger({
id: "github-to-slack",
name: "Notify of new push",
on: github.events.pushEvent({
repo: "triggerdotdev/trigger.dev",
}),
run: async (event, ctx) => {
await slack.postMessage("New push to trigger.dev", {
channel: "github-changes",
text: `New push to trigger.dev by ${event.sender.login}: ${event.compare}`,
});
},
}).listen();
```
</CodeGroup>
## Example Event payload
```json
{
"ref": "refs/heads/main",
"after": "4a0834a1daa09cdd1a03038dbc131f807d887de8",
"before": "e7c0680e23fcd3e52d35ddfbb4076112c640d9fa",
"forced": false,
"pusher": {
"name": "ericallam",
"email": "eallam@icloud.com"
},
"sender": {
"id": 534,
"url": "https://api.github.com/users/ericallam",
"type": "User",
"login": "ericallam",
"node_id": "MDQ6VXNlcjUzNA==",
"html_url": "https://github.com/ericallam",
"gists_url": "https://api.github.com/users/ericallam/gists{/gist_id}",
"repos_url": "https://api.github.com/users/ericallam/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/534?v=4",
"events_url": "https://api.github.com/users/ericallam/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/ericallam/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/ericallam/followers",
"following_url": "https://api.github.com/users/ericallam/following{/other_user}",
"organizations_url": "https://api.github.com/users/ericallam/orgs",
"subscriptions_url": "https://api.github.com/users/ericallam/subscriptions",
"received_events_url": "https://api.github.com/users/ericallam/received_events"
},
"commits": [
{
"id": "4a0834a1daa09cdd1a03038dbc131f807d887de8",
"url": "https://github.com/triggerdotdev/trigger.dev-examples/commit/4a0834a1daa09cdd1a03038dbc131f807d887de8",
"added": [],
"author": {
"name": "Eric Allam",
"email": "eallam@icloud.com",
"username": "ericallam"
},
"message": "Add some documentation for how to run (needs work)",
"removed": [],
"tree_id": "5c06942324e80422eea4f4c11ff80d4bd8f9d7a7",
"distinct": true,
"modified": [
"README.md",
"pnpm-lock.yaml",
"src/examples/github-webhook.ts"
],
"committer": {
"name": "Eric Allam",
"email": "eallam@icloud.com",
"username": "ericallam"
},
"timestamp": "2023-01-24T04:43:40Z"
}
],
"compare": "https://github.com/triggerdotdev/trigger.dev-examples/compare/e7c0680e23fc...4a0834a1daa0",
"created": false,
"deleted": false,
"base_ref": null,
"repository": {
"id": 588602633,
"url": "https://github.com/triggerdotdev/trigger.dev-examples",
"fork": false,
"name": "trigger.dev-examples",
"size": 161,
"forks": 0,
"owner": {
"id": 95297378,
"url": "https://api.github.com/users/triggerdotdev",
"name": "triggerdotdev",
"type": "Organization",
"email": "hello@trigger.dev",
"login": "triggerdotdev",
"node_id": "O_kgDOBa4fYg",
"html_url": "https://github.com/triggerdotdev",
"gists_url": "https://api.github.com/users/triggerdotdev/gists{/gist_id}",
"repos_url": "https://api.github.com/users/triggerdotdev/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/95297378?v=4",
"events_url": "https://api.github.com/users/triggerdotdev/events{/privacy}",
"site_admin": false,
"gravatar_id": "",
"starred_url": "https://api.github.com/users/triggerdotdev/starred{/owner}{/repo}",
"followers_url": "https://api.github.com/users/triggerdotdev/followers",
"following_url": "https://api.github.com/users/triggerdotdev/following{/other_user}",
"organizations_url": "https://api.github.com/users/triggerdotdev/orgs",
"subscriptions_url": "https://api.github.com/users/triggerdotdev/subscriptions",
"received_events_url": "https://api.github.com/users/triggerdotdev/received_events"
},
"topics": [],
"git_url": "git://github.com/triggerdotdev/trigger.dev-examples.git",
"license": null,
"node_id": "R_kgDOIxVdCQ",
"private": false,
"ssh_url": "git@github.com:triggerdotdev/trigger.dev-examples.git",
"svn_url": "https://github.com/triggerdotdev/trigger.dev-examples",
"archived": false,
"disabled": false,
"has_wiki": false,
"homepage": null,
"html_url": "https://github.com/triggerdotdev/trigger.dev-examples",
"keys_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/keys{/key_id}",
"language": "TypeScript",
"tags_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/tags",
"watchers": 1,
"blobs_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/blobs{/sha}",
"clone_url": "https://github.com/triggerdotdev/trigger.dev-examples.git",
"forks_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/forks",
"full_name": "triggerdotdev/trigger.dev-examples",
"has_pages": false,
"hooks_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/hooks",
"pulls_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/pulls{/number}",
"pushed_at": 1674535423,
"teams_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/teams",
"trees_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/trees{/sha}",
"created_at": 1673620005,
"events_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/events",
"has_issues": true,
"issues_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues{/number}",
"labels_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/labels{/name}",
"merges_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/merges",
"mirror_url": null,
"stargazers": 1,
"updated_at": "2023-01-23T14:22:40Z",
"visibility": "public",
"archive_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/{archive_format}{/ref}",
"commits_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/commits{/sha}",
"compare_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/compare/{base}...{head}",
"description": "Node.js project with multiple example Trigger.dev workflows",
"forks_count": 0,
"is_template": false,
"open_issues": 2,
"branches_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/branches{/branch}",
"comments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/comments{/number}",
"contents_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/contents/{+path}",
"git_refs_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/tags{/sha}",
"has_projects": true,
"organization": "triggerdotdev",
"releases_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/releases{/id}",
"statuses_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/statuses/{sha}",
"allow_forking": true,
"assignees_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/assignees{/user}",
"downloads_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/downloads",
"has_downloads": false,
"languages_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/languages",
"master_branch": "main",
"default_branch": "main",
"milestones_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/milestones{/number}",
"stargazers_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/stargazers",
"watchers_count": 1,
"deployments_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/deployments",
"git_commits_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/git/commits{/sha}",
"has_discussions": false,
"subscribers_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/subscribers",
"contributors_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/contributors",
"issue_events_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/events{/number}",
"stargazers_count": 1,
"subscription_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/subscription",
"collaborators_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/collaborators{/collaborator}",
"issue_comment_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/issues/comments{/number}",
"notifications_url": "https://api.github.com/repos/triggerdotdev/trigger.dev-examples/notifications{?since,all,participating}",
"open_issues_count": 2,
"web_commit_signoff_required": false
},
"head_commit": {
"id": "4a0834a1daa09cdd1a03038dbc131f807d887de8",
"url": "https://github.com/triggerdotdev/trigger.dev-examples/commit/4a0834a1daa09cdd1a03038dbc131f807d887de8",
"added": [],
"author": {
"name": "Eric Allam",
"email": "eallam@icloud.com",
"username": "ericallam"
},
"message": "Add some documentation for how to run (needs work)",
"removed": [],
"tree_id": "5c06942324e80422eea4f4c11ff80d4bd8f9d7a7",
"distinct": true,
"modified": [
"README.md",
"pnpm-lock.yaml",
"src/examples/github-webhook.ts"
],
"committer": {
"name": "Eric Allam",
"email": "eallam@icloud.com",
"username": "ericallam"
},
"timestamp": "2023-01-24T04:43:40Z"
},
"organization": {
"id": 95297378,
"url": "https://api.github.com/orgs/triggerdotdev",
"login": "triggerdotdev",
"node_id": "O_kgDOBa4fYg",
"hooks_url": "https://api.github.com/orgs/triggerdotdev/hooks",
"repos_url": "https://api.github.com/orgs/triggerdotdev/repos",
"avatar_url": "https://avatars.githubusercontent.com/u/95297378?v=4",
"events_url": "https://api.github.com/orgs/triggerdotdev/events",
"issues_url": "https://api.github.com/orgs/triggerdotdev/issues",
"description": "",
"members_url": "https://api.github.com/orgs/triggerdotdev/members{/member}",
"public_members_url": "https://api.github.com/orgs/triggerdotdev/public_members{/member}"
}
}
```
@@ -1,128 +0,0 @@
---
title: "Send Email"
sidebarTitle: "Send Email"
description: "Send email using Resend.com"
---
Send email using Resend.com, which supports sending emails using React, HTML, and plain text. Resend.com is currently in private beta but you can request early access [here](https://resend.com/).
<Note>
If you'd like to render emails using React, please see the [React.email
docs](https://react.email/)
</Note>
## Params
<ParamField path="key" type="string" required={true}>
A unique string. Please see the [Keys and Resumability](/guides/resumability)
doc for more info.
</ParamField>
<ParamField path="message" type="object" required={true}>
<Expandable title="properties" defaultOpen={true}>
<ParamField path="text" type="string" required={false}>
The text of the email. If `html` is provided, this will be used as the
plain text version of the email.
</ParamField>
<ParamField path="html" type="string" required={false}>
The HTML of the email. If `text` is provided, this will be used as the
HTML version of the email.
</ParamField>
<ParamField path="react" type="react component" required={false}>
A React component that will be rendered to HTML and used as the email
content. Please see the [React.email docs](https://react.email/) for more info
</ParamField>
<ParamField path="subject" type="string" required={true}>
The subject of the email.
</ParamField>
<ParamField path="from" type="string" required={true}>
The email address of the sender.
</ParamField>
<ParamField path="to" type="string | string[]" required={true}>
One or more email addresses of the recipients.
</ParamField>
<ParamField path="cc" type="string | string[]" required={false}>
One or more email addresses of the CC recipients.
</ParamField>
<ParamField path="bcc" type="string | string[]" required={false}>
One or more email addresses of the BCC recipients.
</ParamField>
<ParamField path="replyTo" type="string | string[]" required={false}>
An optional email address to use as the reply-to address.
</ParamField>
</Expandable>
</ParamField>
## Response
<ResponseField name="id" type="string">
The ID of the email.
</ResponseField>
<ResponseField name="from" type="string">
The email address of the sender.
</ResponseField>
<ResponseField name="to" type="string">
The email address of the recipient.
</ResponseField>
<ResponseField name="created_at" type="string">
The date and time the email was created.
</ResponseField>
## Example Workflows
<CodeGroup>
```typescript criticalIssue.tsx
import * as github from "@trigger.dev/github";
import * as resend from "@trigger.dev/resend";
import { CriticalIssueEmail } from "./emails";
new Trigger({
id: "email-ops",
name: "On Critical Issue",
on: github.events.issueEvent({
repo: "triggerdotdev/trigger.dev",
}),
run: async (event, ctx) => {
if (event.action === "labeled" && event.label.name === "critical") {
await resend.sendEmail("🚨 Alert Ops", {
to: "ops@trigger.dev",
from: "internal@trigger.dev",
subject: `Critical issue: ${event.issue.title}`,
react: (
<CriticalIssueEmail
issue={event.issue}
sender={event.sender}
repo={event.repository}
/>
),
});
}
},
}).listen();
```
</CodeGroup>
## Example Response
```json
{
"id": "1673618429",
"from": "internal@trigger.dev",
"to": "ops@trigger.dev",
"created_at": "2023-01-24T14:38:26Z"
}
```
-11
View File
@@ -1,11 +0,0 @@
---
title: "Shopify"
sidebarTitle: "Shopify"
description: "Support for the Shopify API"
---
## Shopify API integration
Full reference of all functions is coming soon.
Check out some example workflows using the Shopify API [here](/examples/shopify).
-11
View File
@@ -1,11 +0,0 @@
---
title: "Slack"
sidebarTitle: "Slack"
description: "Support for the Slack API"
---
## Slack API integration
Full reference of all functions is coming soon.
Check out some example workflows using the Slack API [here](/examples/slack).
@@ -1,263 +0,0 @@
---
title: "Post Message"
sidebarTitle: "Post Message"
description: "Post a message to a Slack channel"
---
Publish Slack messages to a public or private channel in your Slack Workspace as the Trigger.dev Slack bot. If you need to publish messages to your customer's Slack channels, consider using [Incoming Webhooks](https://api.slack.com/messaging/webhooks) and our [fetch](/functions/fetch) function.
## Params
<ParamField path="key" type="string" required={true}>
A unique string. Please see the [Keys and Resumability](/guides/resumability)
doc for more info.
</ParamField>
<ParamField path="message" type="object" required={true}>
<Expandable title="properties" defaultOpen={true}>
<ParamField path="channelName" type="string" required={false}>
The name of the channel, can optionally include the `#`. E.g. `#team`.
Alternatively you can use the `channelId` param.
</ParamField>
<ParamField path="channelId" type="string" required={false}>
The slack ID of the channel, e.g. `C04GWUTDC4W`. Can be used instead of `channelName`. Use `channelId` if the slack channel name could change.
</ParamField>
<ParamField path="text" type="string" required={true}>
The formatted text of the message to be published, formatted as [mrkdwn](https://api.slack.com/reference/surfaces/formatting#basics).
</ParamField>
<ParamField path="blocks" type="object" required={false}>
You can use blocks to create a rich message with images, buttons, and more.
You can either pass in a JavaScript object or use [JSX Slack](https://github.com/yhatt/jsx-slack/) to create blocks. We highly recommend using JSX Slack as it's much easier to read and write. See the [block example](#blocks-with-interactivity) to see it in action.
For full details on Slack blocks, see the [Slack API docs](https://api.slack.com/reference/block-kit/blocks).
</ParamField>
</Expandable>
</ParamField>
## Response
<ResponseField name="ok" type="boolean" default="true">
Always true; non-ok responses will halt the workflow run and throw an error.
</ResponseField>
<ResponseField name="channel" type="string">
The channel ID of the channel the message was published to.
</ResponseField>
<ResponseField name="ts" type="string">
The "timestamp ID" of the message, which can be used to update or delete the
message.
</ResponseField>
<ResponseField name="message" type="object">
<Expandable title="properties">
<ResponseField name="ts" type="string">
The "timestamp ID" of the message, which can be used to update or delete the message.
</ResponseField>
<ResponseField name="text" type="string">
The text published to the channel.
</ResponseField>
<ResponseField name="user" type="string">
The user ID of the user who published the message.
</ResponseField>
<ResponseField name="bot_id" type="string">
The bot ID of the bot that published the message.
</ResponseField>
</Expandable>
</ResponseField>
## Example Workflows
### Notify Slack on New GitHub Star
<CodeGroup>
```typescript Notify Slack on New GitHub Star
import * as github from "@trigger.dev/github";
import * as slack from "@trigger.dev/slack";
new Trigger({
id: "new-star",
name: "On New Star",
on: github.events.newStarEvent({
repo: "triggerdotdev/trigger.dev",
}),
run: async (event, ctx) => {
await slack.postMessage("⭐️ New Star", {
channelName: "github-stars",
text: `Repo ${event.repository.full_name} got a star from ${event.sender.login}, for a total of ${event.repository.stargazers_count} stars!`,
});
},
}).listen();
```
```json Example response
{
"ok": true,
"ts": "1673618429.084699",
"channel": "C04GWUTDC3W",
"message": {
"ts": "1673618429.084699",
"text": "New domain created: trigger.dev by customer 1st-ever-slack-workflow-yippie",
"type": "message",
"user": "U04JTTQ08SF",
"bot_id": "B04JR3DCB4M"
}
}
```
</CodeGroup>
### Blocks with interactivity
You can add interaction and richer visual elements using Blocks. The easiest way to add them is using `jsx-slack` (which is a separate npm package that you can install).
This example messages your team every minute (!) and asks them how they're doing. There are two buttons and a dropdown menu.
In this examples there are two workflows:
1. Messages your team every minute (!) and asks them how they're doing.
2. Receives the interaction from users. It adds reactions when the buttons are pressed and posts a message when a user selects from the dropdown menu.
Please note, that to use `jsx-slack` you will need to add the `jsxImportSource` pragma to the top of your file. This is because `jsx-slack` is not a React library, but it uses the same syntax as React. Also, you might need to add `"jsx": "react-jsx"` to your `compilerOption` in `tsconfig.json`. The workflow file needs to be a `.jsx` or `.tsx` file (like when you use React).
<CodeGroup>
```typescript workflow.tsx
/** @jsxImportSource jsx-slack */
import * as slack from "@trigger.dev/slack";
import JSXSlack, {
Actions,
Blocks,
Button,
Section,
Select,
Option,
} from "jsx-slack";
import { z } from "zod";
const BLOCK_ID = "issue.action.block";
//1. every minute see how your employees are doing, we don't recommend this frequency 😉
new Trigger({
id: "slack-interactivity",
name: "Testing Slack Interactivity",
on: scheduleEvent({
rateOf: {
minutes: 1,
},
}),
run: async (event, ctx) => {
await slack.postMessage("jsx-test", {
channelName: "test-integrations",
//text appears in Slack notifications on mobile/desktop
text: "How is your progress today?",
//import and use JSXSlack to make creating rich messages much easier
blocks: JSXSlack(
<Blocks>
<Section>How is your progress today?</Section>
<Actions blockId={BLOCK_ID}>
<Button value="blocked" actionId="status-blocked">
I'm blocked
</Button>
<Button
value="help"
actionId="status-help"
url="https://xkcd.com/1349/"
>
Get help
</Button>
<Select actionId="rating" placeholder="Rate it!">
<Option value="5">5 {":star:".repeat(5)}</Option>
<Option value="4">4 {":star:".repeat(4)}</Option>
<Option value="3">3 {":star:".repeat(3)}</Option>
<Option value="2">2 {":star:".repeat(2)}</Option>
<Option value="1">1 {":star:".repeat(1)}</Option>
</Select>
</Actions>
</Blocks>
),
});
},
}).listen();
//2. this workflow listens for Slack interactions filtered by the block id and actions we used above
new Trigger({
id: "slack-block-interaction",
name: "Slack Block Interaction",
on: slack.events.blockActionInteraction({
blockId: BLOCK_ID,
actionId: ["status-blocked", "status-help", "rating"],
}),
run: async (event, ctx) => {
//create promises from all the actions
const promises = event.actions.map((action) => {
switch (action.action_id) {
case "status-blocked": {
//the user is blocked so add a 😢 emoji as a reaction
if (event.message) {
return slack.addReaction("React to message", {
name: "cry",
timestamp: event.message.ts,
channelId: event.channel.id,
});
}
break;
}
case "status-help": {
//the user needs help so add an 🆘 emoji as a reaction
if (event.message) {
return slack.addReaction("React to message", {
name: "sos",
timestamp: event.message.ts,
channelId: event.channel.id,
});
}
break;
}
case "rating": {
if (action.type != "static_select") {
throw new Error("This action should be a select");
}
//post the rating as a message that appears below the original,
//only the user pressing the button will see this message
return slack.postMessageResponse(
"Added a comment to the issue",
event.response_url,
{
text: `You rated your day ${action.selected_option?.value} stars`,
replace_original: false,
}
);
}
default:
return Promise.resolve();
}
});
await Promise.all(promises);
},
}).listen();
```
```json tsconfig.json
{
//other options
"compilerOptions": {
"jsx": "react-jsx"
//other options
}
}
```
</CodeGroup>
@@ -1,7 +0,0 @@
---
title: "Authentication"
sidebarTitle: "Authentication"
description: "Authentication"
---
Coming soon...
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

-162
View File
@@ -1,162 +0,0 @@
{
"name": "Trigger.dev",
"logo": {
"dark": "/logo/light.png",
"light": "/logo/light.png",
"href": "https://app.trigger.dev"
},
"favicon": "/images/favicon.png",
"colors": {
"primary": "#0fd122",
"light": "#41FF54",
"dark": "#632CCC",
"anchors": {
"from": "#069613",
"to": "#0fd122"
}
},
"backgroundImage": "/images/docs-background.png",
"modeToggle": {
"default": "dark",
"isHidden": true
},
"topbarLinks": [
{
"name": "Login",
"url": "https://app.trigger.dev"
},
{
"name": "Sign up",
"url": "https://app.trigger.dev"
}
],
"topbarCtaButton": {
"type": "github",
"url": "https://github.com/triggerdotdev/trigger.dev"
},
"anchors": [
{
"name": "Community",
"icon": "discord",
"url": "https://discord.gg/nkqV9xBYWy"
},
{
"name": "GitHub",
"icon": "github",
"url": "https://github.com/triggerdotdev/trigger.dev"
}
],
"navigation": [
{
"group": "Getting Started",
"pages": [
"welcome",
"getting-started",
"get-help"
]
},
{
"group": "Examples",
"pages": [
"examples/examples",
"examples/slack",
"examples/github",
"examples/shopify",
"examples/resend"
]
},
{
"group": "Triggers",
"pages": [
"triggers/webhooks",
"triggers/custom-events",
"triggers/scheduled"
]
},
{
"group": "Integrations",
"pages": [
{
"group": "APIs",
"pages": [
{
"group": "Slack",
"pages": [
"integrations/apis/slack/actions/post-message"
]
},
{
"group": "Resend.com",
"pages": [
"integrations/apis/resend/actions/send-email"
]
}
]
},
"integrations/authentication"
]
},
{
"group": "Functions",
"pages": [
"functions/fetch",
"functions/logging",
"functions/delays",
"functions/send-event",
"functions/loops-conditionals-etc"
]
},
{
"group": "Guides",
"pages": [
"guides/resumability",
"guides/event-filters",
"guides/zod",
"guides/event-driven"
]
},
{
"group": "SDK Reference",
"pages": [
"reference/trigger",
"reference/custom-event",
"reference/webhook-event",
"reference/schedule-event",
"reference/send-event"
]
},
{
"group": "API Reference",
"pages": [
"api/events/sendEvent"
]
},
{
"group": "Webhook Catalog",
"pages": [
{
"group": "GitHub",
"pages": [
"integrations/apis/github/events/push",
"integrations/apis/github/events/issues",
"integrations/apis/github/events/issue-comments",
"integrations/apis/github/events/pull-requests",
"integrations/apis/github/events/pull-request-reviews",
"integrations/apis/github/events/pull-request-comments",
"integrations/apis/github/events/new-star"
]
}
]
}
],
"footerSocials": {
"twitter": "https://twitter.com/triggerdotdev",
"github": "https://github.com/triggerdotdev/trigger.dev",
"discord": "https://discord.gg/nkqV9xBYWy"
},
"api": {
"auth": {
"method": "bearer"
}
}
}
-133
View File
@@ -1,133 +0,0 @@
openapi: 3.0.3
info:
title: Trigger.dev API
version: v0.2.3
description: Please see https://docs.trigger.dev for more details.
contact:
name: Eric
email: eric@trigger.dev
url: https://trigger.dev
termsOfService: https://trigger.dev/terms
servers:
- url: https://app.trigger.dev/api/v1
description: Trigger.dev
tags:
- name: "events"
description: "Send and manage custom events"
externalDocs:
description: "Trigger.dev Docs"
url: "https://docs.trigger.dev"
security:
- apiKey: []
paths:
/events:
post:
summary: Send Custom Event
description: Send a custom event to run your customEvent Triggers
operationId: "sendEvent"
tags:
- events
externalDocs:
description: "API method documentation"
url: "https://docs.trigger.dev/api/events/sendEvent"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/customEvent"
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/customEvent"
"401":
description: Unauthorized
content:
application/json:
schema:
$ref: "#/components/schemas/error"
"405":
description: Method not allowed
content:
application/json:
schema:
$ref: "#/components/schemas/error"
"422":
description: Unprocessable Entity
content:
application/json:
schema:
$ref: "#/components/schemas/error"
components:
schemas:
error:
type: object
properties:
error:
type: string
customEvent:
type: object
required:
- id
- event
properties:
id:
type: string
description: "A unique event identifier, can be used to deduplicate events. Use a sufficiently unique ID generator, such as UUIDv4"
event:
type: object
additionalProperties: false
required:
- name
- payload
properties:
name:
type: string
example: user.created
description: "The name of the event. This is the same value you'd use in your customEvent trigger code to listen for events"
payload:
type: object
additionalProperties: true
description: "The JSON payload of the event"
context:
type: object
additionalProperties: true
description: "An optional context object for the event. This can be used to pass additional information about the event, such as the user who triggered it. Note that this is not currently exposed to the workflow (coming soon)."
timestamp:
type: string
format: "date-time"
example: "2022-01-01T12:30:00Z"
description: "An optional timestamp for the event. If not provided, one will be generated. Must be in ISO 8601 format (e.g. new Date().toISOString())"
delay:
type: object
description: "An optional delay object for the event. This can be used to delay the event by a certain amount of time. "
oneOf:
- type: object
properties:
seconds:
type: integer
- type: object
properties:
minutes:
type: integer
- type: object
properties:
hours:
type: integer
- type: object
properties:
days:
type: integer
- type: object
properties:
until:
type: string
format: date-time
securitySchemes:
apiKey:
type: apiKey
in: header
name: Authorization
-12
View File
@@ -1,12 +0,0 @@
{
"name": "docs",
"version": "1.0.0",
"description": "Trigger.dev documentation",
"private": true,
"scripts": {
"dev": "mintlify dev --port 3050"
},
"devDependencies": {
"mintlify": "^2.0.16"
}
}
-40
View File
@@ -1,40 +0,0 @@
---
title: "customEvent Trigger"
sidebarTitle: "customEvent"
description: "Trigger a workflow when a custom event is received."
---
## Usage
```ts
import { customEvent, Trigger } from "@trigger.dev/sdk";
new Trigger({
id: "user-created-notify-slack",
name: "User Created - Notify Slack",
on: customEvent({
name: "user.created",
schema: z.object({ id: z.string(), admin: z.boolean() }),
filter: {
admin: [false],
},
}),
run: async (event, ctx) => {},
}).listen();
```
## Options
<ParamField path="name" type="string" required={true}>
The name of the custom event to listen for.
</ParamField>
<ParamField path="filter" type="object" required={false}>
An event filter to apply to the custom event payload. See the [event filter
documentation](/guides/event-filters) for more information.
</ParamField>
<ParamField path="schema" type="Zod Schema" required={true}>
A Zod schema to validate the webhook event payload against. See our [Zod
guide](/guides/zod) for more information.
</ParamField>
-68
View File
@@ -1,68 +0,0 @@
---
title: "scheduleEvent Trigger"
sidebarTitle: "scheduleEvent"
description: "Run a workflow on a recurring schedule."
---
## Usage
```ts
import { scheduleEvent } from "@trigger.dev/sdk";
new Trigger({
id: "usage",
name: "usage",
on: scheduleEvent({ rateof: { minutes: 10 } }),
run: async (event, ctx) => {},
}).listen();
```
## Options
You must use one of the following options, but not both:
<ParamField path="rateOf" type="object" required={false}>
The rate of the schedule. This can be a number of minutes, hours,
or days. For example, `{ rateOf: { minutes: 10 } }` will run
every 10 minutes.
</ParamField>
<ParamField path="cron" type="string" required={false}>
A cron expression to run the workflow on. For example, `0 0 * * *` will run
the workflow every hour at the top of the hour. See
[crontab.guru](https://crontab.guru/) for more information.
</ParamField>
## Event Payload
<ResponseField name="scheduledTime" type="Date" required={true}>
The time the event was scheduled to run.
</ResponseField>
<ResponseField name="lastRunAt" type="Date" required={false}>
The time the event last run. This will be `undefined` if the event has never run. Use this parameter to run window queries:
```ts
import { scheduleEvent, Trigger } from "@trigger.dev/sdk";
new Trigger({
id: "usage",
name: "usage",
on: scheduleEvent({ rateof: { minutes: 10 } }),
run: async (event, ctx) => {
const { lastRunAt, scheduledTime } = event;
const query = `SELECT * FROM users WHERE created_at < ${scheduledTime}`;
if (lastRunAt) {
query += ` AND created_at > ${lastRunAt}`;
}
const latestUsers = await db.query(query);
// ...
},
}).listen();
```
</ResponseField>
-97
View File
@@ -1,97 +0,0 @@
---
title: "sendEvent"
sidebarTitle: "sendEvent"
description: "Send a custom event to Trigger, from inside or outside of a workflow."
---
## Usage
```ts
import { Trigger, customEvent } from "@trigger.dev/sdk";
new Trigger({
id: "usage",
name: "usage",
on: customEvent({
name: "user.created",
schema: z.any(),
}),
run: async (event, ctx) => {
await ctx.sendEvent("Sending context user.created event", {
name: "user.created",
payload: {
id: "1234_abc",
},
});
},
}).listen();
```
You can also use `sendEvent` by importing it from `@trigger.dev/sdk`:
```ts
import { sendEvent } from "@trigger.dev/sdk";
await sendEvent("Sending context user.created event", {
name: "user.created",
payload: {
id: "1234_abc",
},
});
```
<Note>
If calling `sendEvent` from outside of a workflow run, it will make an HTTP
API request to app.trigger.dev to send the event. Make sure you set the
`TRIGGER_API_KEY` environment variable if you will be using it this way.
</Note>
## Parameters
<ParamField path="key" type="string" required={true}>
A unique key for the event in the context of a workflow run. Please see the
[Keys and Resumability](/guides/resumability) guide for more info.
</ParamField>
<ParamField path="event" type="object" required={true}>
<Expandable title="properties" defaultOpen={true}>
<ParamField path="id" type="string" required={false}>
An optional unique ID for the event. If not provided, one will be
generated automatically (using `clid`). Set this field to perform event
deduplication.
</ParamField>
<ParamField path="name" type="string" required={true}>
The name of the event. This is the name you set when creating the
`customEvent` trigger.
</ParamField>
<ParamField path="payload" type="json object" required={true}>
The payload of the event.
</ParamField>
<ParamField path="timestamp" type="ISO8601 string" required={false}>
An optional timestamp for the event. If not provided, one will be generated. Must be in ISO 8601 format (e.g. `new Date().toISOString()`)
</ParamField>
<ParamField path="context" type="json object" required={false}>
An optional context object for the event. This can be used to pass
additional information about the event, such as the user who triggered
it. Note that this is not currently exposed to the workflow (coming soon).
</ParamField>
<ParamField path="delay" type="object" required={false}>
An optional delay object for the event. This can be used to delay the
event by a certain amount of time. Use one of the following options:
- `{ seconds: number }` - delay the event by a certain number of seconds
- `{ minutes: number }` - delay the event by a certain number of minutes
- `{ hours: number }` - delay the event by a certain number of hours
- `{ days: number }` - delay the event by a certain number of days
- `{ until: Date }` - delay the event until a certain date
See the [Delaying Event Delivery](/functions/send-event#delaying-event-delivery) docs for more info.
</ParamField>
</Expandable>
</ParamField>
-159
View File
@@ -1,159 +0,0 @@
---
title: "Trigger"
sidebarTitle: "Trigger"
description: "The Trigger class let's you define a workflow that is triggered by a specific event."
---
## Constructor
### Usage
```ts
import { customEvent, Trigger } from "@trigger.dev/sdk";
const trigger = new Trigger({
id: "user-created-notify-slack",
name: "User Created - Notify Slack",
on: customEvent({
name: "user.created",
schema: z.object({ id: z.string(), admin: z.boolean() }),
filter: {
admin: [false],
},
}),
run: async (event, ctx) => {},
});
```
### Options
<ParamField path="id" type="string" required={true}>
An identifier for this trigger. Must unique across your Trigger.dev
organization.
</ParamField>
<ParamField path="name" type="string" required={true}>
A display name for this trigger.
</ParamField>
<ParamField path="apiKey" type="string" required={false}>
Your Trigger.dev API key. If not provided, the API key will be read from the
`TRIGGER_API_KEY` environment variable.
</ParamField>
<ParamField path="endpoint" type="string" required={false}>
The URL of the Trigger.dev WebSocket server. If not provided, the endpoint
will point to the production server.
</ParamField>
<ParamField path="logLevel" type="string" required={false}>
The log level for the Trigger. Defaults to `info`
</ParamField>
<ParamField path="triggerTTL" type="number" required={false}>
The TTL for the trigger in seconds. If the delay between the event timestamp
and the current time is greater than the TTL, the trigger will not be
executed. Defaults to `3600` seconds, or 1 hour.
</ParamField>
<ParamField path="run" type="function" required={true}>
The function that will be executed when the trigger is fired. The function
will be passed the event data and a context object.
</ParamField>
### Context Object
<ParamField path="id" type="string">
The identifier of the individual run of this trigger.
</ParamField>
<ParamField path="environment" type="string">
Either `development` or `live`, depending on the API Key used.
</ParamField>
<ParamField path="apiKey" type="string">
The API Key used to authenticate this trigger.
</ParamField>
<ParamField path="organizationId" type="string">
The identifier of the organization that owns this trigger.
</ParamField>
<ParamField path="logger" type="object">
The logger object for this trigger. See the [Logging](/functions/logging) page
for more info.
</ParamField>
<ParamField path="isTest" type="boolean">
Whether or not this trigger is being run as a test.
</ParamField>
<ParamField path="sendEvent" type="function">
A function that can be used to send an event to trigger.dev. See the [Sending
Events](/functions/send-event) page for more info.
</ParamField>
<ParamField path="waitFor" type="function">
A function that can be used to wait for a specific amount of time before
continuing. See the [Delays](/functions/delays) page for more info.
</ParamField>
<ParamField path="waitUntil" type="function">
A function that can be used to wait for a specific date/time before
continuing. See the [Delays](/functions/delays) page for more info.
</ParamField>
<ParamField path="fetch" type="function">
A function that can be used to make HTTP requests. See the
[fetch](/functions/fetch) page for more info.
</ParamField>
## listen
The `listen` function will register the Trigger with Trigger.dev and start listening for events.
### Usage
```ts
const trigger = new Trigger({
id: "user-created-notify-slack",
name: "User Created - Notify Slack",
on: customEvent({
name: "user.created",
schema: z.object({ id: z.string(), admin: z.boolean() }),
filter: {
admin: [false],
},
}),
run: async (event, ctx) => {},
});
trigger.listen();
```
You can split the creation of the trigger and the listening for events by calling `trigger.listen()` at a later time.
<CodeGroup>
```ts triggers.ts
export const userCreatedNotifySlack = new Trigger({
id: "user-created-notify-slack",
name: "User Created - Notify Slack",
on: customEvent({
name: "user.created",
schema: z.object({ id: z.string(), admin: z.boolean() }),
filter: {
admin: [false],
},
}),
run: async (event, ctx) => {},
});
```
```ts index.ts
import { userCreatedNotifySlack } from "./triggers";
userCreatedNotifySlack.listen();
```
</CodeGroup>
-65
View File
@@ -1,65 +0,0 @@
---
title: "webhookEvent Trigger"
sidebarTitle: "webhookEvent"
description: "Trigger a workflow when a webhook event is received"
---
## Usage
```ts
import { webhookEvent, Trigger } from "@trigger.dev/sdk";
new Trigger({
id: "caldotcom-to-slack",
name: "Cal.com To Slack",
on: webhookEvent({
service: "cal.com",
eventName: "BOOKING_CREATED",
filter: {
triggerEvent: ["BOOKING_CREATED"],
},
schema: z.any(),
verifyPayload: {
enabled: true,
header: "X-Cal-Signature-256",
},
}),
run: async (event, ctx) => {},
}).listen();
```
## Options
<ParamField path="service" type="string" required={true}>
The name of the service that will be sending the webhook event.
</ParamField>
<ParamField path="name" type="string" required={true}>
The name of the event that will be sent by the service.
</ParamField>
<ParamField path="filter" type="object" required={false}>
An event filter to apply to the webhook event. See the [event filter
documentation](/guides/event-filters) for more information.
</ParamField>
<ParamField path="schema" type="Zod Schema" required={true}>
A Zod schema to validate the webhook event payload against. See our [Zod
guide](/guides/zod) for more information.
</ParamField>
<ParamField path="verifyPayload" type="object" required={false}>
Verify the payload of the webhook event. Currently only supports sha256 HMAC
signatures.
<Expandable title="properties">
<ParamField path="enabled" type="boolean" required={false}>
Whether to verify the payload of the webhook event. Defaults to `false`.
</ParamField>
<ParamField path="header" type="string" required={false}>
The name of the header that contains the signature to verify the payload
against. e.g. `X-Webhook-Signature`.
</ParamField>
</Expandable>
</ParamField>
-38
View File
@@ -1,38 +0,0 @@
---
title: "Resources"
description: "Learn more about how to build amazing documentation"
---
<CardGroup>
<Card title="Development" icon="rectangle-terminal" href="https://mintlify.com/docs/development">
Run on your computer to see changes locally
</Card>
<Card title="Global Settings" icon="sliders" href="https://mintlify.com/docs/settings/global">
Customizing the theme, branding, and other global configurations
</Card>
<Card title="Page Titles and Metadata" icon="heading" href="https://mintlify.com/docs/settings/page">
Setting the title and metadata for navigation and SEO
</Card>
<Card title="Writing Content" icon="pen-nib" href="https://mintlify.com/docs/components/overview">
Introduction on how to add and edit content
</Card>
</CardGroup>
## Advanced Topics
Learn more about how to take your documentation to the next level
<CardGroup>
<Card title="Custom Domains" icon="browser" href="https://mintlify.com/docs/settings/custom-domain/subdomain">
Get the documentation hosted at your custom domain
</Card>
<Card title="Advanced Components" icon="paintbrush-pencil" href="https://mintlify.com/docs/components/advanced/accordion">
Advanced components built for specific communication mediums
</Card>
<Card title="API Components" icon="square-code" href="https://mintlify.com/docs/api-components/overview">
Add an API playground into your documentation
</Card>
<Card title="Analytics" icon="chart-mixed" href="https://mintlify.com/docs/analytics/supported-integrations">
Learn how users are interacting with your documentation
</Card>
</CardGroup>
-117
View File
@@ -1,117 +0,0 @@
---
title: "Custom event triggers"
sidebarTitle: "Custom events"
description: "Custom event triggers allow you to run workflows from your own code (or your other workflows)"
---
[Send an event](/functions/send-event) and any workflows that subscribe to that custom event will get triggered.
## Name and Schemas
### Name
Custom event triggers have a `name`. They will only get triggered when a custom event with that name are sent.
### Schema
Custom event triggers take a [Zod](https://github.com/colinhacks/zod) schema. This is used to validate the data that is sent with the event. If the data does not match the schema, the workflow will not run.
It also means that inside your run function the event param will be typed correctly. We use [Zod](https://github.com/colinhacks/zod#installation) for our schemas it's a fantastic library that allows you to define schemas in a very simple way.
You can always start out by using `z.any()` as your schema, and then later on you can add more strict validation. See our [Zod guide](/guides/zod) for more information.
## Filters
You can also add filters to your custom event triggers. This allows you to filter out events that you don't want to run your workflow for.
```ts
new Trigger({
id: "new-user-slack",
name: "New user slack message",
on: customEvent({
name: "user.created",
schema: z.object({
name: z.string(),
email: z.string(),
paidPlan: z.boolean(),
}),
filter: {
//only run the workflow if the user is paying
paidPlan: [true],
},
}),
//this function is run when the custom event is received
run: async (event, ctx) => {
//send a message to the #new-users Slack channel with user details
const response = await slack.postMessage("send-to-slack", {
channel: "new-users",
text: `New user: ${event.name} (${event.email}) signed up. ${
event.paidPlan ? "They are paying" : "They are on the free plan"
}.`,
});
return response.message;
},
}).listen();
```
Please see the [Event filters guide](/guides/event-filters) for more information.
## Example
```ts
import { Trigger, customEvent } from "@trigger.dev/sdk";
import * as slack from "@trigger.dev/slack";
import { z } from "zod";
//this workflow will run when a "user.created" event is sent
new Trigger({
id: "new-user-slack",
name: "New user slack message",
apiKey: "<your_api_key>",
//this is the custom event subscription
on: customEvent({
name: "user.created",
schema: z.object({
name: z.string(),
email: z.string(),
paidPlan: z.boolean(),
}),
}),
//this function is run when the custom event is received
run: async (event, ctx) => {
//send a message to the #new-users Slack channel with user details
const response = await slack.postMessage("send-to-slack", {
channel: "new-users",
text: `New user: ${event.name} (${event.email}) signed up. ${
event.paidPlan ? "They are paying" : "They are on the free plan"
}.`,
});
return response.message;
},
}).listen();
```
That workflow will never run, unless an event is sent from your code somewhere it can be sent from a completely different server.
## Sending an event
There is a [full guide on sending events](/functions/send-event) but here is a quick example:
```ts
import { sendEvent } from "@trigger.dev/sdk";
//send an event with the name "user.created"
await sendEvent("fire-user-created-event", {
name: "user.created",
payload: { name: "John Doe", email: "john@doe.com", paidPlan: true },
});
```
If you are calling this from inside a workflow, ensure that the first parameter is unique inside your workflow.
<Note>
The same event can trigger many different workflows, just subscribe to the
same event name to achieve this.
</Note>
-109
View File
@@ -1,109 +0,0 @@
---
title: "Scheduled triggers"
sidebarTitle: "Scheduled"
description: "Run a workflow on a recurring schedule"
---
See the [reference](/reference/schedule-event) for more details.
## Examples
### Every 5 minutes
This job will run every 5 minutes, starting 5 minutes after this code is first run on your server (that includes running locally).
```ts
import { Trigger, scheduleEvent } from "@trigger.dev/sdk";
new Trigger({
id: "scheduled-workflow",
name: "Scheduled Workflow",
apiKey: "<your_api_key>",
on: scheduleEvent({ rateOf: { minutes: 5 } }),
run: async (event, ctx) => {
await ctx.logger.info("Received the scheduled event", {
event,
wallTime: new Date(),
});
return { foo: "bar" };
},
}).listen();
```
### Using CRON syntax
This job will run at 2:30pm every Monday. You can get help with [CRON syntax](https://crontab.guru/).
```ts
import { Trigger, scheduleEvent } from "@trigger.dev/sdk";
new Trigger({
id: "cron-scheduled-workflow",
name: "Cron Scheduled Workflow",
apiKey: "<your_api_key>",
on: scheduleEvent({ cron: "30 14 * * 1" }),
run: async (event, ctx) => {
await ctx.logger.info("Received the cron scheduled event", {
event,
wallTime: new Date(),
});
return { foo: "bar" };
},
}).listen();
```
## Preventing late runs
To prevent a scheduled trigger from running late, you can set a `triggerTTL` option when creating the `Trigger`, like so:
```ts
new Trigger({
id: "scheduled-workflow",
name: "Scheduled Workflow",
apiKey: "<your_api_key>",
on: scheduleEvent({ rateOf: { minutes: 5 } }),
triggerTTL: 300,
run: async (event, ctx) => {
await ctx.logger.info("Received the scheduled event", {
event,
wallTime: new Date(),
});
return { foo: "bar" };
},
}).listen();
```
This will prevent the trigger from running if it is running more than `300` seconds behind, which can happen if the server running your `Trigger` code goes down or is otherwise unavailable.
This is especially useful for scheduled triggers that run on a very short interval, like every minute, so you don't get a backlog of runs that all run at once when the server comes back online.
<Tip>
Set your `triggerTTL` to the same time (or double) as the rateOf the trigger.
</Tip>
## Live-only scheduled events
In many cases, you only want scheduled events to run when your code is running on a server, and not locally during development. To do this, you can check the `context.environment` property together with the `context.isTest` property, like so:
```ts
new Trigger({
id: "check-scheduler",
name: "Check Scheduler",
on: scheduleEvent({ rateOf: { minutes: 10 } }),
logLevel: "info",
triggerTTL: 600,
run: async (event, context) => {
// Return if in development and not running a test
if (context.environment === "development" && !context.isTest) {
return;
}
// do stuff here
},
}).listen();
```
By checking `context.isTest`, you can manually test scheduled events locally before pushing to live.
-117
View File
@@ -1,117 +0,0 @@
---
title: "Webhooks"
sidebarTitle: "Webhooks"
description: "Webhooks allow you to subscribe to events from APIs you use."
---
Webhooks are a crucial part of API development, allowing for real-time reactions to various events across different systems, such as when a Stripe Payment is made, or when a GitHub issue is created.
## Advantages of using Trigger.dev for webhooks
Webhooks can be difficult to work with, especially when developing locally. We make them far easier to use with our [integrations](/integrations/apis).
- You don't need to register/unregister for webhooks, we do it for you
- They work locally during development without needing to use tunnels (e.g. Ngrok)
- We receive the webhook, then keep trying to send it to you until you receive it. If your server goes down, no problem.
## Usage
There are two ways to use webhooks with Trigger.dev:
1. Use one of our built-in integrations, such as [GitHub](/integrations/github). We'll take care of registering the webhook for you.
2. Use our [webhookEvent](/reference/webhook-event) function to create a webhook subscription and you'll register the webhook yourself.
## Webhook integrations
We currently have built in integrations for the following webhooks:
- [GitHub](/integrations/apis/github)
Please [join our discord community](https://discord.gg/kA47vcd8P6) and let us know which integration you'd like us to add.
We've documented all the support webhooks for each integration in the sidebar, for example the GitHub [newStarEvent](/integrations/apis/github/events/new-star) webhook:
```ts
import * as github from "@trigger.dev/github";
new Trigger({
id: "demo",
on: github.events.newStarEvent({
repo: "triggerdotdev/trigger.dev",
}),
run: async (event, ctx) => {},
}).listen();
```
Once you've connected to Trigger.dev, and authorized your GitHub account, we'll go ahead and register the webhook in the repository you've specified and start triggering your `Trigger.run` function when new stars roll in.
## Manual Webhooks
If we haven't built out the integration you need, you can use our `webhookEvent` function to create a webhook subscription. You'll need to register the webhook yourself, but we'll take care of the rest. Here's an example for triggering events when a new booking happens in [Cal.com](https://cal.com):
```ts
new Trigger({
id: "caldotcom-to-slack",
name: "Cal.com To Slack",
on: webhookEvent({
service: "cal.com",
eventName: "BOOKING_CREATED",
filter: {
triggerEvent: ["BOOKING_CREATED"],
},
schema: z.any(),
verifyPayload: {
enabled: true,
header: "X-Cal-Signature-256",
},
}),
run: async (event, ctx) => {},
}).listen();
```
For more information on the various options for `webhookEvent`, see the [webhookEvent reference](/reference/webhook-event).
Once you connect to Trigger.dev, we will display the URL and (optionally) the secret you need to register with the webhook provider on the workflow overview page:
![Webhook URL](/images/webhook-url.png)
Copy the URL and secret, and register the webhook with the provider (in this case, Cal.com). Once you've done that, we'll start triggering your `Trigger.run` function when the webhook fires.
## Examples
<CodeGroup>
```ts Github
import { Trigger } from "@trigger.dev/sdk";
import * as github from "@trigger.dev/github";
import * as slack from "@trigger.dev/slack";
new Trigger({
id: "escalate-critical-issues",
name: "Posts to Slack when GitHub Issue created or modified",
apiKey: "<my_api_key>",
//this is the webhook subscription
on: github.events.issueEvent({
repo: "my-github-org/my-github-repo",
}),
//this function is run when the webhook fires
run: async (event, ctx) => {
if (event.action === "labeled") {
await ctx.logger.info(
`The issue ${event.issue.title} was labeled ${event.label.name}`
);
if (event.label.name === "critical") {
await slack.postMessage("send-to-slack", {
channel: "serious-issues",
text: `Critical issue: ${event.issue.title} was labeled ${event.label.name}`,
});
}
}
return event;
},
}).listen();
```
</CodeGroup>
-55
View File
@@ -1,55 +0,0 @@
---
title: "Trigger.dev Documentation"
sidebarTitle: "Welcome"
description: ""
---
Trigger.dev is an open source platform that enables developers to create event-driven background tasks directly in their code. Build, test and run workflows locally and subscribe to webhooks, schedule jobs, run background jobs and add long delays easily and reliably.
Workflows live in your codebase so you can use your existing types, functions, version control and IDE. They are triggered by us but run on your server so your private data is never exposed.
Go to [trigger.dev](https://app.trigger.dev) and sign up or login to your account.
_A workflow in action:_
![Test a run](/images/workflow-demo.gif)
<iframe
width="100%"
height="440"
src="https://www.youtube.com/embed/aFlwD0frvnQ?rel=0"
title="YouTube video player"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowfullscreen
></iframe>
&nbsp;
<CardGroup>
<Card title="Getting Started" icon="circle-play" href="/getting-started">
Quickly get up and running with Trigger.dev by following our quick start
guide.
</Card>
<Card
title="Examples"
icon="arrow-right-arrow-left"
href="/examples/examples"
>
One of the quickest ways to learn how Trigger.dev works is to view some
example workflows.
</Card>
<Card
title="Join Our Discord"
icon="discord"
href="https://discord.gg/kA47vcd8P6"
>
The #help-and-questions channel is a great place to get help with any
questions about Trigger.dev.
</Card>
<Card
title="Schedule a call"
icon="phone"
href="https://cal.com/team/triggerdotdev/support"
>
Arrange a call with one of the founders. We can help answer questions, build
API integrations for you and help you with workflows.
</Card>
</CardGroup>
+3 -3
View File
@@ -1,7 +1,7 @@
FROM node:16-bullseye AS pruner
RUN apt-get update && apt-get install openssl -y
WORKDIR /app
RUN npm install turbo -g
RUN npm install turbo@1.7.0 -g
COPY . .
RUN turbo prune --scope=webapp --docker
RUN find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
@@ -21,7 +21,7 @@ COPY --from=pruner /app/out/pnpm-workspace.yaml ./pnpm-workspace.yaml
FROM base AS production-deps
WORKDIR /app
RUN npm install turbo -g
RUN npm install turbo@1.7.0 -g
RUN corepack enable
ENV NODE_ENV production
RUN npm config set python /usr/bin/python3
@@ -31,7 +31,7 @@ RUN pnpx prisma generate --schema /app/apps/webapp/prisma/schema.prisma
FROM base AS builder
WORKDIR /app
RUN npm install turbo -g
RUN npm install turbo@1.7.0 -g
COPY turbo.json turbo.json
RUN corepack enable
COPY --from=pruner /app/out/full/ .
+50 -127
View File
@@ -1,150 +1,73 @@
import { Tab } from "@headlessui/react";
import { ArrowTopRightOnSquareIcon } from "@heroicons/react/24/outline";
import type { IntegrationMetadata } from "@trigger.dev/integration-sdk";
import { PopupButton } from "@typeform/embed-react";
import { ApiLogoIcon } from "~/components/code/ApiLogoIcon";
import discord from "../assets/images/discord.png";
import onboarding from "../assets/images/onboarding-image.png";
import { Panel } from "./layout/Panel";
import { PrimaryA, SecondaryA } from "./primitives/Buttons";
import { Body } from "./primitives/text/Body";
import { Underlined, UnderlinedList } from "~/components/primitives/Tabs";
import { useCurrentOrganization } from "~/hooks/useOrganizations";
import CodeBlock from "./code/CodeBlock";
import { PrimaryLink, SecondaryA } from "./primitives/Buttons";
import { SubTitle } from "./primitives/text/SubTitle";
export function CreateNewWorkflow() {
const currentOrganization = useCurrentOrganization();
if (currentOrganization === undefined) {
return <></>;
}
return (
<>
<SubTitle>Create a new workflow</SubTitle>
<div className="flex gap-2">
<PrimaryA
<PrimaryLink
to={`/orgs/${currentOrganization.slug}/workflows/new`}
rel="noreferrer"
>
Create a workflow
</PrimaryLink>
<SecondaryA
href="https://docs.trigger.dev"
target="_blank"
rel="noreferrer"
>
<ArrowTopRightOnSquareIcon className="w-4 h-4" />
<ArrowTopRightOnSquareIcon className="h-4 w-4" />
<span>Documentation</span>
</PrimaryA>
<SecondaryA
href="https://docs.trigger.dev/examples/examples"
target="_blank"
rel="noreferrer"
>
<ArrowTopRightOnSquareIcon className="w-4 h-4" />
<span>Example Workflows</span>
</SecondaryA>
</div>
</>
);
}
export function CreateNewWorkflowNoWorkflows({
providers,
}: {
providers: IntegrationMetadata[];
}) {
export function InstallPackages({ packages }: { packages: string }) {
return (
<>
<Panel className="flex p-0 overflow-hidden">
<div className="flex flex-col p-6 w-full xl:w-2/3 text-slate-300 ">
<Body className="mb-5 max-w-max px-3.5 py-2 bg-slate-700 rounded border border-slate-600">
Trigger.dev workflows are written in your own codebase and run in
your existing infrastructure.
</Body>
<Body size="small" className={allCapsTitleClasses}>
To get started
</Body>
<ol className="flex flex-col gap-2 list-decimal marker:text-slate-400 ml-5 mb-5">
<li>
Check out the Quick Start Guide to create your first workflow in
your code.
</li>
<li>
Trigger the workflow by writing a test on the Test page. The
workflow run will then appear on the Runs page.
</li>
<li>
If you need to authenticate with an API, the Runs page will
display a prompt to connect.
</li>
</ol>
<div className="flex gap-2 mb-8">
<PrimaryA
href="https://docs.trigger.dev/getting-started"
target="_blank"
rel="noreferrer"
>
<ArrowTopRightOnSquareIcon className="w-4 h-4" />
<span>Quick Start Guide</span>
</PrimaryA>
<SecondaryA
href="https://docs.trigger.dev/examples/examples"
target="_blank"
rel="noreferrer"
>
<ArrowTopRightOnSquareIcon className="w-4 h-4" />
<span>Example workflows</span>
</SecondaryA>
</div>
<Body size="small" className={allCapsTitleClasses}>
API integrations
</Body>
<Body className="mb-4">
Easily authenticate with APIs using the supported integrations
below. If there's an integration we don't yet support,{" "}
<PopupButton
id="VwblgGDZ"
className="underline opacity-80 hover:opacity-100 transition underline-offset-2"
>
<span>vote for it here</span>
</PopupButton>{" "}
and we'll add it.
</Body>
<div className="flex gap-2 items-center flex-wrap mb-8">
{providers.map((provider) => (
<ApiLogoIcon
key={provider.slug}
integration={provider}
size="regular"
/>
))}
<Body className="text-slate-300">+</Body>
<Body
size="small"
className="uppercase text-slate-400 bg-slate-850 py-2.5 px-4 rounded tracking-wide"
>
Fetch
</Body>
<Body className="text-slate-300">&</Body>
<Body
size="small"
className="uppercase text-slate-400 bg-slate-850 py-2.5 px-4 rounded tracking-wide"
>
Webhooks
</Body>
</div>
<Body size="small" className={allCapsTitleClasses}>
Join the community
</Body>
<Body className="mb-4">
To get help quickly and answers to any questions, join our Discord.
</Body>
<PrimaryA
href="https://discord.gg/kA47vcd8P6"
target="_blank"
rel="noreferrer"
>
<img src={discord} alt="Discord" className="h-3.5 -ml-1" />
<span>Join Discord</span>
</PrimaryA>
</div>
<div className="hidden xl:flex flex-col w-1/3">
<img
src={onboarding}
alt="Logo"
className="w-full h-full object-cover"
<Tab.Group>
<UnderlinedList>
<Underlined>npm</Underlined>
<Underlined>pnpm</Underlined>
<Underlined>yarn</Underlined>
</UnderlinedList>
<Tab.Panels className="flex-grow">
<Tab.Panel className="relative h-full">
<CodeBlock
code={`npm install ${packages}`}
language="bash"
align="top"
showLineNumbers={false}
/>
</div>
</Panel>
</>
</Tab.Panel>
<Tab.Panel className="relative h-full">
<CodeBlock
code={`pnpm add ${packages}`}
language="bash"
align="top"
showLineNumbers={false}
/>
</Tab.Panel>
<Tab.Panel className="relative h-full">
<CodeBlock
code={`yarn add ${packages}`}
language="bash"
align="top"
showLineNumbers={false}
/>
</Tab.Panel>
</Tab.Panels>
</Tab.Group>
);
}
const allCapsTitleClasses = "mb-2 uppercase tracking-wide text-slate-400";
@@ -7,7 +7,7 @@ type GitHubLoginButtonProps = {
};
export function GitHubLoginButton({
label = "Login with GitHub",
label = "Continue with GitHub",
className,
onClick,
}: GitHubLoginButtonProps) {
@@ -0,0 +1,20 @@
import { TertiaryA } from "./primitives/Buttons";
import { Body } from "./primitives/text/Body";
export function ImpersonationBanner() {
return (
<div className="grid grid-cols-3 items-center bg-gradient-to-r from-amber-500 via-amber-400 to-amber-500 text-center px-4">
<span></span>
<Body size="small" className="text-slate-800">
You are impersonating{" "}
<span className="font-semibold">James Ritchie</span>
</Body>
<TertiaryA
href="/api/auth/logout"
className="justify-self-end text-slate-700 hover:!text-slate-900"
>
Stop impersonating
</TertiaryA>
</div>
);
}
@@ -0,0 +1,21 @@
import { XMarkIcon, DevicePhoneMobileIcon } from "@heroicons/react/24/outline";
import { PrimaryA } from "./primitives/Buttons";
import { Body } from "./primitives/text/Body";
export function NoMobileOverlay() {
return (
<>
<div className="fixed inset-0 z-[9999] flex items-center justify-center sm:hidden">
<div className="relative bg-black opacity-90 h-full w-full"></div>
<div className="absolute flex flex-col gap-6 mx-8 items-center bg-slate-850 px-8 py-10 text-center rounded-lg">
<XMarkIcon className="absolute top-14 h-8 w-8 text-rose-600" />
<DevicePhoneMobileIcon className="h-16 w-16 text-slate-500" />
<Body className="text-slate-300">
Trigger.dev is currently only available on desktop.
</Body>
<PrimaryA href="https://trigger.dev">Back Home</PrimaryA>
</div>
</div>
</>
);
}
@@ -2,6 +2,7 @@ import { useEffect, useRef, useState } from "react";
import Prism from "prismjs";
import "prismjs/components/prism-typescript";
import "prismjs/components/prism-json";
import "prismjs/components/prism-bash";
import "prismjs/plugins/line-numbers/prism-line-numbers";
import "prismjs/plugins/line-numbers/prism-line-numbers.css";
import { CopyTextButton } from "../CopyTextButton";
@@ -11,7 +12,7 @@ Prism.manual = true;
type CodeBlockProps = {
code: string;
language?: "typescript" | "json";
language?: "typescript" | "json" | "bash";
showCopyButton?: boolean;
align?: "top" | "center";
maxHeight?: string;
@@ -60,7 +61,7 @@ export default function CodeBlock({
{showCopyButton === true && (
<CopyTextButton
className={classNames(
"absolute text-sm my-2 mx-2",
"absolute my-2 mx-2 text-sm",
align === "center" ? " top-1/2 right-0" : "top-0 right-0"
)}
value={code}
@@ -68,9 +69,9 @@ export default function CodeBlock({
/>
)}
{maxHeight && (
<div className="absolute left-0 bottom-0 w-full flex items-center justify-center bg-gradient-to-b from-transparent to-[#0F172A]">
<div className="absolute left-0 bottom-0 flex w-full items-center justify-center bg-gradient-to-b from-transparent to-[#0F172A]">
<button
className="bg-slate-800 rounded-full py-2 px-3.5 text-xs mb-1 hover:bg-slate-700 transition"
className="mb-1 rounded-full bg-slate-800 py-2 px-3.5 text-xs transition hover:bg-slate-700"
onClick={(e) => setIsCollapsed((s) => !s)}
>
{isCollapsed ? "Expand" : "Collapse"}
@@ -0,0 +1,8 @@
import type { ReactNode } from "react";
const inlineCode =
"px-1 py-0.5 text-sm bg-slate-700 border border-slate-900 rounded text-slate-200";
export function InlineCode({ children }: { children: ReactNode }) {
return <code className={inlineCode}>{children}</code>;
}
@@ -66,7 +66,7 @@ export function BasicConnectButton({
organizationId={organizationId}
sourceId={sourceId}
serviceId={serviceId}
className="flex rounded bg-indigo-700 gap-3 text-sm text-white items-center hover:bg-indigo-600 transition shadow-md disabled:opacity-50 pl-3 pr-4 py-2"
className="flex items-center gap-3 rounded bg-indigo-700 py-2 pl-3 pr-4 text-sm text-white shadow-md transition hover:bg-indigo-600 disabled:opacity-50"
>
{(status) => (
<>
@@ -28,7 +28,11 @@ export function ConnectOAuthButton({
const { createFetcher, status } = useCreateConnection(sourceId, serviceId);
return (
<createFetcher.Form method="post" action="/resources/connection?index">
<createFetcher.Form
method="post"
action="/resources/connection?index"
className="flex"
>
<input type="hidden" name="type" value="oauth" />
<input type="hidden" name="organizationId" value={organizationId} />
<input type="hidden" name="service" value={integration.slug} />
@@ -1,10 +1,15 @@
import classNames from "classnames";
import { ImpersonationBanner } from "../ImpersonationBanner";
export function AppLayout({ children }: { children: React.ReactNode }) {
return (
<div className="grid grid-rows-[3rem_auto_2rem] w-full h-full">
{children}
</div>
// <div className="grid grid-rows-[2rem_3rem_auto_2rem] w-full h-full">
// <ImpersonationBanner />
// {children}
// </div>
);
}
@@ -1,4 +1,5 @@
import { InformationCircleIcon } from "@heroicons/react/24/solid";
import { Body } from "../primitives/text/Body";
export type PanelInfoProps = {
children: React.ReactNode;
@@ -8,15 +9,20 @@ export type PanelInfoProps = {
export function PanelInfo({
children,
className,
message,
}: {
children: React.ReactNode;
className?: string;
message?: string;
}) {
return (
<div
className={`flex gap-2.5 items-start bg-slate-400/10 border border-slate-600 w-full shadow-md rounded-md p-3 ${className}`}
className={`flex w-full justify-between gap-4 rounded-md border border-slate-600 bg-slate-400/10 py-3 pl-3 pr-3 shadow-md ${className}`}
>
<InformationCircleIcon className="h-6 w-6 min-w-[24px] text-blue-500" />
<div className="flex items-center justify-start gap-2.5">
<InformationCircleIcon className="h-6 w-6 min-w-[24px] text-blue-500" />
<Body className="text-slate-300">{message}</Body>
</div>
{children}
</div>
);
@@ -1,4 +1,5 @@
import { ExclamationTriangleIcon } from "@heroicons/react/24/solid";
import { Body } from "../primitives/text/Body";
export type PanelWarningProps = {
children: React.ReactNode;
@@ -8,15 +9,20 @@ export type PanelWarningProps = {
export function PanelWarning({
children,
className,
message,
}: {
children: React.ReactNode;
children?: React.ReactNode;
className?: string;
message: string;
}) {
return (
<div
className={`flex gap-2.5 items-center bg-amber-400/10 border border-amber-500 w-full shadow-md rounded-md p-3 ${className}`}
className={`flex w-full items-center rounded-md border border-amber-500 bg-amber-400/10 p-3 shadow-md ${className}`}
>
<ExclamationTriangleIcon className="h-6 w-6 min-w-[24px] text-amber-500" />
<div className="flex items-center gap-2.5">
<ExclamationTriangleIcon className="h-6 w-6 min-w-[24px] text-amber-500" />
<Body className="">{message}</Body>
</div>
{children}
</div>
);
@@ -11,6 +11,7 @@ import {
ClipboardDocumentCheckIcon,
Squares2X2Icon,
Cog6ToothIcon,
PlusCircleIcon,
} from "@heroicons/react/24/outline";
import { Link, NavLink } from "@remix-run/react";
import {
@@ -24,7 +25,7 @@ import invariant from "tiny-invariant";
import { CopyText } from "../CopyText";
export function SideMenuContainer({ children }: { children: React.ReactNode }) {
return <div className="grid grid-cols-[300px_2fr] h-full">{children}</div>;
return <div className="grid h-full grid-cols-[300px_2fr]">{children}</div>;
}
type SideMenuItem = {
@@ -59,6 +60,11 @@ export function OrganizationsSideMenu() {
icon: <UsersIcon className={iconStyle} />,
to: `/orgs/${currentOrganization.slug}/members`,
},
{
name: "New Workflow",
icon: <PlusCircleIcon className={iconStyle} />,
to: `/orgs/${currentOrganization.slug}/workflows/new`,
},
];
return (
@@ -129,24 +135,24 @@ function SideMenu({
invariant(organization, "Organization must be defined");
return (
<div className="flex min-h-0 flex-1 flex-col bg-slate-950 border-r border-slate-800">
<div className="flex min-h-0 flex-1 flex-col border-r border-slate-800 bg-slate-950">
<div className="flex flex-1 flex-col overflow-y-auto pb-4">
<nav
className="mt-2 flex flex-col h-full justify-between space-y-1 px-2"
className="mt-2 flex h-full flex-col justify-between space-y-1 px-2"
aria-label="Sidebar"
>
<div>
<div className="group flex items-center my-2 text-slate-400 rounded hover:bg-slate-950 border border-transparent hover:border-slate-800 transition divide-x divide-transparent hover:divide-slate-900">
<div className="group my-2 flex items-center divide-x divide-transparent rounded border border-transparent text-slate-400 transition hover:divide-slate-900 hover:border-slate-800 hover:bg-slate-950">
<Link
to={backPath}
className="px-2 py-3 hover:bg-slate-800 rounded-l transition"
className="rounded-l px-2 py-3 transition hover:bg-slate-800"
>
<ChevronLeftIcon className="h-5 w-5 text-slate-400" />
</Link>
<Header1
size="small"
className="pl-2 py-2 w-full text-slate-400 rounded-r hover:bg-slate-800 transition whitespace-nowrap text-ellipsis overflow-hidden"
className="w-full overflow-hidden text-ellipsis whitespace-nowrap rounded-r py-2 pl-2 text-slate-400 transition hover:bg-slate-800"
>
<Link to="">{title}</Link>
</Header1>
@@ -167,17 +173,17 @@ function SideMenu({
))}
</div>
<div className="flex flex-col gap-6">
<ul className="flex flex-col gap-6 ml-3 mr-2">
<ul className="ml-3 mr-2 flex flex-col gap-6">
{organization.environments.map((environment) => {
return (
<li
key={environment.id}
className="flex flex-col gap-1.5 justify-between w-full"
className="flex w-full flex-col justify-between gap-1.5"
>
<div className="flex justify-between">
<Body
size="extra-small"
className={`text-slate-300 overflow-hidden ${menuSmallTitleStyle}`}
className={`overflow-hidden text-slate-300 ${menuSmallTitleStyle}`}
>
{environment.slug} api key
</Body>
@@ -186,11 +192,11 @@ function SideMenu({
value={environment.apiKey}
/> */}
</div>
<div className="relative overflow-hidden text-sm select-all text-slate-400 p-1 pl-2 rounded-sm border border-slate-800">
<span className="block absolute pointer-events-none right-7 top-0 bg-gradient-to-r from-transparent to-slate-950 w-20 h-6"></span>
<div className="relative select-all overflow-hidden rounded-sm border border-slate-800 p-1 pl-2 text-sm text-slate-400">
<span className="pointer-events-none absolute right-7 top-0 block h-6 w-20 bg-gradient-to-r from-transparent to-slate-950"></span>
<CopyText
value={environment.apiKey}
className="group absolute flex right-0 top-0 items-center justify-center rounded-sm w-7 h-full bg-slate-950 border-l border-slate-800 hover:bg-slate-900 transition hover:cursor-pointer active:bg-green-900"
className="group absolute right-0 top-0 flex h-full w-7 items-center justify-center rounded-sm border-l border-slate-800 bg-slate-950 transition hover:cursor-pointer hover:bg-slate-900 active:bg-green-900"
>
<ClipboardDocumentCheckIcon className="h-5 w-5 group-active:text-green-500" />
</CopyText>
@@ -200,7 +206,7 @@ function SideMenu({
);
})}
</ul>
<ul className="flex flex-col gap-3 ml-3">
<ul className="ml-3 flex flex-col gap-3">
<li>
<Body size="extra-small" className={menuSmallTitleStyle}>
Help and resources
+40 -7
View File
@@ -34,7 +34,7 @@ export function Classic({ children, ...props }: HeadlessTabProps) {
export function UnderlinedList({ children, ...props }: HeadlessTabListProps) {
return (
<HeadlessTab.List
className={"-mb-px flex space-x-4 border-b border-slate-200"}
className={"-mb-px flex space-x-4 border-b border-slate-700"}
{...props}
>
{children}
@@ -48,10 +48,10 @@ export function Underlined({ children, ...props }: HeadlessTabProps) {
className={({ selected }: { selected: boolean }) =>
classnames(
selected
? "border-blue-500 text-slate-900 outline-none"
: "border-transparent text-slate-800 hover:border-slate-200 hover:text-slate-700",
? "border-slate-300 text-slate-300 outline-none"
: "border-transparent text-slate-400 hover:border-slate-200 hover:text-slate-200",
"disabled:text-slate-300 disabled:hover:border-transparent",
"flex whitespace-nowrap border-b-2 py-2 px-4 text-xs font-medium"
"flex whitespace-nowrap border-b-2 py-2 px-4 text-base font-medium transition"
)
}
{...props}
@@ -69,7 +69,7 @@ export function SegmentedList({
return (
<HeadlessTab.List
className={classNames(
"flex ml-8 gap-0.5 max-w-fit bg-slate-200 rounded-md p-0.5 border border-slate-300",
"flex max-w-fit gap-0.5 rounded-md bg-slate-800 p-1",
className
)}
{...props}
@@ -85,8 +85,8 @@ export function Segmented({ children, ...props }: HeadlessTabProps) {
className={({ selected }: { selected: boolean }) =>
classnames(
selected
? "bg-blue-500 text-white rounded shadow outline-none"
: "text-slate-800 hover:bg-slate-300 rounded hover:text-slate-700 hover:shadow-none transition",
? "rounded bg-indigo-600 text-white shadow outline-none"
: "rounded text-slate-300 transition hover:bg-slate-700 hover:text-slate-300 hover:shadow-none",
"flex whitespace-nowrap py-2 px-4 text-xs font-medium"
)
}
@@ -96,3 +96,36 @@ export function Segmented({ children, ...props }: HeadlessTabProps) {
</HeadlessTab>
);
}
export function LargeBoxList({
children,
className,
...props
}: HeadlessTabListProps) {
return (
<HeadlessTab.List
className={classNames("grid grid-cols-carousel gap-2", className)}
{...props}
>
{children}
</HeadlessTab.List>
);
}
export function LargeBox({ children, ...props }: HeadlessTabProps) {
return (
<HeadlessTab
className={({ selected }: { selected: boolean }) =>
classnames(
selected
? "bg-slate-800 text-white shadow outline-none"
: "text-slate-300 transition hover:bg-slate-800/50 hover:text-slate-300 hover:shadow-none",
"flex flex-col items-center justify-center gap-4 rounded border border-slate-700 py-6 px-4 text-base font-medium"
)
}
{...props}
>
{children}
</HeadlessTab>
);
}
@@ -1,8 +1,14 @@
import { Header2 } from "./Headers";
export function SubTitle({ children }: { children: React.ReactNode }) {
export function SubTitle({
children,
className,
}: {
children: React.ReactNode;
className?: string;
}) {
return (
<Header2 size="small" className="mb-2 text-slate-400">
<Header2 size="small" className={`mb-2 text-slate-400 ${className}`}>
{children}
</Header2>
);
@@ -97,10 +97,10 @@ export function RunsTable({
})
)}
{isLoading && (
<tr className="absolute top-0 left-0 w-full h-full bg-slate-800/90">
<tr className="absolute top-0 left-0 h-full w-full bg-slate-800/90">
<td
colSpan={6}
className="flex items-center justify-center gap-2 text-white h-full"
className="flex h-full items-center justify-center gap-2 text-white"
>
<Spinner /> Loading
</td>
@@ -125,7 +125,7 @@ function Cell({
alignment?: "left" | "right";
}) {
return (
<td className="group-hover:bg-slate-850/50 transition cursor-pointer">
<td className="cursor-pointer transition group-hover:bg-slate-850/50">
<Link
to={to}
className={classNames(
@@ -142,7 +142,7 @@ function Cell({
function BlankRow({ children }: { children: ReactNode }) {
return (
<tr>
<td colSpan={6} className="py-6 text-sm text-center">
<td colSpan={6} className="py-6 text-center text-sm">
{children}
</td>
</tr>
@@ -152,7 +152,7 @@ function BlankRow({ children }: { children: ReactNode }) {
export function NoRuns({ title }: { title: string }) {
return (
<div className="flex items-center justify-center">
<PanelWarning className="max-w-max">{title}</PanelWarning>
<PanelWarning message={title} className="max-w-max" />
</div>
);
}
@@ -0,0 +1,20 @@
export function customEvent(apiKey: string) {
return `import { customEvent, Trigger } from "@trigger.dev/sdk";
import { z } from "zod";
new Trigger({
id: "user-created-notify-slack",
name: "User Created - Notify Slack",
// For security, we recommend moving this api key to your .env / secrets file.
// Our env variable is called TRIGGER_API_KEY
apiKey: "${apiKey}",
on: customEvent({
name: "user.created",
schema: z.object({ id: z.string(), admin: z.boolean() }),
filter: {
admin: [false],
},
}),
run: async (event, ctx) => {},
}).listen();`;
}
@@ -0,0 +1,25 @@
export function githubIssues(apiKey: string) {
return `import { Trigger } from "@trigger.dev/sdk";
import * as github from "@trigger.dev/github";
import * as slack from "@trigger.dev/slack";
new Trigger({
id: "github-issues-to-slack",
name: "Posts to Slack when GitHub Issue created or modified",
// For security, we recommend moving this api key to your .env / secrets file.
// Our env variable is called TRIGGER_API_KEY
apiKey: "${apiKey}",
on: github.events.issueEvent({
repo: "my-github-org/my-github-repo",
}),
run: async (event, ctx) => {
const response = await slack.postMessage("send-to-slack", {
channelName: "my-slack-channel-name",
text: \`A new issue has been created or modified. \${event.action}\`,
});
return response.message;
},
}).listen();`;
}
@@ -0,0 +1,22 @@
export function githubStars(apiKey: string) {
return `import { Trigger } from "@trigger.dev/sdk";
import * as github from "@trigger.dev/github";
import * as slack from "@trigger.dev/slack";
new Trigger({
id: "new-github-star-to-slack",
name: "New GitHub Star: triggerdotdev/trigger.dev",
// For security, we recommend moving this api key to your .env / secrets file.
// Our env variable is called TRIGGER_API_KEY
apiKey: "${apiKey}",
on: github.events.newStarEvent({
repo: "triggerdotdev/trigger.dev",
}),
run: async (event) => {
await slack.postMessage("github-stars", {
channelName: "github-stars",
text: \`New GitHub star from \n<\${event.sender.html_url}|\${event.sender.login}>\`,
});
},
}).listen();`;
}
@@ -0,0 +1,34 @@
export function newUserSlackMessage(apiKey: string) {
return `import { Trigger, customEvent } from "@trigger.dev/sdk";
import { postMessage } from "@trigger.dev/slack";
import { z } from "zod";
new Trigger({
id: "new-user",
name: "New user slack message",
// For security, we recommend moving this api key to your .env / secrets file.
// Our env variable is called TRIGGER_API_KEY
apiKey: "${apiKey}",
on: customEvent({
name: "user.created",
schema: z.object({
name: z.string(),
email: z.string(),
paidPlan: z.boolean(),
}),
}),
run: async (event, ctx) => {
await ctx.logger.info("This log will appear on the Trigger.dev run page");
//send a message to the #new-users Slack channel with user details
const response = await postMessage("send-to-slack", {
channel: "new-users",
text: \`New user: \${event.name} (\${event.email}) signed up. \${
event.paidPlan ? "They are paying" : "They are on the free plan"
}.\`,
});
return response.message;
},
}).listen();`;
}
@@ -1,23 +1,5 @@
---
title: "Resend"
sidebarTitle: "Resend"
description: "Here are some example workflows you could create using the Resend integration."
---
<Tip>
Resend is in private beta, if you would like access please contact us at{" "}
<a href="mailto:help@trigger.dev">help@trigger.dev</a>
</Tip>
## Welcome email drip campaign
This workflow will get triggered and a Slack notification and welcom email will be sent straight away.
1 day later we check if the user has completed onboarding, if they have, they get a 'tips' email, otherwise they get a re-engagement email.
Integrations required: Resend, Slack
```ts
import { customEvent, Trigger, sendEvent } from "@trigger.dev/sdk";
export function resendEmailDripCampaign(apiKey: string) {
return `import { customEvent, Trigger, sendEvent } from "@trigger.dev/sdk";
import * as resend from "@trigger.dev/resend";
import * as slack from "@trigger.dev/slack";
import React from "react";
@@ -28,7 +10,9 @@ import { InactiveEmail, TipsEmail, WelcomeEmail } from "./email-templates";
new Trigger({
id: "welcome-email-campaign",
name: "Welcome email drip campaign",
apiKey: "<my_api_key>",
// For security, we recommend moving this api key to your .env / secrets file.
// Our env variable is called TRIGGER_API_KEY
apiKey: "${apiKey}",
on: customEvent({
name: "user.created",
schema: z.object({
@@ -41,7 +25,7 @@ new Trigger({
await slack.postMessage("send-to-slack", {
channelName: "new-users",
text: `New user signed up: ${user.name} (${user.email})`,
text: \`New user signed up: \${user.name} (\${user.email})\`,
});
//Send the first email
@@ -53,7 +37,8 @@ new Trigger({
react: <WelcomeEmail name={user.name} />,
});
await context.logger.debug(
`Sent welcome email to ${welcomeResponse.to} with id ${welcomeResponse.id}`
\`Sent welcome email to \${welcomeResponse.to} with id \${welcomeResponse.id}
\`
);
//wait 1 day, check if the user has created a workflow and send the appropriate email
@@ -78,5 +63,6 @@ new Trigger({
});
}
},
}).listen();
```
}).listen();`;
}
@@ -0,0 +1,132 @@
import {
StarIcon,
EnvelopeIcon,
ShoppingCartIcon,
ChatBubbleOvalLeftEllipsisIcon,
UserIcon,
DocumentTextIcon,
} from "@heroicons/react/24/outline";
import { customEvent } from "./custom-event";
import { githubIssues } from "./github-issues";
import { githubStars } from "./github-stars";
import { newUserSlackMessage } from "./new-user-slack-message";
import { resendEmailDripCampaign } from "./resend-email-drip-campaign";
import { shopifyCreateNewProducts } from "./shopify-create-new-product";
import { webhook } from "./webhook";
import { scheduled } from "./scheduled";
import { whatsappListenForMessageAndReply } from "./whatsapp-listen-for-message-and-reply";
import { scheduledCron } from "./scheduled-cron";
export const exampleProjects = [
{
icon: <StarIcon className="h-8 w-8 text-yellow-400" />,
name: "GitHub star → Slack",
title: "When you receive a GitHub star, post that user's details to Slack",
description:
"This workflow is triggered when a GitHub user adds a star to a repository. The user's details will then be posted in a specific Slack channel.",
requiredPackages: "@trigger.dev/github @trigger.dev/slack zod",
code: githubStars,
},
{
icon: <EnvelopeIcon className="h-8 w-8 text-blue-400" />,
name: "New user → email",
title:
"When a new user signs up, post a message to Slack and send them a series of emails",
description:
"This workflow is triggered when a new user signs up. A welcome email is sent straight away and an alert is sent to a specific Slack channel. 1 day later it checks if the user has completed the onboarding, if they have, they get a tips email, otherwise they get a re-engagement email.",
requiredPackages: "@trigger.dev/resend @trigger.dev/slack zod",
code: resendEmailDripCampaign,
},
{
icon: <UserIcon className="h-8 w-8 text-rose-400" />,
name: "New user → Slack",
title: "When a new user signs up, post a message to Slack",
description:
"This workflow is triggered when a new user signs up. The user's details will then be posted in a specific Slack channel.",
requiredPackages: "@trigger.dev/slack zod",
code: newUserSlackMessage,
},
{
icon: <ShoppingCartIcon className="h-8 w-8 text-purple-400" />,
name: "New item → Shopify",
title: "When a custom event is triggered, create a new product in Shopify",
description:
"This workflow is triggered by a custom event. Once it is triggered, a new product is created in Shopify with the specified details.",
requiredPackages: "@trigger.dev/shopify zod",
code: shopifyCreateNewProducts,
packagesCopy: "Shopify",
},
{
icon: <DocumentTextIcon className="h-8 w-8 text-orange-400" />,
name: "GitHub issue → Slack",
title: "When a GitHub issue is created or modified, post it to Slack",
description:
"This workflow is triggered when a new issue is created or modified in GitHub. The issue will then be posted in a specific Slack channel.",
requiredPackages: "@trigger.dev/github @trigger.dev/slack zod",
code: githubIssues,
},
{
icon: <ChatBubbleOvalLeftEllipsisIcon className="h-8 w-8 text-green-400" />,
name: "WhatsApp → Slack",
title: "Listen for WhatsApp messages and automatically reply",
description:
"This workflow is triggered when a WhatsApp message has been received. When received, a pre-determined reply is sent.",
requiredPackages: "@trigger.dev/whatsapp zod",
code: whatsappListenForMessageAndReply,
packagesCopy: "WhatsApp",
},
];
export const fromScratchProjects = [
{
name: "Webhook",
requiredPackages: "@trigger.dev/sdk zod",
code: webhook,
docsLink: "https://docs.trigger.dev/triggers/webhooks",
description:
"Webhooks allow you to subscribe to events from APIs but can be difficult to work with, especially when developing locally. Trigger.dev makes using webhooks easy:",
bulletPoint1:
"You dont need to register/unregister for webhooks, we do it for you.",
bulletPoint2:
"They work locally during development without needing to use tunnels (e.g. Ngrok).",
bulletPoint3:
"We receive the webhook, then keep trying to send it to you until you receive it. If your server goes down, no problem.",
},
{
name: "Custom event",
requiredPackages: "@trigger.dev/sdk zod",
code: customEvent,
docsLink: "https://docs.trigger.dev/triggers/custom-events",
description:
"Custom event triggers allow you to run workflows from your own code (or your other workflows). Send an event and any workflows that subscribe to that custom event will get triggered. You can easily send an event from anywhere, including from inside another workflow. Events dont have to come from the same server as your workflow and can be sent as HTTP requests from any language.",
bulletPoint1: "",
bulletPoint2: "",
bulletPoint3: "",
},
{
name: "Scheduled (recurring)",
requiredPackages: "@trigger.dev/sdk zod",
code: scheduled,
docsLink: "https://docs.trigger.dev/triggers/scheduled",
description:
"Run a workflow on a recurring schedule. The example below will run every 5 minutes, starting 5 minutes after this code is first run on your server (that includes running locally).",
bulletPoint1: "",
bulletPoint2: "",
bulletPoint3: "",
},
{
name: "Scheduled (CRON)",
requiredPackages: "@trigger.dev/sdk zod",
code: scheduledCron,
docsLink: "https://docs.trigger.dev/triggers/scheduled",
description:
"Run a workflow on a recurring schedule. The example job below will run at 2:30pm every Monday.",
bulletPoint1: "",
bulletPoint2: "",
bulletPoint3: "",
},
];
@@ -0,0 +1,20 @@
export function scheduledCron(apiKey: string) {
return `import { Trigger, scheduleEvent } from "@trigger.dev/sdk";
new Trigger({
id: "cron-scheduled-workflow",
name: "Cron Scheduled Workflow",
// For security, we recommend moving this api key to your .env / secrets file.
// Our env variable is called TRIGGER_API_KEY
apiKey: "${apiKey}",
on: scheduleEvent({ cron: "30 14 * * 1" }),
run: async (event, ctx) => {
await ctx.logger.info("Received the cron scheduled event", {
event,
wallTime: new Date(),
});
return { foo: "bar" };
},
}).listen();`;
}
@@ -0,0 +1,20 @@
export function scheduled(apiKey: string) {
return `import { Trigger, scheduleEvent } from "@trigger.dev/sdk";
new Trigger({
id: "scheduled-workflow",
name: "Scheduled Workflow",
// For security, we recommend moving this api key to your .env / secrets file.
// Our env variable is called TRIGGER_API_KEY
apiKey: "${apiKey}",
on: scheduleEvent({ rateOf: { minutes: 5 } }),
run: async (event, ctx) => {
await ctx.logger.info("Received the scheduled event", {
event,
wallTime: new Date(),
});
return { foo: "bar" };
},
}).listen();`;
}
@@ -0,0 +1,62 @@
export function shopifyCreateNewProducts(apiKey: string) {
return `import { Trigger, customEvent } from "@trigger.dev/sdk";
import { z } from "zod";
import * as shopify from "@trigger.dev/shopify";
new Trigger({
id: "shopify-products",
name: "Shopify products",
// For security, we recommend moving this api key to your .env / secrets file.
// Our env variable is called TRIGGER_API_KEY
apiKey: "${apiKey}",
on: customEvent({
name: "shopify.products",
schema: z.object({}),
}),
run: async (event, ctx) => {
const newProduct = await shopify.createProduct("create-product", {
descriptionHtml: "This is my brilliant <i>product description</i>.",
title: \`Fantastic product \${Math.floor(Math.random() * 1000)}\`,
productType: "t-shirt",
vendor: "Nike",
options: ["Color", "Size"],
standardizedProductType: {
productTaxonomyNodeId: "gid://shopify/ProductTaxonomyNode/352",
},
variants: [
{
price: "99.99",
sku: "variant-1",
inventoryItem: {
tracked: true,
},
inventoryQuantities: [
{
availableQuantity: 1,
locationId: "gid://shopify/Location/76187369773",
},
],
options: ["Maroon", "Tiny"],
},
],
});
const newImages = await shopify.appendProductImages("append-images", {
id: newProduct.id,
images: [
{
src: "https://via.placeholder.com/600/92c952.png",
altText: "Image 1",
},
{
src: "https://via.placeholder.com/600/d32776.png",
altText: "Image 2",
},
],
});
return newProduct;
},
}).listen();
`;
}
@@ -0,0 +1,25 @@
export function webhook(apiKey: string) {
return `import { webhookEvent, Trigger } from "@trigger.dev/sdk";
import { z } from "zod";
new Trigger({
id: "caldotcom-to-slack",
name: "Cal.com To Slack",
// For security, we recommend moving this api key to your .env / secrets file.
// Our env variable is called TRIGGER_API_KEY
apiKey: "${apiKey}",
on: webhookEvent({
service: "cal.com",
eventName: "BOOKING_CREATED",
filter: {
triggerEvent: ["BOOKING_CREATED"],
},
schema: z.any(),
verifyPayload: {
enabled: true,
header: "X-Cal-Signature-256",
},
}),
run: async (event, ctx) => {},
}).listen();`;
}
@@ -0,0 +1,39 @@
export function whatsappListenForMessageAndReply(apiKey: string) {
return `import { Trigger } from "@trigger.dev/sdk";
import { events, sendReaction, sendText } from "@trigger.dev/whatsapp";
new Trigger({
id: "whatsapp-webhook",
name: "Listen for WhatsApp messages and reply",
// For security, we recommend moving this api key to your .env / secrets file.
// Our env variable is called TRIGGER_API_KEY
apiKey: "${apiKey}",
//this listens for all WhatsApp messages sent to your WhatsApp Business account
on: events.messageEvent({
accountId: "<your_account_id>",
}),
run: async (event, ctx) => {
//these logs will appear on the run page
await ctx.logger.info(\`Message data\`, event.message);
await ctx.logger.info(\`Phone number\`, event.contacts[0]);
//add a 🥰 reaction to the original message
const reactionResponse = await sendReaction("reaction", {
fromId: event.metadata.phone_number_id,
to: event.message.from,
isReplyTo: event.message.id,
emoji: "🥰",
});
//send a text message in response
const textResponse = await sendText("text-msg", {
fromId: event.metadata.phone_number_id,
to: event.message.from,
text: "Hello! This is a text sent automatically from https://www.trigger.dev",
});
//we support all other types of WhatsApp messages (audio, video, document, location, etc)
},
}).listen();`;
}
+30 -16
View File
@@ -46,22 +46,36 @@ function SlackInteraction({
{trigger.name}
</Header2>
</div>
<div className="flex gap-2 items-baseline">
<Body size="extra-small" className={workflowNodeUppercaseClasses}>
Block
</Body>
<Header2 size="small" className="text-slate-300 mb-2">
{trigger.source.blockId}
</Header2>
</div>
<div className="flex gap-2 items-baseline">
<Body size="extra-small" className={workflowNodeUppercaseClasses}>
Action
</Body>
<Header2 size="small" className="text-slate-300 mb-2">
{trigger.source.actionIds.join(", ")}
</Header2>
</div>
{trigger.source.type === "block_action" && (
<div className="flex gap-2 items-baseline">
<Body size="extra-small" className={workflowNodeUppercaseClasses}>
Block
</Body>
<Header2 size="small" className="text-slate-300 mb-2">
{trigger.source.blockId}
</Header2>
</div>
)}
{trigger.source.type === "block_action" && (
<div className="flex gap-2 items-baseline">
<Body size="extra-small" className={workflowNodeUppercaseClasses}>
Action
</Body>
<Header2 size="small" className="text-slate-300 mb-2">
{trigger.source.actionIds.join(", ")}
</Header2>
</div>
)}
{trigger.source.type === "view_submission" && (
<div className="flex gap-2 items-baseline">
<Body size="extra-small" className={workflowNodeUppercaseClasses}>
Callback IDs
</Body>
<Header2 size="small" className="text-slate-300 mb-2">
{trigger.source.callbackIds.join(", ")}
</Header2>
</div>
)}
</div>
);
}
+1 -18
View File
@@ -2,25 +2,8 @@ import { RemixBrowser, useLocation, useMatches } from "@remix-run/react";
import { hydrateRoot } from "react-dom/client";
import * as Sentry from "@sentry/remix";
import { useEffect } from "react";
import { startTransition, StrictMode } from "react";
const hydrate = () =>
startTransition(() => {
hydrateRoot(
document,
<StrictMode>
<RemixBrowser />
</StrictMode>
);
});
if (window.requestIdleCallback) {
window.requestIdleCallback(hydrate);
} else {
// Safari doesn't support requestIdleCallback
// https://caniuse.com/requestidlecallback
window.setTimeout(hydrate, 1);
}
hydrateRoot(document, <RemixBrowser />);
if (process.env.NODE_ENV === "production") {
Sentry.init({
+15 -100
View File
@@ -1,114 +1,29 @@
import * as Sentry from "~/services/sentry.server";
import * as MessageBroker from "~/services/messageBroker.server";
import { PassThrough } from "stream";
import type { EntryContext } from "@remix-run/node";
import { Response } from "@remix-run/node";
import { RemixServer } from "@remix-run/react";
import isbot from "isbot";
import { renderToPipeableStream } from "react-dom/server";
import { renderToString } from "react-dom/server";
import * as MessageBroker from "~/services/messageBroker.server";
import * as Sentry from "~/services/sentry.server";
const ABORT_DELAY = 5000;
const handleRequest = (
export default function handleRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext
) =>
isbot(request.headers.get("user-agent"))
? handleBotRequest(
request,
responseStatusCode,
responseHeaders,
remixContext
)
: handleBrowserRequest(
request,
responseStatusCode,
responseHeaders,
remixContext
);
export default handleRequest;
) {
// deepcode ignore Ssti: <This is recommended by Remix>
const markup = renderToString(
// deepcode ignore OR: <All good in the hood>
<RemixServer context={remixContext} url={request.url} />
);
const handleBotRequest = (
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext
) =>
new Promise((resolve, reject) => {
let didError = false;
responseHeaders.set("Content-Type", "text/html; charset=utf-8");
const { pipe, abort } = renderToPipeableStream(
<RemixServer context={remixContext} url={request.url} />,
{
onAllReady: () => {
const body = new PassThrough();
responseHeaders.set("Content-Type", "text/html");
resolve(
new Response(body, {
headers: responseHeaders,
status: didError ? 500 : responseStatusCode,
})
);
pipe(body);
},
onShellError: (error: unknown) => {
reject(error);
},
onError: (error: unknown) => {
didError = true;
console.error(error);
},
}
);
setTimeout(abort, ABORT_DELAY);
});
const handleBrowserRequest = (
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext
) =>
new Promise((resolve, reject) => {
let didError = false;
const { pipe, abort } = renderToPipeableStream(
<RemixServer context={remixContext} url={request.url} />,
{
onShellReady: () => {
const body = new PassThrough();
responseHeaders.set("Content-Type", "text/html");
resolve(
new Response(body, {
headers: responseHeaders,
status: didError ? 500 : responseStatusCode,
})
);
pipe(body);
},
onShellError: (error: unknown) => {
reject(error);
},
onError: (error: unknown) => {
didError = true;
console.error(error);
},
}
);
setTimeout(abort, ABORT_DELAY);
return new Response("<!DOCTYPE html>" + markup, {
status: responseStatusCode,
headers: responseHeaders,
});
}
Sentry.init();
MessageBroker.init();
+8
View File
@@ -17,6 +17,14 @@ const EnvironmentSchema = z.object({
// eslint-disable-next-line turbo/no-undeclared-env-vars
.default(process.env.FC_URL ?? "https://app.trigger.dev"),
SENTRY_DSN: z.string().optional(),
APP_ENV: z
.union([
z.literal("development"),
z.literal("production"),
z.literal("test"),
z.literal("staging"),
])
.default(process.env.NODE_ENV),
POSTHOG_PROJECT_KEY: z.string().optional(),
MAGIC_LINK_SECRET: z.string(),
GITHUB_CLIENT_ID: z.string(),
+1 -3
View File
@@ -36,9 +36,7 @@ export function useEnvironments(): RuntimeEnvironment[] | undefined {
export function useCurrentEnvironment(): RuntimeEnvironment | undefined {
const environments = useEnvironments();
const routeMatch = useMatchesData(
"routes/__app/orgs/$organizationSlug/workflows/$workflowSlug"
);
const routeMatch = useMatchesData("routes/__app/orgs/$organizationSlug");
const currentEnvironmentSlug = routeMatch?.data.currentEnvironmentSlug;
if (!currentEnvironmentSlug || !environments) {
@@ -1,6 +1,7 @@
import type { APIConnection, Organization } from ".prisma/client";
import { z } from "zod";
import { prisma } from "~/db.server";
import { Workflow } from "./workflow.server";
export { APIConnection };
@@ -117,3 +118,43 @@ export async function updateApiConnectionTitle({
},
});
}
export async function getApiConnectionsForWorkflow({
workflowId,
}: {
workflowId: Workflow["id"];
}) {
const workflow = await prisma.workflow.findUnique({
where: {
id: workflowId,
},
select: {
externalSource: {
select: {
service: true,
connection: true,
},
},
externalServices: {
select: {
service: true,
connection: true,
},
},
},
});
if (!workflow) return [];
let connections: APIConnection[] = [];
if (workflow.externalSource?.connection) {
connections.push(workflow.externalSource.connection);
}
workflow.externalServices.forEach((s) => {
if (s.connection) {
connections.push(s.connection);
}
});
return connections;
}
@@ -243,17 +243,36 @@ function triggerProperties(
};
}
const slackSource = SlackInteractionSourceSchema.parse(
const slackSource = SlackInteractionSourceSchema.safeParse(
internalSource.source
);
if (!slackSource.success) {
return {
type: workflow.type,
typeTitle: "Slack interaction",
title: "on: Slack interaction",
};
}
const title =
slackSource.data.type === "block_action"
? `block_id = ${slackSource.data.blockId}`
: `callback_id = ${slackSource.data.callbackIds.join(", ")}`;
return {
type: workflow.type,
typeTitle: "Slack interaction",
title: `block_id = ${slackSource.blockId}`,
title: title,
properties:
slackSource.actionIds.length > 0
? [{ key: "Action ID", value: slackSource.actionIds.join(", ") }]
slackSource.data.type === "block_action" &&
slackSource.data.actionIds.length > 0
? [
{
key: "Action ID",
value: slackSource.data.actionIds.join(", "),
},
]
: undefined,
};
}
@@ -89,6 +89,13 @@ async function parseStep(
status: original.status,
};
switch (original.type) {
case "RUN_ONCE":
return {
...base,
type: "RUN_ONCE" as const,
output: original.output,
idempotencyKey: original.id,
};
case "LOG_MESSAGE":
return {
...base,
@@ -64,3 +64,23 @@ export async function createStepOnce(
throw e;
}
}
export async function findWorkflowStepById(stepId: string) {
return prisma.workflowRunStep.findUnique({
where: {
id: stepId,
},
include: {
run: {
include: {
workflow: true,
environment: {
include: {
organization: true,
},
},
},
},
},
});
}
@@ -0,0 +1,87 @@
import type { PrismaClient } from "~/db.server";
import { prisma } from "~/db.server";
import { JSONSchemaFaker } from "json-schema-faker";
import type { Workflow, WorkflowRun } from ".prisma/client";
export class WorkflowTestPresenter {
#prismaClient: PrismaClient;
constructor(prismaClient: PrismaClient = prisma) {
this.#prismaClient = prismaClient;
}
async data({
organizationSlug,
workflowSlug,
environmentSlug,
}: {
organizationSlug: string;
workflowSlug: string;
environmentSlug: string;
}) {
const workflow = await this.#prismaClient.workflow.findFirst({
where: {
slug: workflowSlug,
organization: {
slug: organizationSlug,
},
},
include: {
runs: {
where: {
environment: {
slug: environmentSlug,
},
},
include: {
event: true,
},
orderBy: {
createdAt: "desc",
},
take: 1,
},
externalSource: true,
},
});
if (!workflow) {
throw new Error("Workflow not found");
}
const payload = await this.#getPayload(workflow, workflow.runs[0]);
const status =
workflow.status === "CREATED"
? workflow.type === "WEBHOOK" &&
workflow.externalSource?.manualRegistration
? "TESTABLE"
: "CREATED"
: workflow.status;
return { payload, status };
}
async #getPayload(
workflow: Workflow,
lastRun?: WorkflowRun & { event: { payload: any } }
) {
if (workflow.type === "SCHEDULE") {
return {
scheduledTime: new Date(),
lastRunAt: lastRun?.startedAt ?? undefined,
};
}
if (lastRun) {
return lastRun.event.payload;
}
if (workflow.jsonSchema) {
// @ts-ignore
return JSONSchemaFaker.generate(workflow.jsonSchema);
}
return {};
}
}
+29 -7
View File
@@ -7,6 +7,10 @@ import { getOrganizations } from "~/models/organization.server";
import { clearRedirectTo, commitSession } from "~/services/redirectTo.server";
import { requireUserId } from "~/services/session.server";
import { Header } from "~/components/layout/Header";
import { NoMobileOverlay } from "~/components/NoMobileOverlay";
import { IntercomProvider, useIntercom } from "react-use-intercom";
import { useEffect } from "react";
export const loader = async ({ request }: LoaderArgs) => {
const userId = await requireUserId(request);
@@ -24,14 +28,32 @@ export const loader = async ({ request }: LoaderArgs) => {
);
};
const INTERCOM_APP_ID = "pfbctmiv";
export default function App() {
return (
<AppLayout>
<Header />
<AppBody>
<Outlet />
</AppBody>
<Footer />
</AppLayout>
<IntercomProvider appId={INTERCOM_APP_ID}>
<AppLayout>
<NoMobileOverlay />
<Header />
<AppBody>
<IntercomSurvey />
<Outlet />
</AppBody>
<Footer />
</AppLayout>
</IntercomProvider>
);
}
function IntercomSurvey() {
const { boot, shutdown, hide, show, update } = useIntercom();
useEffect(() => {
boot({});
return () => shutdown();
}, []);
return <></>;
}

Some files were not shown because too many files have changed in this diff Show More