Custom Workflow Automation with n8n
While automation is a highly valued process in most toolkits, creating your own workflow automations can often seem daunting. In this lesson, Matt Hojo will be teaching us how to build custom workflow automations with n8n!
Links & Resources
Click to expand the full transcript
Captions provided by White Coat Captioning (https://whitecoatcaptioning.com/). Communication Access Realtime Translation (CART) is provided in order to facilitate communication accessibility and may not be a totally verbatim record of the proceedings.
With that, I think we’re live. Oh, gosh. Hello, everyone. And welcome to the, well, this is Learn with Jason, except I’m not Jason as you probably might have noticed. My name is Ben Hong and I’m happy to be here as the first guest host on Learn with Jason and I’m super excited because today we have Matt with us. Matt, do you want to introduce yourself to everyone?
Good afternoon. Yeah. I’m Matt. I got an interest in automated work flows. I live in Wales in the UK. So it’s kind of evening for me over here. So probably start seeing it get dark as we get through. But yeah. That’s
That’s good. Well, so today, we’re here to talk about custom workflow automation with N8n which we’ll be talking all about. But before we get started, just want to thank Diane from White Coat Captioning who is here today and making it all possible to have captioning on the show. Big thanks to our sponsors. Netlify for making that possible. So with that, let’s, I mean, Matt, let’s kick it off. Let me switch over to my stream programming mode. All right. Can you see my screen?
I can see yours, yep.
Perfect. Yeah. Matt, tell us a little bit about N8n and what it’s all about.
Yeah, N8n is a node based automation. So it’s kind of abstracts some of the kind of logic that you’d think of automation with it being code and put to nice visual elements. And you can drag and drop them, hook them up and create kind of really cool but complex automated workflows using their interface. It can be self hosted or using their own cloud. I think we’re going to use their cloud today, but there’s a multitude of ways you can do it yourself. This is kind of like some of the other tools that are around. This one is slightly more kind of low level. You can get low level. You can really get into the kind of more, kind of, the logic from programming kind of side of things, which we’ll kind of touch on today which is really good. Yeah.
All right. So one of the things when Matt first told me about N8n is we’re looking to do, note taking is a thing that we both nerd out about quite a bit. On a thing called Obsidian which is a notetaking app that manages a bunch of markdown files. Matt was showing you his workflow where he uses, N8n in combination with Telegram, a messaging app. And that is going to let us, basically, update our note basically, a GitHub repo through a custom workflow which, ah, this is going to be cool. This is what we’ll be setting up today. Does that sound good?
It does, indeed. That sounds good to me.
If we want to get started, I guess, we probably need a repo so everyone can follow along. How about let’s get that set up first. So I’m going to call this one Let’s Learn N8n. Let’s initialize it with the file. Boom. All right. I’m going to go ahead and clone that locally. We have that ready to go. It is open oh, here it is. Great. I’m going to go into my projects. And then, let’s clone it. All right. So looks like all we have here now is an empty repo that’s ready to go.
Perfect. Should we go and set that up in Obsidian so we’ve got a vault and we can get Obsidian set up and head into the cool thing with Telegram.
That sounds great. A new vault with Obsidian. And for those wondering what it is. We talked about it as a notetaking app, but what we’re going to do the high level, is when we’re creating a vault, really what we’re saying is we have a folder full of markdown files. That’s a fancy name for that. And so, here I’m going to go ahead and inside of my projects, let’s learn N8n, I’m going to go ahead and open it and go ahead and create that. And so, what we have here now, looks like we have our Let’s Learn. Let’s go ahead and do our Hello, Learn with Jason. And you can see, this is a markdown editor, hello, everyone. And we can jot down things that I would like to have for lunch like ramen, bubble tea. This let’s you render it into HTML. Quick overview for what we have for our Obsidian set up. Looks like we’re good to go on the map.
We’re in Obsidian, we’ll probably install the plugin for get. So we can start pushing files up and get that site hooked up. So if we head over to the community plugins within Obsidian.
Turn off the safe mode.
Yep. All right.
Let’s browse community plugins. Plugins on the Obsidian ecosystem basically allow us to oh
We’re getting drown in spoofs. OK. So let me see. Gosh. I’m seeing. Oh, my gosh, yes. We’re getting buried. Jason, this is where I’m grateful for a time where reduce the size of boops at one point, it was easy to fill up the entire screen.
I think now it’s just me.
Oh, my gosh, I am buried. Oh, my gosh, look at that. Of course, leave it to everyone to, oh, my gosh. All right. Well, in the meantime, while I’m buried, we’ll take this time to install our get integration.
That’s the one.
Let’s go ahead and install that.
Once we’ve done that, I think one thing we’ll do is I’ll kind of cut to the chase a little bit and save us a little bit of pain. If we go to the plugin settings. Once you’ve installed that, if you close out with that and enable it. Perfect. Then, we’ll head down, you’re ahead of time, should appear down there. Perfect.
And there’s a couple of sentences that will change to make our life a little bit easier.
So I set my pull interval to be sort of every so often. We want it to be depends how often you’re going to be updating. I set mine to every minute. But you probably don’t need it that much. But what this means is it will just kind of. You can work asynchronously through your commands, your automated work flows and it’ll pull in as you come in. And then, there’s a pull up dates on start up. That one down at the bottom, enable that one.
Pull updates before
On start up. Just underneath the branch. That’s the one. I disable notifications because that gets quite messy.
Pulled, pulled, pulled. But I think that’s it so far. I know the one at the top was set to zero on the push.
The vault back up. I actually, I think I’ve set that to one. Yeah.
And I think that’s it. That’s all we need, really. So with that, we can now start playing around with stuff.
So this should start to appear the a the bottom right hand corner, it should see a status of git ready. This means, this is kind of connecting. There we go. Everything is up to date. Perfect. As you make changes now, we’ll start seeing these in GitHub. One way that I do this while I’m playing around with these automated work flows is if you open the command panel of Obsidian, command P and type in get push, it’ll force a push. And we don’t need that with the one minute, but it means that you can control some of this stuff.
Yeah. And I’m going to wait for the other button. But should say, the repo. And it should say all good. Perfect.
The six files will be the .vault from the initial creation. After this, it’ll now be one file or should be. If we go back to GitHub, we should be able to see the changes. And that means that we can start playing around with stuff in there.
All right. Here we go. Yep, I see a folder for let’s learn N8n and we see the .Obsidian. Boom, it’s in.
There we go. That’s the first step. That’s what we need. And now, we could do setting up Telegram. On the other end of the spectrum.
Sounds good. Before we move on, just to have everyone sort of catch up on those things. This is the recap. Basically, what we’ve done is created an automated sync between our text editor Obsidian to pull stuff down and automatically push stuff up. So we’ve automated this work flow. You basically have a back up of your local markdown files. So
Very cool. I hear corgi train. This is great. Love it. So with the markdown files being managed in git, why did telecram come into play in the first place?
So the reason I use Telegram is for me, it was the easiest way to get started with bots. Telegram has a really good interface around creating bots. And you don’t really need to do much low level stuff. In fact, we probably don’t need to do any low level stuff with Telegram. N8n handles all of that side for us. So it’s a really quick way of getting started with having bot commands and sending messages to and from yourself via the Telegram bot. The reason why I use this with GitHub is we can use N8n to interact with GitHub files directly. So Obsidian doesn’t have an API. It’s all locally on your machine. So the way to get into Obsidian is through the backup. It sounds weird but it works really well. The git back up from Obsidian, typically, I would imagine is used for just that purpose. Just to back up. But we kind of hook into that process and we pull down changes. So we can manipulate our Obsidian from wherever through Telegram. And we can pretty much change the files however we want. So we’ll kind of start off pretty basic. Through playing around with it, I’ve had some success with some pretty cool work flows, which get a little bit more intricate. But we’ll start off basic for now.
Yeah, that sounds good. For me, one of the things I’m so interested in Matt’s workflow is capturing things on mobile on the go is quite tricky to get that all synced up together. And having this ability to, the send myself a message and have my notes automatically be updated, I’m so excited for this.
Yeah. We just got a message in the chat. Any N8n that interacts with git. Telegram is the initiator, the trigger as N8n calls it. So Telegram triggers a workflow in N8n which we’ll get to in a minute. That ultimately leads to N8n firing off GitHub APIs to manipulate files, which Obsidian, then, subsequently pulls down. So we don’t have to interact with any APIs directly. We use N8n for that.
This is exciting and I don’t have to read API dots, yes.
To get started, what should we do now?
Let’s set up telegram. We can jump into N8n and that’s the fun bit.
Open Telegram and go to a yes, the bot file.
All right. So bot what is Botfather?
Botfather is telegram’s way of creating bots. So this is all through him and he talks you through the process. You don’t need me. So you open him in telegram and
And he should tell you if you start a new chat with him, start down the bottom.
He gives you a list of all the commands you can give him. It’s really, really nice. If you click new bot or type new bot, he’ll start you down the process.
Should we go ahead and create a new one then?
Yeah, forward slash new bot there.
What are we going to call it?
This is the name displayed. I actually keep these the same as the follow up question, which is the user name just because I find it easier. But you can call this however you want. Like on the Botfather on the right, on the info pane, he’s called Botfather, but his user name is just bot. It’s similar to that. So this is the kind of nice name, let’s say.
Got it. And this is custom to my account? Right? Not something shared?
No, only those with an access token, unless you invite someone into the bot. So yeah, this will be just you.
I guess, let’s call it the N8n bot, call it this?
Unless that’s taken. But I don’t think it will be.
Let’s try that. Good.
So now the user name, it has to end in underscore bot. But you can choose it however you wish.
This will be what you kind of use to talk to with some commands.
Got it. OK. I guess we’ll do N8n bot but just with this underscore.
Let’s keep it simple. Sorry it’s already taken. OK. Let’s learn N8n bot. Oh, this should be all underscore.
Yeah. We’ll keep it succinct with the show. OK. There we go.
So that access token that’s in there uses token to access the http API. We’ll need that.
All right. Sounds good. And don’t worry, chat will be deleting this after the show. So we’re just playing around with this right now. Now that we have our API key, where are we going next?
Let’s go into N8n. We can start setting up the stuff in there.
Sounds good. All right. So N8n here, I do have I’ve created a brand new account. I skip everyone from that process. So actually, let me, oh, I need to log in one password. Give me one sec. Just in case. Let’s not there we go.
Some holding music.
Yeah, let’s do that next. Thanks for the request. There we go. Sign in here we go.
Let’s bump this up a bit so people can see. Much better now. On your screen. Great. Enhance. All right. It should be pretty big now.
There we go. All right. We’re here at the brand new N8n dashboard and so everyone knows, I haven’t touched this before. We are brand new to this. Where do we go from here, Matt?
I think it’s showing you workflow. Click on the button on the right.
Oh, sorry, it’s N8n.cloud on the top.
Yeah, we want to head into the oh, I’ll touch on the sharing in a bit.
OK. Sounds good.
Workflows can be shared.
All right. Let’s do this, then.
Yeah. For those watching, this is their paid for hosted version. So you don’t have to do anything. You can either go down the route of doing it yourself on Pi or however.
Apparently, I created an account in the wrong area.
A question from the chat, does this have a free tier?
It does not as far as I’m aware.
There’s a free trial, though, right?
Yeah. A free trial. I think it’s a decent one, too, like 30 days.
And I think
Oh, I can use my existing one from the other one. That’s great. OK.
Oh, there we go.
Yep. Free for 30.
There’s the pricing.
But N8n is open source, right? So people could theoretically self host it.
Yeah. You can stick it on a Py or N8n has a great community. And the forums there’s plenty on how to host it on many platforms, I think it’s mostly done through Docker, I might be wrong on that. I use their cloud service and it’s brilliant.
All right. I just need. Those wondering, I have to enter my credit card information for the free trial. We obviously don’t want that on the stream because that would be much more painful to change later on after the stream. But OK. Now I’ve signed up for the free trial, ba boom. David is in the chat going to make an open source version. Perfect.
Let’s start. I think that might take us through a tutorial.
Yeah. Close it.
So from there, we can open your instance. What this is doing is spinning up your VM. So I can kind of talk us through what we’ll do in here.
That would be great.
So once N8n sets up your instance, we’ll go through and start adding in your credentials is what they call credentials. So we’ll need GitHub, your Telegram through the access token and I think that’s all really. And then, in between, the two bits we’ll kind of fill in with however we want to go. So they’ve got tons of what they call nodes. And if one doesn’t exist, here’s my call out to those with fancy workflows, you can create them. You can push it to the communities. Other people can build their own nodes and have it so everyone else can use it. I don’t know, there we go
There we go. It’s online.
Perfectly timed. If we head into here, they’ll give you a default one, I think.
Great, I have a subdomain here. I’m going to close out of this.
Ideal. Now, on the left hand side, you get a side bar. If you expand that, there’s a section there of credentials. All right. Credentials.
We want to head into credentials and type, and type in Telegrams. It’s easy, we’ve got the access token.
Anything special for the name?
Let me check mine, I don’t think so. No, I just got mine as Telegram N8n, I think it’s for your bot. So you could have multiple, what’s referenced. They’ll give you a dropdown in the nodes as to which authentication you want to use. Your access token, that’s the access token that Botfather gave you.
This whole thing?
That’s the one. The whole thing.
I’ll copy that over and switch that back. And let’s drop it in.
You can create credentials from the N8n itself. From N8n, inside info.
Good to know.
From here, if you double check the Telegram and Telegram trigger, sling them over and it’ll give you access and create down the bottom right. Right. Perfect.
> We can try and do the credentials from within the nodes, then, that makes life a bit easier.
Yeah. How do we do that?
OK. Let’s create our first initial node. If you click the plus icon, top right.
Plus icon, top right.
And there’s a section called trigger.
And in there, if you type in the type filter at the top, type in Telegram. Perfect. And then, just click it, it’ll stick it in, and then you can choose your Telegram API credentials, the one we made here. There’s a create new section. I see.
That’s cool. Sorry.
Yeah, so this bit here, in updates, want to choose message. So this is when we receive a message, trigger our workflow.
If we have time, I can touch on other triggers, but for now, we’ll stick to message.
This is as basic at it gets.
We have here the initial trigger. Sorry, I was checking my workflow to make sure
We can close this now. And that should be set up for us to have an initial kind of play. If you go to telegram and open your bot, you should be able to kind of
I’m going to bump this to the right so that people can see. We’re going to start a new message, you said. So
If you click, you will find a link at the top of the where the access token was.
Yeah. If you click that, it should take there’s your bot. So this is your bot now.
I think this will work. If we had, if you are kind of flipped between the two. If you head back to n8n. We’ll do this a lot. It might be good to keep this side by side. We need the workflow. At the moment, it’s not kind of anywhere. If you click on the oh, cancel that. If you click on the dropdown with workflows, there should be a thing that says save, save as.
Let’s learn n8n save. There we go.
There we go. We’ve got the web hook registered. That should be good. So if we click execute workflow now.
This should give us a little spinout. Right. That’s now waiting for a trigger. And if you go to n8n bot and just type in anything.
We should get a little boop. OK. Yes. Click on Telegram trigger. N8n makes stuff so easy to debug, it’s almost criminal. If you click on that, there we go, that’s our output straight from Telegram. This is the data we can hook into. We can go from there. This is just the data from message. So different ones from the different kind of trigger, like the trigger types of different output. Which is why it’s easy just to stick with message for now.
From there, go back to the trigger and look at the output, again.
We have a username there of Ben codes them.
The first thing we want to make sure is that the message comes from you. When we start getting into telegram, the thing I found was you want feedback as in, yes, we’ve saved this, yes, we’ve updated this. We’re doing something. When you click a chat message, it’ll trigger. Check the username, does it come from me? Have I triggered this? We don’t want it to run indefinitely. The first thing, we’ll create an if node. If you close that and we go to the top right hand side. Yep. And then type in if. And then it’s split screen depending on the yeah, that’s the one. So in there, if we close that a second, yes, it has perfect. That now knows that if you close in between, there’s a little cross if you hover in the middle.
Like this? Yep.
Yeah. And now, click on the dot, you can drag where you want it to connect to. So it’s super slick.
Oh, that’s so
If you click on if
OK. And you go in there.
This is when we kind of start seeing how nice n8n is. And this is kind of throughout the whole thing. So if you click add condition.
And you want to make that string.
And you go value. And in value, if you click the cogs on the right hand side of that, add expression.
If you click on input data, you’ll get JSON, in JSON you’ll get message and in message, you’ll get author or from. Yeah. Go to from, it’ll give you your username. Username, click that. And it will now tell you in the result what it would get if when that’s run. You’ve already run it once. If you close that now. And then, in the operation there, in the value two, type in your username.
Now, that will match. We’ll head on. If it’s false, it doesn’t do anything. Now we can start building out between telegram and git.
Okay. The question is, what would you like to do?
I mean, I think, let’s, what is the simplest route for showing the feedback loop?
Yeah. OK. Let’s have a file and let’s start adding stuff in. Whatever you put in. The command side of things, we can add this quite easily in between. What would be the next best thing? The next best thing would probably be to set up GitHub in n8n. I would say. If we add a new action and we want to create new.
If you change the authentication to OAuth.
Oh, much better.
Yeah. You’ll now go through the GitHub OAuth. Yeah. Click on the excellent.
Authorize. I think you need a let’s Learn with Jason.
Jason, we’re going to need you to approve something. Hopefully, you see this. But OK. At least that’s that. And I’ll at least authorize it from here.
Yeah. Jason I need you to approve the n8n request so we can have it talk to that specific repo. All right in the meantime. So now we have that, let’s assume if it’s not connected, we’ll refresh it in a little bit.
Yeah. If you scroll down, I think that’s a bit down the bottom. Save.
So do we need to add any of these GitHub triggers?
No, it’s just already assumed we’ll want access for that. You could have a GitHub trigger, but for now, we don’t need that. The repository owner. Oh, actually, sorry, no, resource. We want that to be file. Just under reauthentication.
And operation, we want it to be read.
Or get, sorry. The reason we want to get this, we want to get the files so we can append to the bottom of it every time. The way that GitHub works is the API, if you create a change in something, you just kind of provide it with everything that you want in that file. If we just give it our string that we’re going to append to the file, it’ll override it with the single string every time. The best thing about this, from this side, there’s no merge conflict. It’ll get the fresh file every single time. From the other side, though, that’s where we need to be careful. We’ll get to that later. When we pull in. If we don’t pull before we make a change, it’ll try to push up a change when there’s been one from where we’ve sent a command. That’s the only kind of caveat to all of this. Repository owner, this is where we want the Learn with Jason, I think.
Yeah, let’s check that really quick. GitHub.LearnwithJason. Let’s learn with Jason here.
And you’ll need the repository name on the end.
Let’s learn n8n.
This could be anything. But this needs to be where in our vault. So our vault is, I think, in Obsidian? I can’t remember how it was in GitHub. But we will create a file in here I don’t know if you want to call it inbox or something.
Yeah, something simple. Let’s call it inbox. OK. We have our inbox. I’m going to go ahead and push this up.
That should be in GitHub. And the path.
All right. If I go ahead and refresh that now. We’ll see the repo and pump this up a bit. And if we look in here, looks like it didn’t push yet. Oh, it’s pulling changes. Some people are commenting. My laptop is running a lot of different things right now. It is spinning up. Push two files to remote.
Maybe I need one of those new iMacs with an N1 chip and this won’t be a problem. Look at that, we have our inbox right here.
We’re going to need the file path to that. The let’s learn n8n/inbox.nd.
Oh, OK, this part right here, right?
Yep, that’s it.
This is where we’re that should be all good.
Path required. It should be oh, there we go. Once I move off of it to validate it.
I deal. And I think that is let me check. That’s all we need from there. So if you close that, that node is set up. That now reads from GitHub in a binary data, though. If we try to manipulate any of that, it’s not going to work. If you click on the plus on the right hand side. We’ll get one called binary data, I think it’s called. Move binary data.
Move binary data, OK.
If we drag that down on the screen and we hook up GitHub to that. That’s going to pump all the binary from GitHub into the move binary data. And on the end, the opposite end of that we’ll get JSON. If you click on the, click on move binary data.
It’ll tell you the JSON key at which that’s going to output at. It’s going to come out as data.
At the bottom, yeah. And you can change that if you want.
Data works for me. That sounds good.
If you create a new node of GitHub, again.
OK. All right.
We need to change authentication to OAuth and you should be able to select the one you’ve done. Resource we want file, again.
Yes. We’re going to go to file. And this time, edit.
Yep. And same thing, we want the same repository.
Repository learner is Learn with Jason. Let’s learn n8n. And then the same file.
If we go back into the expression edit.
For binary data?
No, for file content.
OK. Add expression.
Uh huh. And in current sorry, current node is going to have anything. We haven’t run this yet.
So if we close this, this is my bad. I should have remembered this. We close this, and then, we hook this up to true.
Do we need to put a commit message?
You can put a commit message in, yeah. And close that. And in the if, connect the true to get file.
This is as basic as it’s going to get.
What this is going to do is this is going to on a trigger, it’s going to say, is this in? Yes, get the content to the file, convert it to JSON from the binary to JSON and then, we’re going to edit the file. But we don’t really want to edit the file just yet. If you hover over edit file on that node on the end, there’s a pause button but there’s a specific pause button you can, basically, say, don’t do this. If you hover over that, click on that.
That freezes that one. Yep. That won’t actually run that action.
If you click execute workflow at the bottom, again. And then open Telegram.
Yes. Right. OK. Let’s try, again.
And you’ll see all of the ones go all the way across. JSON input. That’s not what we wanted. Why is this?
Double click that.
Oh, we don’t want settle data, we want source key data. Click off that. There we go. I deal. The reason we did that is the read data from GitHub is sending out. If you close this and then go back into the read workflow, we can see the output of that. And those are binary on the top right.
That’s it. That’s outputting and it says at the bottom, binary property data. On the left hand side. So that’s saying that this will output the binary in the data key of the output.
So that’s, if you close this and then hit on the move binary. You could do that, again. Run it through Telegram, again. There is a play button on an individual node that can cause it to trigger that one node. But I find it. There we go.
Look at that.
OK. So. We’ve got all the way to edit file. If we double click on that.
We now will have the ability to select and file content in the expression edit.
OK. The cogs here. Oh, we already
We’ve already got one. Double click on the input on the left on the input field of that
Got it. Like this?
There we go. Open it back up. We added an expression. It knows this the is the intent. If you click current node and input data, JSON and then, we want the data, we want data there. Yep. Because there’s no value. So data is the what we read for it and obviously nothing in the file.
At the moment, it’s just completely empty, which is why this is empty because there was nothing to read. If we do that, what we can do from there is underneath the data, if you create a new line in the expression on the right
If you click on message and then, your text. So now, what we’ll do, what this will do is every single message you send.
It will add to the previous file and it’ll just keep going.
We’ll take the existing file and append the message you just sent it.
Oh, so really
Every time it works the workflow.
Update like this? It won’t override it. It’s just sticking it to the bottom.
This is, we’re getting steps. This is good. We close this.
And run it, again. We should now
I could just run this node by itself?
Yes, you could. Yeah. You hit play. It’ll activate a node, but on the top right, there’s a, I don’t know what they actually call it.
Execute note. I think it’ll work.
It said it did get executed successfully.
If you go into there, you’ll see a new commit of
We check Obsidian.
We’ll need to pull here. Do the command and pull down.
I think it’s already pulling.
From here, it’s an infinite world of possibilities. You just kind of get clever.
How long do we have? Another half an hour.
Yeah. What about saving links?
Oh, yeah. Let’s go down that. So the first thing we want to do is I will prefix this with Telegram commands are a specific thing in terms of you can have a command that would typically run something.
With the command that we’ll build now, we’re kind of hijacking that process. Where we’ll type in forward slash URL. Forward slash command and it would go off and do something. We’ll take what we put after that as the URL. So that’s how we’ll kind of know we’re submitting a URL.
Yeah. Sounds good.
So the first thing we want to do is let’s stick in a switch statement. If you click on the plus.
Yep, let’s do this.
And we’ll do a switch. The reason we’re doing switch is adding new commands is easy. At the moment, they only support up to four outputs per switch. But you can stack switches. So you can have the fourth output full back to another one. You have as many as you want. At the moment, it only has four specific outputs. If we close that and disconnect the node from edit file, and if you disconnect the if to GitHub in the middle and then, if you highlight, yes, native kind of looks native probably very difficult to implement SHLGTS if you hook that from true into the switch. Yep, from the switch, you can hook zero into git file. So we’ve got that kind of bit set up. Now, if we go into switch and we go to rules and we want data type string. Yep, I want the value to be the if statement. If we click on the, sorry, if you click on the expression. We want the current node and input data. And we P want that to be the message message and text, sorry, yep. And close out. And then, in the add routing rule at the bottom. This is, we’ll do starts with because it’s the easiest one. Type in whatever you want the command to be forward slash URL is what I use. And we’ve already got the output set to zero. If you were to output if you had another command, you could add a rule starts with forward slash URL. Whatever you route it off with. I can’t hear you, I don’t think. I don’t know if it’s just me. It may be just me. Can chat hear everyone? No, chat can’t hear Ben either. While Ben is trying to get his mic working, again, I’ll look at chat. Chat, do you have any questions where’re at right now? I could probably answer questions about n8n and fall back if there’s anything there. In theory, you could. The way we’re doing this is working with message platforms not just Telegram. I don’t know the support in n8n, though, for other messaging programs. I’m not sure what support they have. But in theory, with this command we’re doing now with the URL anyway, we’re just string matching. We’re not actually kind of using any kind of hey, again, on Ben? I don’t think he can hear me now, either.
OK. I’m back. Matt, can you hear me?
I can hear you.
I don’t think it’s going to go through the stream just yet.
OK. I can hear Ben.
We’re almost there, hang on. Test mic. Nope. Did my mic die?
Jason said got to change it in OBS.
Yeah, that’s what I’m trying to do. OK. Test mic, one, two. I think I got it.
Can we get some boops if we can hear Ben. Boops for Ben.
Yes. OK, thank goodness for backup mics. How am I coming in?
You sound great, mate.
All right. Sorry about that, everyone. Glad I had a spare podcast mic sitting on the floor.
As you do.
All right. Excellent. Cool. Sorry about that. Should we continue on, then? We have the URL you were talking about, the routing rule.
If you wanted to add another routing rule, you could, sorry, I realized I was calling it routing rule. You could create as many of these as you wanted and you could output them to one of the four once you get to that point where you’ve reached three and you want a fourth one, you would, typically, fall back that output and choose the one that you’re going to kind of fall back to in the new switch.
OK. Let’s illustrate that, then.
You’ve created three commands.
So one, two, three. OK.
Yep. And then, you have four outputs. But obviously, if you want to once you’ve hit that four, you’re at capacity of that switch node. At the bottom of that node that you’re on now, once you’ve gotten the third one, there’s a full back output. And you can select from there three.
What that will do is any input data that comes into the switch will now fall back to another switch. And you can have as many of them as you want.
Then, from here, we would theoretically, then, add another switch rule.
And then, we would take
Hook that to three.
So three would fall into this new switch.
Correct. And you can have as many as you want.
Going in here?
One and two would be different commands.
Sounds good. So currently, if I understand everything correctly, zero right now is, actually, it’s going into directly into URL.
Yeah. It’ll come in and it’s just like a normal programming switch statement. So the first thing it hits is this one. You want to change the output of this to zero, though.
OK. Got it.
Perfect. And then, the other two.
Leave it alone.
We can leave it alone.
Now, zero, if we get a slash URL should trigger this workflow?
If I understand correctly, I’m going to execute the workflow, and if I don’t prefix anything and test message, it should just stop?
It forms through the switch because it’s a fallback. Keep going all the way through and doesn’t do anything.
That worked exactly as I expected.
If you now do execute workflow.
Yep, start the execute work flow, again.
And forward slash URL and type in some stuff. Maybe put in a URL. Then, we can use that data. So you want to prefix this with HTTPS or HTTP, that’s a good hook to have.
So I’m going to actually just do Obsidian.nd. Like this. I was right. So if I hit it, boom, we can see that now because of our switch statement with the prefix.
Do you know if you can side scroll, by the way? In photoshop, you would hold spacebar.
I actually don’t know the command for it, but I have a mouse with a horizontal scrolled wheel. So I just use that.
Well, I’ve got a vertical one but no horizontal scroll wheel. I’m sad.
I don’t know how you would
I guess I can zoom out a little bit. Oh, that’s not what I wanted. All right. This will have to do. Because, you know what I mean? Usually, you can drag the canvas.
I can’t seem to drag. Maybe someone in the chat knows how to do it.
Yeah, command click.
Command click, that’s what I wanted. Perfect.
The OCD in me, I want it perfectly centered.
OK. What we want to do there is we now want to get everything after forward slash URL. A little bit of trust basis here. I think that’s the easiest way. We could get the route and try to reroute. But we can say everything after forward slash URL is going to be a URL.
Disconnect the switch to get and shift them all over, again.
Let’s push it alone. Great.
In there, we’re going to do a set what this does, this is a very, very useful node in the sense of you can take an input and you can manipulate the object that it comes out with. You can create a new property within the object or override an existing one with a transform value. What we’ll do here is if you click add value.
And we want string.
We’ll call this, the name, we can call what should we call it? Either value, which is what mine is or we can call it URL.
Let’s call it value.
So the value of that is what we want to get from the message. If you add expression. And then, current node input. Oh, we don’t have input data yet. This is a new node. Yes. If you close that and then we take it from zero. Yeah. I think because with that one, I think that means it has data in it that we can use.
Come back in into this.
Current node, input data. And then JSON message text.
Yes. OK. Everything between the squiggly brackets is SK. So under the text reference, we can do a .match. Or however you would do it. I’ll leave that up to you. However you would take away the forward slash URL space. That, you do that. I do that rejex.
How would you do it? I was about to do a substraight.
I will send you it.
This is in the Zoom chat?
Yes, and I’ll explain why I’ve sent it to you.
All right. Copying, pasting this in. Look at this.
Coding on if fly.
That should be.
Why is it pasting in funny?
I think it’s the syntax
It’s not taking out the forward slash URL. Why is that?
Do I need to manually type it?
I know why. Because I’ve got it so my URL workflow, I share URLs an awful lot to myself.
Got it. And it got to the point where I was not able to put the forward slash URLs. Just take it. So what I was doing here, what this reg ex does everything on the first line.
Often stuff that wasn’t on the second. But what we do want to do is we want a different reg ex.
I’ll send you.
Here we go.
We’ll have to play around with this one, this will get the HTTPS bit. This just checks. So this just checks for
Oh, that’s not it.
HTTPS. And we want to create a new kind of capture point after that. Yeah.
OK. Did that do anything?
That’s not found anything. Because we haven’t at the moment, we haven’t the carrot at the beginning is matching to the start of the line. Want to take that away.
And we want to open up the, open up the bracket on the HTTPS. Can you see, we’ve got open bracket HTTPS question mark, closed bracket, that’s our capture group. We want to move that group to the end of the reg ex. If you take that one away and stick it off the forward slashes. Keep the question mark in, that’s http or HTTPS. That’s it.
And you want it before the final forward slash.
We’ve got the same thing here, but basically, we could do a, what would you .star really bad. The chat’s probably going to go wild. Capture everything. In the array, in the zero field, we now have our URL. Ta dah. We can stick this on the end of our document.
If we close this, go back to here, it’s going to output value and then, if we close that one
And we want to plug that into the get. And in the edit file on the far end, we want to reference that specific value. So where we’ve got file content.
File content. Opening this up.
Yep. Current node, input node, input data, sorry. JSON. We haven’t run it. So it doesn’t have it yet.
Oh, that makes sense.
It’s using data that’s in move binary data.
If I play this, will it work?
Try it. Give it a go. I don’t know.
That executed. And
There may not be
There may not be anything there but we’ll see. We don’t want to run that one just yet.
Not yet? OK.
You can. So in there, let’s go to file contents, and let’s see if it’s available. So, yeah, so the moment, we’ve got the broad. We’ve put in forward slash URL, we’ve got the raw thing. What we want is value at the bottom there.
It did work. Look how easy that was. That was so good.
It’s super easy.
And take out that one.
Take all this out. That didn’t work the way I wanted it to. Oh, it didn’t delete the whole field automatically. My computer’s chugging. Oh, there we go. Almost there.
So close, except, I’m going to delete the whole line. That was such a fail. Much better.
Sorry. I knocked the mic. Now, technically, you’re done for the basics of it. I don’t think we’ve got time for it just yet. But I will quickly illustrate you some of the nodes we could stick in between.
Let’s do it.
If you close these down, the reason I mentioned earlier about the command not taking forward slash URL, I still have support for that in mind, but mostly use, is this a URL?
Yep. And the way I do that is I have a second reg ex in the fix. I check for forward slash URL or reg ex. Then it’ll run the same URL workflow and go through the URL process. One thing we can do but we don’t have time for today, which is a shame. If you click on the plus at the top right and you add a node called http request.
Yes. If oooo. This will take a URL and make a http request and return the data. From that point you’re probably thinking, oh, no, I’m going to try to reg ex out some values. But if you click on the plus and type in extract on the top right, if you add a new node. Yep. You can, then, plug in the, yeah. So you can plug in the data. It’s actually already hooked up. It’s setting right the way across your workflow.
Yeah, it totally did. Let me move this stuff over. So here, it’s going to plug into there.
We might have time.
I think we might be able to make this work. We should gun it.
Stick it on there in URL, you want to fetch that value we just set in set. So you click on there, add expression. You got it.
Current node, input data. JSON, value.
Hey, look at that.
Perfect. OK. So that’s all good. So you want to output that as JSON.
Let me double check mine just to make sure there’s nothing in there. Oh, so I’ve got response format string.
The reason why we do that is you could request from an API end point that returns JSON. What we’re doing here is we’re saying, we just want raw text. Because the endpoint we’re hitting is going to be just a URL. It could be anything. And then, we output as data, that one’s good. So if you click close on that.
Yep. That’s going to come into HTML extract. HTML extract is going to take the JSON of data now, extraction values. This is the values that we’re going to take. So
What would be one that every site has? A title. So stick a key of title.
OK. At CSS select there, title.
Oh. Right. Yep.
And I’ve got mine as return array. I don’t know why. I don’t think we need return array.
I don’t have an array.
The check box. I’ve got mine set as an array. But I don’t think we need one. That would basically be if you want multiple selectors. If you want to return we can turn that off. We only want one. And this will now output title as the value, value being the URL and title being the name of the site. If we close that.
In edit file.
Oh. We need to run the workflow. We don’t have the data yet. I keep forgetting.
Execute it. This time, I’m not going to individually click. We’re going to grab this URL, same one, pipe it through. If we go to edit file.
And let’s go file content.
No longer valid. That’s fine.
The reason this is the HTML extraction bit is its own thing. It doesn’t take information in and pass it on. But there is a way we can now get the URL still. So if you create an empty markdown URL, so if you
Create at empty one.
Yep. Perfect. In the brackets
We want the title. If you go to input data JSON.
Title. And if you go down to nodes, hit the button, and then, we can do the set. You can title your nodes wherever you want. So you would, typically, if you have multiple commands have the set titled to what you want. Set and you want value. And this will reach in and take the value out of that node. You have just created a markdown link with the title of the page. The preview down the bottom shows exactly what you’re going to get. So what I also do for my inbox here, as well, is I also add in the date. So I have a reference.
OK. So how do we do that?
So if you close
Added on oh, wait. Didn’t let me type. Added on, OK. All right. Now what?
So if you close that.
And then close that. And then, I would probably stick it by the set somewhere. But if you click an add node.
And then type in date. And it will give you date and time. And then, in value, yeah, you want format date, in value, add an expression. Create some empty brackets. Trying to be quick here.
Yeah. Got it.
Type in new date. Just JS for new date. Perfect. Close this.
Close it. And choose the format which you want the date to be in.
I have mine in the
That’s the one. And set the property name to date.
Perfect. Close that.
Disconnect from edit file.
Yep. And then, stick it in your workflow. And I normally put it around the set. So you want to have HTTP go into extract. We definitely need that. But you can basically put this anywhere within there. Yep.
OK. So I’m just going to take this.
Hang on a second. No, we may need that to go into set. If you put it after set because set doesn’t theoretically go into anything because we pull it out ourselves. Yep.
And then, like this, this is very ugly, this will do.
It’ll do. And go to edit file. Believe me, tidying up these things is a whole other realm. And then, if you go to file contents.
And then, add it on, you want nodes.
Date and time.
Date and time. Parameters.
Oh, we haven’t run it.
Oh, we’ve got to run it.
We’ve got to run it.
Run the workflow. I’m going to switch it up this time. We’re going to go to “New York Times”.com. Here we go. Boom. Uh huh, oh, my gosh. Go back in here. And we go to the file content. Date and time, output data, JSON. Date. Stick them in the square brackets and you’ll get a reference in Obsidian. Yeah, you’re doing the Wikireference at this point.
Exactly. And loop that into Obsidian has a really cool extension called daily note. Which will create a daily note of this format. This is the reason why we went for this format in particular. Or you can choose it, actually. It defaults to this format.
If I execute this node now, this means that inside of our inbox, I refresh.
We’re not creating new lines in between.
Escape it manually?
No, so if we go to the edit file, going to check and make sure on mine. Yeah. So in edit file, create a I don’t know what we’re doing here. Add it on. So they should be. Should be adding it on as it does on the bottom there. I’m not sure.
Maybe it’s just a pass artifact? I’ll try, again. This time, aisle going to do Twitter.
Oh, we need to execute workflow.
Shoot. You’re right.
There’s a button that says active.
The way that we get this to work because I’ve noticed we’re on time and this is critical to workflows.
If you want, when you want this to run in the background without you doing anything, if you expand the menu on the left, you have to hit save. Every time you make a change, it pauses the workflow. So even if you went away, it won’t run. Until you’ve hit save. You need to enable that. Perfect. While you’re playing around, hit execute, hit save. Now, you don’t, theoretically, need to click execute workflow, it’ll be running in the background. However, if you want to visualize those steps like we have been doing, you need to have that running, otherwise, it won’t display them in the UI.
Once again, let’s do the Twitter, URL, will it still show since it’s now active?
If you click on raw in the file. I wonder if it’s the way that GitHub runs the marked down files?
Oh, got it.
Because Obsidian will render this. They should be on yeah. So Obsidian will have this as it does whereas GitHub mark down renders slightly different to Obsidian.
Twitter did not have a title for us to select. That’s an interesting one.
I’ve had this before and it’s because there’s a surprising number of sites that use JS to change the title and the raw text doesn’t have one so if you use something like netlify or something that has a title, it might show that kind of thing. If we get the n8n refresh?
Yeah, give it a refresh.
I’ve realized we’re over time.
Yeah, we’re getting to that point. We have 12 minutes left.
I’ll do this all night. I love in. This.
I feel like we have to have you on for part two. I feel like we unlocked the chip of the iceberg now.
I’ll disclose now. I was hoping we might get close to it. I carved the work flow. If you click execute work flow and we kind of run this in the background.
One of the things I’ve done, in Obsidian, you can have a daily note and in that, you’ve got the, you can have yaml front matter. But you can hook into various plugins. What I’ve managed to do is simple, once you hook into the reg ex side of things, have a system where I can automate a job, and it sends me a telegram keyboard command message. Sorry. That will update the document based on the ID that I give the keyboard button. So I give the keyboard button a specific ID that matches to the yaml front matter. And expand upon this an infinite amount. The workflow side of it just looks for using reg ex. The first section before an underscore and the value is the second section after an underscore. And I can hook into the text space document using those different values.
It’s just so many things that you can do with this. But let’s try and figure out why this isn’t, quickly, I don’t know why. Did we, did you type in another URL?
Yeah. Let’s do it really quick. Yeah, let’s do one more. This time, instead of Twitter, though, what’s another one we can do?
Sorry, just to Lindacat in chat, yes, you use a multiple GitHub notes. So the GitHub nodes, well, pure workflow, anyways, or per stream. This one, where we have an individual command is kind of slightly more specific because you’re editing and you’re putting in a specific markdown syntax. The one I described there where it’s a value hooked on the key. That one, it uses the same one for as many keys because it’s a generic pull text, there’s no formatting involved.
URL for PPC?
Is this not running? Are we hitting issues?
Here’s waiting for the web hook call. I’m going to hit it, see what happens.
There we go.
OK. So if we now go to edit file. Yeah, you could refresh this.
This is a raw git commit.
We should see.
Here we go. BBC home page.
Got title, the link. And if you go to Obsidian and pull that down, you will now have the reference on the name.
Oh, this is going to unlock so much. But you’re saying something about the edit file, though?
I was going to view the output, you know, in the file content just to see to make sure that n8n was putting in the right place. But we cut to the chase. One thing to mention, if you edit that inbox file. So I have all of my stuff from Telegram come into the inbox file for the sole reason of as I’m adding stuff, if I have it come into a daily note or something, which I’m editing frequently, then merge conflicts just happen all the time because I will forget to push. My computer will sleep or something and Obsidian won’t do the get thing, I’ll send myself a link, come back and they’ll be like, oh, I’ve updated it in two different places. If you change this file, command P push. Push it up before you go away so you know that GitHub has the latest version. The git Obsidian plugin has good conflict resolution. Click push and it’ll figure out everything else. Does it for you, but it’s still annoying.
This is fantastic.
I remember you said, we could share this workflow, isn’t there an easy way to export this?
Yeah, two ways, I have to tell you this.
Let’s do it.
If you select the entire workflow or just a snippet of it. Doesn’t really matter.
OK. I’m selecting it.
Command C, command V.
The way that n8n works, this is all JSON. So this is, it’s so good. And this is actually means that you can speed up n8n workflow creation like super fast if you have a certain thing to repeat over and over, command C, command V. Optimize it to use the same bit. There’s an export feature. Download. Sorry, I’m using the wrong terminology.
It’s all good.
OK. Let’s open this up really quick in VS code. Assuming my file doesn’t crash on me. All right. Here we go. So many things chugging away.
Come on, computer.
I know. I gave you eight cores and 64 megabytes of RAM. Please, work. Oh, look at that. There you go. Yup.
You can share that file or there is a route which I’ve not done before which is through the one we very briefly touched on at the start of the stream with the share functionality within n8n itself. Where you take the JSON and you put it into that interface and you can share a link to it and people, I think they can just create click new workflow. I don’t know how that works I think there’s a whole thing around it so you can stick it in your cloud or whatever.
So if anyone creates really cool workflows, please put them up somewhere and tag me and Ben, I would love to steal them.
I’ll use them.
Yeah. Gosh, I can’t wait to play with this. But OK. So we are at time. So, thanks so much to Matt for coming on. I mean, so as we covered in today’s episode, we can see that n8n. We talked a lot about Obsidian and GitHub work flows, there’s so many integration points here. And so, if you think of it as a if this, then that, there’s so much in here, I’m going to have to dive into this.
Yeah, there’s an absolute ton of different things.
If you click on trigger, that down to the stuff you can start the workflow with. But the way I kind of got so excited with this whole thing at the beginning, you can have a trigger. One thing I’ve done is I’ve used Telegram as a middle man of commands. So actually, update my daily note in Obsidian with my sleep time from my Apple watch. So my Apple watch goes to my iphone, I have a shortcut which uses Apple shortcuts, which pulls my sleep and figures out how much sleep I’ve had in the night, creates a command for me, I share that to Telegram, which just does it. Sends it and n8n picks that up, sticks it in the right place in my daily note. And all I did was press one button on my phone and it’s just two workflow automations all together.
Oh, my gosh.
The possibilities with this sort of thing is even though you could have one trigger, you can hook it up to so many different things.
Yeah. It’s ridiculous.
This is amazing. All right. Well, in that case, I think everyone, we are at time for today, so before we wrap up, let me switch it over, Learn with Jason. That’s the wrong page. That’s my old all right. Again, for those, if you’re new to the show, you can find the entire schedule here Learn with Jason and we have the schedule coming up. Again, a big thanks to Diane from White Coat Captioning, which is made possible by our sponsors. And so as far as, you know, we talked a lot about Obsidian today, that is a whole separate topic, which is why, later on this week, I’ll bring you. We’re going to get to dive the ins and outs of Obsidian and why the developer community is really excited about the tooling and obviously Matt and I nerd out a lot about this. So would love to have you all there. If you’re curious about learning more about Obsidian.
That was great. I love that. I’d love a part 2.
Yes. I know. We’ll have to have Jason bring you on for that one.
We could all be there.
So much fun. But Matt, if people want to find you on the internet of things, where can they find you?
Yes. I’ve just stuck a link in the stream. It’s Matt underscore Hojo.
I’m going to drop. Here is the upcoming episode. Awesome. Matt dropped it. Yeah. And I think with that, let’s see, I think I got everything on my checklist. Yeah, again, thanks everyone for coming and hanging out today. Matt, this has been an absolute blast. I’ll be hitting you up with a lot more n8n questions going forward. This should be fun. With that, chat, we are going to raid. OK, let’s go ahead. And we’re going to go ahead and look to see who is online right now. Let’s see, actually, this will be interesting.
Do we have a message? Is that a thing, still?
I don’t know, actually. I think Jason is still in the chat. Looks like bald bearded builder is here. All right. How do we do this? I’m going to, I just realized, we’re testing out sort of the streaming things, but I wonder if Bald Bearded Builder, I don’t know if this is going to work. OK. I don’t have permission to save that. OK. Jason, if you’re on, looks like I’m streaming to your key. Let me try that. It said I didn’t have permissions. Here we go. And no. Do not have permission to perform that action. Jason, I think you’re going to have to be the one to kick off this raid. Because I don’t
He’s done it. Jason’s done it.
Epic. All right. Well, again, thanks so much, everyone, for joining, it’s been an absolute pleasure. And I hope to see you on Thursday. So talk to you then. Bye bye, everybody.
Closed captioning and more are made possible by our sponsors: