Skip to content

feat: add Inngest stage automation workflow - #46

Merged
pasc4le merged 2 commits into
devfrom
StefanoFalco/embedding-n8n-automations
May 19, 2026
Merged

feat: add Inngest stage automation workflow#46
pasc4le merged 2 commits into
devfrom
StefanoFalco/embedding-n8n-automations

Conversation

@StefanoFalco

Copy link
Copy Markdown

Related Issue:

No linked issue for now. This PR addresses the migration of part of the recruitment stage automation flow from n8n to Inngest.

Description:

This PR introduces an Inngest-based automation layer for selected recruitment stage transitions, moving part of the current n8n-driven flow closer to the Next.js application.

The implemented changes include:

  • added an Inngest client and a Next.js API route for Inngest under the existing /recruitment base path;
  • added shared stage events for triggering and canceling delayed automations;
  • implemented a shared scheduling rule with Rome timezone support and sleeping-hour handling;
  • added delayed Inngest functions for Stage A, Stage B, and Stage C;
  • added cancellation support for pending stage workflows through cancellation events;
  • added shared automation utilities for Telegram notifications, email sending, Google Docs template rendering, and stage data loading;
  • updated stage switching logic so stage changes emit Inngest events directly from the app;
  • updated initial applicant creation so Stage A can also be triggered by the app rather than only through n8n;
  • added dry-run support to safely test the flow without actually sending emails or Telegram messages.

Stage D has intentionally not yet been fully migrated in this PR, because it involves more complex persistent side effects such as Google Docs report creation, Google Calendar event creation, Google Meet generation, and saving generated data back into the interview record. This will be handled in a follow-up PR after validating the basic Inngest structure.

Validation:

  • I ran pnpm lint.
  • I successfully ran pnpm build.
  • I ran pnpm dev and checked the local Next.js app.
  • I tested /recruitment/api/inngest-health.
  • I tested /recruitment/api/inngest.
  • I started the Inngest dev server against /recruitment/api/inngest.
  • I verified that the PR targets dev and not main.
  • I checked that the branch follows the requested naming format.
  • I reviewed the generated AI-assisted code before submitting.

@StefanoFalco
StefanoFalco requested a review from pasc4le May 6, 2026 08:32
@pasc4le pasc4le added the enhancement New feature or request label May 6, 2026
@pasc4le pasc4le linked an issue May 6, 2026 that may be closed by this pull request
@pasc4le

pasc4le commented May 11, 2026

Copy link
Copy Markdown
Member

@all-contributors please add @StefanoFalco for code

@allcontributors

Copy link
Copy Markdown

@pasc4le

I've put up a pull request to add @StefanoFalco! 🎉

@StefanoFalco
StefanoFalco force-pushed the StefanoFalco/embedding-n8n-automations branch from 6c9b0da to 37968ae Compare May 13, 2026 12:36
@StefanoFalco

Copy link
Copy Markdown
Author

I also pushed the follow-up Stage D branch:

StefanoFalco/inngest-stage-d-automation

I am not opening it as a separate PR to dev yet, because it depends on this current Inngest A/B/C PR. Once this PR is reviewed and merged into dev, I will rebase the Stage D branch on top of the updated dev and open a clean second PR.

Stage D adds the Inngest workflow for creating the interview report document, creating the Google Calendar event with Google Meet link, saving meetingId and reportDocId back into the interview record, and notifying HR.

@pasc4le pasc4le left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent PR! Thank you for the submission. I'm only concerned about the sleepUntil, won't it cause unnecessary CPU load? I saw on the documentation that there's also a way to schedule one-off tasks:

https://www.inngest.com/docs/examples/scheduling-one-off-function

Should we think about switching to this solution instead?

P.S. Upon further thinking, it's fine this way, better not to delay this uselessly. Just check the all-contributors-cli dep and we should be good to go.

Comment thread src/inngest/functions/stage-a.ts Outdated
Comment thread package.json
@StefanoFalco

Copy link
Copy Markdown
Author

Ok, I kept sleepUntil as discussed, since Inngest handles it as a durable wait, and it should not create CPU load in the Next.js process.
I pushed a small follow-up commit that should solve the issues/redundancies that emerged.

@pasc4le
pasc4le merged commit 876be9a into dev May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants