# Get started with n8n.cloud (Part 3)

## Метаданные

- **Канал:** n8n
- **YouTube:** https://www.youtube.com/watch?v=JpIec7eSID0
- **Дата:** 09.12.2020
- **Длительность:** 6:02
- **Просмотры:** 1,939
- **Источник:** https://ekstraktznaniy.ru/video/15949

## Описание

In this tutorial, we'll add conditional logic to our workflow with the IF node and only post a Slack message if the comment comes from a list of specific usernames.

If you've completed part 1-3 of this "Get started with n8n.cloud" series, you should have an understanding of the basics of workflow design in n8n. However, this is just scratching the surface of the functionality available in n8n.

For inspiration on workflows and more tutorials, check out our Blog: https://medium.com/n8n-io

For reference on specific nodes, head to our docs: https://docs.n8n.io/nodes/nodes.html

## Транскрипт

### Intro []

so in the previous tutorial we created a workflow that triggers each time someone makes a comment on a commit in github and then we send that to slack now let's add some conditional logic that will only send a message when that message is coming from a handful of usernames so to do that we'll add a if node which

### Intro []

so in the previous tutorial we created a workflow that triggers each time someone makes a comment on a commit in github and then we send that to slack now let's add some conditional logic that will only send a message when that message is coming from a handful of usernames so to do that we'll add a if node which

### Add if node [0:20]

is one of our conditional nodes we'll click on it here and the first thing i'll do is i'll close this and we want to check this condition before we post the message so we'll break this connection we'll place it in the middle here and we'll connect our github trigger how the if node works is we set up a condition within it which either evaluates to true or false and then the trigger routes that data accordingly so from our github trigger we receive some data we evaluate a condition if that goes to true then we'll go to the slack node and post that message so let's go ahead and open up the if

### Add if node [0:20]

is one of our conditional nodes we'll click on it here and the first thing i'll do is i'll close this and we want to check this condition before we post the message so we'll break this connection we'll place it in the middle here and we'll connect our github trigger how the if node works is we set up a condition within it which either evaluates to true or false and then the trigger routes that data accordingly so from our github trigger we receive some data we evaluate a condition if that goes to true then we'll go to the slack node and post that message so let's go ahead and open up the if

### Add string conditions [1:00]

note um how it works is we set up multiple conditions to evaluate and then we select if all of those conditions need to be true or if any so in this case let's add a string condition because what we want to be evaluating or comparing is a text string and for the first value here basically we're setting up this value and operation if it equals the second value or one of these other operations equals is what we need here but for the first one we want to reference that username from the github trigger so again we'll use expressions we'll go into the nodes into the github trigger drill down into its output data into the comment and we want to get the username which happens to be here so we'll click on that again up top we're seeing in the expression editor we have the variable that's now getting rendered here as max to catch perfect so if value one equals max to catch this will now evaluate to true let's add another username to another string condition we again want to use the expression editor here now if you remember what that variable is perhaps you're adding a lot of expressions you can filter so here clicking that login again and now if this equals that's a username too now currently we have the sort of combine here set to all so all of these would have to evaluate to true but we actually just want that one of these evaluates to true which means that if any of these are true this if node will evaluate to true and route to our true branch to our slack node so now that this is set up let's execute this node give this a test we see that we have one result which makes sense because we only had one github comment from our trigger and here from this drop down we see that this evaluated to true and in false branch nothing evaluated to false here this is useful if perhaps you grabbed 10 jira tickets and you're comparing some property some might evaluate to true false

### Add string conditions [1:00]

note um how it works is we set up multiple conditions to evaluate and then we select if all of those conditions need to be true or if any so in this case let's add a string condition because what we want to be evaluating or comparing is a text string and for the first value here basically we're setting up this value and operation if it equals the second value or one of these other operations equals is what we need here but for the first one we want to reference that username from the github trigger so again we'll use expressions we'll go into the nodes into the github trigger drill down into its output data into the comment and we want to get the username which happens to be here so we'll click on that again up top we're seeing in the expression editor we have the variable that's now getting rendered here as max to catch perfect so if value one equals max to catch this will now evaluate to true let's add another username to another string condition we again want to use the expression editor here now if you remember what that variable is perhaps you're adding a lot of expressions you can filter so here clicking that login again and now if this equals that's a username too now currently we have the sort of combine here set to all so all of these would have to evaluate to true but we actually just want that one of these evaluates to true which means that if any of these are true this if node will evaluate to true and route to our true branch to our slack node so now that this is set up let's execute this node give this a test we see that we have one result which makes sense because we only had one github comment from our trigger and here from this drop down we see that this evaluated to true and in false branch nothing evaluated to false here this is useful if perhaps you grabbed 10 jira tickets and you're comparing some property some might evaluate to true false

### Testing the workflow [3:15]

but in this case that's working so if we test the slack node by clicking this play button here we see that the workflow was executed if we go into slack we see that we have the message here now what i did by pressing this play button is the slack node went to the previous saw that it has data and used that instead of if we hit the execute workflow button it would restart the whole workflow and we'd have to create another trigger event so it's useful to use this play button or the xcode execute node button when you're testing so you don't have to keep creating a new trigger event so this workflow is working now um what we can do to improve readability of it is rename our if node so we remember what we're comparing here in this case we're filtering user names we'll save that and what else we can do with the conditional node here is use a no operation node now while this node does not do anything it's helpful to have it in your flow because as you can see here the slack node had some data sent to it and if we did have multiple items coming in we could see that some were flowing to the slack node and some flowing there's no operation node here the last thing to do here is to save our workflow and then activate it activate and save and now this will run in the background and the workflow will execute each time we're getting a comment here on github let's give that a quick try it's running in the background now this is the last comment that let's take a look at slack here we see that it just came in this is the last comment posted by max to catch um this is the last tutorial in this get started series we will be creating more but from here there's some links in the description we have a medium blog where we have various examples and also our documentation which are great places to check out what to go and do from here but what you've learned here are the essentials for building a workflow from here it really is about adding more nodes to build more comprehensive workflows and then understanding the complexities of each node for example in the slack node there's various sections we haven't tackled yet that can add things like tables buttons and other sorts of blocks or attachments thanks

### Testing the workflow [3:15]

but in this case that's working so if we test the slack node by clicking this play button here we see that the workflow was executed if we go into slack we see that we have the message here now what i did by pressing this play button is the slack node went to the previous saw that it has data and used that instead of if we hit the execute workflow button it would restart the whole workflow and we'd have to create another trigger event so it's useful to use this play button or the xcode execute node button when you're testing so you don't have to keep creating a new trigger event so this workflow is working now um what we can do to improve readability of it is rename our if node so we remember what we're comparing here in this case we're filtering user names we'll save that and what else we can do with the conditional node here is use a no operation node now while this node does not do anything it's helpful to have it in your flow because as you can see here the slack node had some data sent to it and if we did have multiple items coming in we could see that some were flowing to the slack node and some flowing there's no operation node here the last thing to do here is to save our workflow and then activate it activate and save and now this will run in the background and the workflow will execute each time we're getting a comment here on github let's give that a quick try it's running in the background now this is the last comment that let's take a look at slack here we see that it just came in this is the last comment posted by max to catch um this is the last tutorial in this get started series we will be creating more but from here there's some links in the description we have a medium blog where we have various examples and also our documentation which are great places to check out what to go and do from here but what you've learned here are the essentials for building a workflow from here it really is about adding more nodes to build more comprehensive workflows and then understanding the complexities of each node for example in the slack node there's various sections we haven't tackled yet that can add things like tables buttons and other sorts of blocks or attachments thanks
