🚀 Add to Chrome – It’s Free - YouTube Summarizer
Category: Automation Guide
Tags: automationdatan8nSlackworkflow
Entities: community.n.ioJavaScriptMaxn8nSlack
00:00
hey I'm Max the original flowgrammer and welcome to your n8n quick start i'm going to teach you the key fundamentals to building any n8n workflow that includes triggers and actions how items of data work between steps in your n8n workflows how to map data between those steps and transform it and
00:19
route it based on business logic i'm also going to teach you how to connect to apps and services so you can perform actions in those apps and services in your app stack and we're going to do this all with a super simple workflow it's an installation request so there'll be a web form and it'll send a
00:34
notification to Slack it's a simple workflow to teach you the key fundamentals of N8N that you can leverage in your actual use cases and if you came here wanting to build some fancy AI stuff I hear you it's very exciting there's a lot of hype about it right now but I strongly recommend that you watch this video first learn these foundations and then jump off into that agentic future all
00:53
right with all that in mind let's switch to N8N and begin i'm here in a brand new n8n workspace and let's start a new workflow from scratch this is going to take us to the workflow canvas this is where you build out your workflow activate it and then it runs automatically it saves you a bunch of
01:08
time let's add our first step to the workflow and that's going to be a workflow trigger in Nen we have triggers that kick off workflows and then we have actions that perform steps in your workflow there's lots of different types of triggers that you can leverage for example if you want to kick off the workflow based on an event in an app or service that you use in your app stack you can
01:25
go on to on app event if you're building an AI chatbot perhaps you're going to start off with our chat trigger since today we're creating a web form automation let's start off with an on form submission cuz n8n is going to give us a web form that we can give to the end user to fill out to kick off the workflow let's click to add that to the canvas this added the node to the canvas
01:43
by default the trigger node the form trigger and we can see that it's a trigger node because it's got this lightning bolt on it and if I hover near it it gets its own execute workflow button let's go ahead and set it up there's various parameters that you need to fill out before you can execute a step these are required fields as you can see here there's an error around the form title so let's go
02:01
ahead and give it a title request an installation and let's also give it a description fill out this form to request an installation we'll reach out via email to finalize your appointment next let's add the form fields that we want the users to actually fill out these are called form elements in n8n let's add the first one and let's ask for the email and since an email is text we could keep
02:20
this to text but we do have a specific email type and this offers a bit extra data validation when the user fills that out if they get the email wrong so let's add that and we won't add a placeholder for now but let's make it required and then let's also capture their preferred install date so we can do a bit of conditional routing based on that and I can show you how to work with
02:37
data and manipulate it in n8n as well and let's set that to a date because then it'll be a nice little date picker for the user to use for now let's respond when the form is submitted so it'll just say "Hey great your form was submitted." But in future you could make this a multi-step form if you're evolving this now that I filled out the parameters of my node the next thing is we need to
02:55
test it and we do that by clicking execute step in the case of the form trigger this pops up a test form this is what your end user is going to see once you activate the workflow let's go ahead and fill that out name.com let's say my preferred install date i need this in two days like I'm really busy i got to get this stuff installed so I submit that okay let's go ahead and close that
03:14
popup and we can see that it executed successfully and there's a green check mark in my output here and I have some output data here as well how nodes work in n8n be it a trigger or an action is they run their step and then they output some data and that's what we can see here in the output there's a few different ways to visualize that data for example I'm looking in JSON mode right now
03:32
because most of this data does get passed in JSON format in n8n so this is a rather true to form representation of that data i can also see it as a table if that's useful for the type of data I'm looking at and there's also a schema view which extrapolates the schema of this data and shows it in a format where if I had nesting I could also collapse it this would be a good juncture in time
03:51
to talk about n items what they are and how to work with them so as you can see we have one item of data in my output and if I go to my workflow we can see the node executed successfully it's got a green check and there's an item of data coming out of that as well what is an item of data basically each node in nin8nn including this trigger node outputs an array of items that's its
04:10
payload that it sends out that you can pipe in to the next step now the one contract between nodes in n8n is that they always need to pass along this array and it should have zero to many items in this case we have one item of data in here because there's one element in this top level array which is why there's one item here that's going to be useful for you to know because most nodes
04:29
perform their step on each item of data and a lot of folks sometimes get the looping paradigm wrong and try to add looping steps when they don't need to because again nodes perform each step on each incoming item of data that will become clearer in the next step when we add some conditional routing before we continue though if I continue to test my workflow be it from this execute step button
04:48
here or execute workflow button here i'm going to continue seeing that popup and I'm going to have to fill it out now in our web form that's not too bad there's just two form fields but what if it's a subscription event for Stripe or something that's difficult to replicate for my main system it's going to be really annoying to basically keep creating test data as I do that so what you can do
05:05
is pin the data in this node so each time that we run it it just outputs the pinned data to do that we can hit this pin data button here this data is now pinned we can see that visualized in the canvas as well so each time I mash this execute workflow button it doesn't actually run it just
05:20
outputs whatever payload was sitting in there super useful pro tip that I highly recommend with pin data once I activate my workflow it won't be used on those production executions but it will stay here for when I come back here for a future session when I maybe want to test my flow let's now add some conditional routing logic that routes it to Slack if the preferred install
05:37
date is within 7 days and otherwise continues the workflow to do that I'll click the plus button here and since I want some conditional routing we need to go into the flow section of my nodes panel and here there's various things that can control the flow what we need here is an if node if you do need to have multiple output branches depending on more complex conditional logic you
05:57
could also opt for the switch node in this case we're just checking if it's under 7 days away so we can use the if node and I'll drag and drop that onto the canvas just to contextualize this we can now see I've got my pin trigger sending one item of data into my if node if I open it up I can see that I've got the one item of data flowing into here and in the if node it also has parameters
06:17
that we set up to inform how the step runs and we do this by setting up one or many conditions that we evaluate and they might evaluate to true or false and they'll go out the true branch or the false branch let's set up the first condition to do that we want to check if the preferred install
06:33
date is 7 days into the future of right now or not so we can actually drag and drop that onto this value and this turns it to an expression in n before it was set to fixed that's the default so it just treats this as text which I can also type but if it's set to an expression anything within these curly brackets will be treated as an expression that is evaluated and we can see
06:52
the evaluated result here is that date so I can drag and drop data from previous nodes and map them into the steps for current nodes to inform the current step right so the next thing that we need to do is the operation that we want to evaluate basically value one to value two right
07:08
since this is a datetime we do have date and time operators which is useful because dealing with date and times can be a little clunky mentally and so this kind of helps make sure that you got sound logic for that so let's set this to is before or equal to and we're going to get an error because
07:23
we don't have anything set in the second value yet but for the second value how to think of this i have a date we don't know what time it is and we want to check if it's younger than 7 days from now so we got to get the now and add seven to it right to do that we can set an expression go ahead
07:39
and set an expression there and I'll do two open brackets and in here I see an autocomplete shows up and in nan we do have a helper function to get the time right now it's called dollar now so let's click to add that and we can see it's printed a date time but we want now plus 7 days so if I
07:57
hit period I can access autocomplete and see the various helper methods that I can use if you're familiar with JavaScript this is also JavaScript so you can apply JavaScript methods here as well but the Nadin team has a bunch of helper methods in addition to JavaScript for the things that uh JavaScript might not cover let's add the plus method and we can see here there's a
08:16
mini documentation on how to use it we need to specify the an integer on how much to increment the current datetime and the units to do that by so days so actually we need exactly what's in this example so let's click to add that and then in here let's write seven days and we can see that
08:32
is now 7 days in the future if we run this it does work because this gets cast to a date even though this is currently a text as you can see there's a little a character there to make this a bit more robust and just to show the different methods at work I can again hit a period here to access this autocomplete and there is a two datetime method available here there's a bunch
08:51
of others that you can look at as you're going through your use case but this one makes it just a little bit more robust so now we're comparing a datetime to a datetime let's test that it's true that's great we could test this again make sure the logic's working because we set a date 2 days in advance so this should go to the false branch that's working correctly we'll set that back great
09:10
so now we've got conditional logic we're routing to the true branch and we can see that's coming out there now before we add the slack node let's annotate our workflow so it's a little clearer when we come back and we can do that by actually modifying the name of this if node let's say is
09:26
within 7 days it's a little tip I like to do for my conditional nodes is phrase it as a question so it's kind of clear what the true condition means versus the false condition and before we add the slack step for the false branch just for completeness let's actually add a no operation node now as the name implies the no operation node doesn't really do anything but it can be
09:45
renamed for example there's a few more advanced use cases for it but right now we're just going to use it as a placeholder so it's clear later in the flow if we want to evolve that on to the Slack step let's click the plus from the true branch because if it's within 7 days we want to send a Slack notification to someone on the team that's going to be within action in an app i can also
10:04
just search for it from here but just so you see where that is in the app I would go into action in app i could scroll down to find it or again just search inline here let's click on Slack now there's a lot of different actions in Slack again I could search for that but what we're looking for is to send a message and so I'm going to click on this send a message action here and it's connected
10:22
to my workflow we can just confirm that by going back to the canvas and seeing that's going to the true branch now we just need to set up the slack step for most app nodes you are going to have to set a credential for it this is an entity within edit end when you add your API key or whatever that service expects and then niten can connect to that service on your behalf i have already created
10:39
a slack credential for my Slack but you can create a new one in line from here as well you're going to see this screen here if you're on NADN cloud I do recommend the oorthth route because you get the fancy just click to connect experience you go through the Slack popup and it auto connects otherwise you are going to have to go create an access token but if you're stuck on that you can
10:56
open the edit in docs to do that and you can also rename your credential as well i'll use one that I already created but that is going to be the first step now the resource and operation is already set cuz we picked that from the nodes panel so we're sending a message now we need to pick who we send this message to right so let's drop down here and let's send this to a channel and in this
11:13
case let's pick from a list although I could also set this by ID again there's an expression here that could be a dynamic thing in a more advanced workflow in future so let's go ahead and select a channel let's send it to the sales channel and let's do a simple text message but you could use Slack blocks in future that's what's going to allow you to have buttons and all manner of those
11:32
sorts of things and for the message text let's set this to an expression and let's actually open this up so I can see a bit of a bigger view and I'm going to paste in the static text that I would like so new install request within 7 days contact email preferred install day and again here we're just going to drag and drop values from earlier in my workflow the most recent node is autoexpanded
11:52
but I could also map values from previous nodes as well in this case they're the same because the conditional node doesn't manipulate data it just routes it so let's go ahead and get that preferred install date and map that here as well now again here I could combine these texts i could I write a lot more but you get the idea i can combine static and dynamic text to send a
12:10
useful notification all right let's test this by running it we got a success check which means it worked let's go over to Slack and confirm that and great we can see that came in here contact email name and email automated with this end workflow perfect we can open up that workflow if ever need
12:26
to troubleshoot future let's run that one more time just to be sure worked again here and now we see two here perfecto next let's go back to my workflow canvas and before we get too excited let's save our workflow now that the workflow is saved if we leave this it's not going to work
12:42
automatically yet because we haven't activated the workflow so far we've run a test execution we've done a test form but we need to activate the workflow and then as the workflow runs executions are going to occur in the execution tab of this workflow so you can see there's a bunch of these
12:58
test workflows that we just ran signified by this beaker icon here and if I take that production URL from the web form so if I go in here I copy that and in a new tab I enter that i can see the form is now live and if I fill this out let's do a different one let's say max at company code
13:15
and let's pick an install date also pretty soon and submit that we can see firstly that that ran really quickly that's very cool but then if I go into my workflow into executions I can see I have an execution that came in that doesn't have this beaker icon this is a production execution i can
13:33
go in here i can inspect that i can understand if it failed perhaps or if I want to update the logic and one last thing to point out a little pro tip before you go is that I can copy this into the editor this is going to unpin the current data that I have repin the data from that current
13:48
execution and now I could continue building with that latest production execution which is super useful if you're troubleshooting or if you're just evolving your workflow wow you did it good for you i hope you found this video helpful you're well on your way to becoming
14:04
a flowgrammer if you keep it up there's a ton of resources in our global community to help you on your journey as you learn the first place you're probably going to want to go is community.n.io that's our official community forums where you can post questions we've also got the n8n templates
14:20
library that's n8n.io/workflows really excited for you to start your automation journey everyone at believes that you should own the means of your automation and so on that note happy flowgramming