Creating Custom Workflows With Inngest and Sanity

It's possible to create user-defined workflows with Inngest and Sanity. The demo shows a button triggering an event in Inngest. The event has parameters such as account ID, salesperson email, lead email and status. Once triggered, multiple steps occur including sending emails, waiting for periods of time, and sending slack messages.

The workflow is loaded from Sanity, a flexible platform where elements of the event can be rearranged and published directly. In this case, the workflow is rather simple and set for a single account, but can be made more robust for other accounts and workflows. Testing can be done within these platforms to ensure each action of the workflow operates as expected.


[00:02] Alright, so here we have a little demo. So there's a button to trigger here and if we come look at the button, this is sending marketing new account as an ingest event with an account ID, lead email, salesperson email status. It's effectively similar to what we've got here, but I'll click this. It clicks over in the stream, comes through, and we get some steps. Some send emails, some waits, wait for five seconds, send slacky message, all that fun stuff.

[00:49] So coming into here and looking at new account so this is the workflow over here and functions marketing new account with the type and we get that and then what this does is actually loads the workflow from sanity so inside of sanity and you see then it comes down here and has a switch statement does all that logging out that sort of fun stuff In Sanity we are actually able to come in here, load up, so we have just a test, the trigger is new account, and then the account ID is 123. I didn't make this very robust so it's kind of it's like like hard-coded like that's the only one that exists right now is 123 but you could you know there could be a sensible default and then that could be overridden, that sort of fun stuff is also very much a possibility. How you query it is is pretty flexible inside of sanity. But now I can come in here and I can do like that so I can move these delays around and move that move that down here move this up here publish this and now when we come over here and we trigger that we get so it sent the slacks message which you can see down here, sent the other one, sent the last email, did all the pauses, and completed the workflow.

[02:29] So you know I only made those four, right, delay, filter, send email, slack, but we could make a lot more and you know this could be made way more robust by having you know I didn't even test the filter yet but we could you know like have a lot of different ways to do this where, and I even set a count ID default, I just didn't set that one up. But that's the idea, right? Like, so how you query sanity, you get the workflow with the actions in line, and then you can, you know, run whatever you need to. Pretty cool.