Transcription
Today we are talking about building reports from Hey Reach data. Why? Well, chances are you might have superiors, team members, and very often clients that would like to see regular stats. The good thing is with the workflow that I'm going to share with you, your reports will be generated automatically while you sleep.
What we're building here is a workflow that is scheduled. It will run every Monday at midnight, so between Sunday and Monday. and it will pull all the information about stats about all campaigns from the beginning of time since we started doing our campaigns. Then it will pull weekly stats. So from this moment 7 days in the past stats of campaigns. Then it will draft an email for us and it will CC or just put already what we defined client email addresses. So when we get up on Monday morning, we just need to look at the draft and if we're happy with it, just press send and that's that. We've finished with the reporting for the previous week. And additionally, this workflow will save this weekly information in a spreadsheet that we defined. So we'll have week after week stats in our spreadsheet.
So here I have the spreadsheet and I have my inbox and my drafts folder. So what we're actually doing here is I'm going to run this workflow. It's adding one new row in this spreadsheet which is this one. If we refresh this, here is our draft. This is totally arbitrary. You can put any kind of text you want. This is already person one at client.com, person two, our colleagues. And we've defined this subject line and say, "Dear client, please find results." So for the past 7 days and total stats, I'm using a test account in Hey Reach and that's why I have zeros or really low numbers. When you run this, you will have regular numbers of your campaigns. Here we have week after week. I've did a lot of testing. That's why I have multiple rows here.
And after that, we are going to talk about the second version of this workflow that is a little bit more complex and has a few more steps. And the reason for that is it does one additional thing. Not only does it pull stats from the beginning of time and for the last week and creates an email draft and saves everything in a spreadsheet, it also finds people that replied in the last 7 days. It takes their information, adding them to the email draft and creating an additional sheet inside the spreadsheet for that week listing all the people.
So let me show how this is working. So, as we can see, it created a new sheet, added the header, it's filling out the information, adding leads, added leads, created a draft. As we can see, compared to the previous draft, now we have a list of people that replied in last week. These people are my colleagues and again, I'm using Hey Reach's test account. So, that is what we're building today.
So the simpler version here, we are starting with a schedule trigger and here we have multiple options what we can choose like seconds, minutes, and so forth. And we can use cron. Cron is a task scheduler for Unix-based operating systems like Linux, which many servers run on. So if we don't know the syntax of cron, we have this convenient link here that takes us to this website which helps us to define what we're actually doing. So you can find here every Monday at midnight, etc., and then come up with this.
So moving forward, we don't have to use the generic HTTP request node for communicating with Hey Reach's API. The reason is we finally have official integration between Hey Reach and n8n, meaning we have an official node, or actually nodes that communicate that are official from the Hey team and that communicate with Hey Reach's API. In order to use these nodes, we need to find it by typing Hey Reach. We will see Hey Reach API here. If we go here, you will probably see a little button here to install this package that contains all these nodes. I've installed it already, so I don't have to do this step. And if we analyze what we can do with this and take a look at the documentation of the API, we'll see that it maps to each other pretty well. So, a lot of things that we can do here.
And just for the sake of comparison to see what the difference is, we can see here to retrieve total stats, we just need to drag and drop this node, connect with our Hey Reach account, and that's it. We will get total stats from the beginning of time. If we want to do the same thing with the generic HTTP request node, we can, but we will have some extra steps. We will need to find this endpoint in the documentation. We would need to either import cURL and get these fields and set up the API key and set up the mandatory fields in JSON, etc., to achieve the same thing. So my recommendation is to start using the official integration, official Hey Reach nodes.
From there and on, we want to set, in my case, I prefer to use variables for this and to set dates and times. End date is the current moment and the start date is - 7 days. This minus 7 days comes from a library that n8n uses behind the scenes for manipulating dates and times called Luxon. And I linked here in the workflow the link to the official documentation of Luxon. So you can research and see for yourself what you want to achieve. Of course, this is going to be more or less. If you want every 2 days, 3 days, 14 days, you'll change this number here.
Then we need to retrieve the stats. So we're using basically the same node as before, just using dynamic fields from the node of variables. And then we're connecting the node for Gmail, connect to our Gmail account. Say we want to create a draft and here we build our subject line. And what I'm doing here with this split method is, if we take a look at this, this is the full timestamp, date and time separated by this uppercase T. So what I'm doing when I'm building my subject line is just saying, okay, split this string. So this is textual value by this character and take the first part left of this character. So I'm just left with the date. And here you can do whatever you like. You can set the text that you prefer. And also, let me execute previous nodes. So everything is green and dynamic values are as shown. So we can add here one space. You can do whatever you want with this text. This is just an example. And here we can add options to add like CC, BCC, two values, etc. And here in our spreadsheet node, connected to our account by sheet ID and then we can just map, drag and drop from one of the nodes before weekly stats and not stats by day, but actually overall stats, just drag and drop and be done with it. And here in this case, I'm preserving the timestamp start and end. And these are all columns that we can get from Hey Reach's API about campaigns. If you don't want to preserve all of these values, for example, you're not using emails at all in your campaigns, then maybe there's no need for you to save like email reply rate or something like that.
By the way, before we continue, I just want to mention that if you prefer to load this workflow in your n8n account instead of building it step by step, you can. You can find the link in the description to download it. Just load it into your n8n account, set the schedule, connect with your platforms, and you're all set because if you're selling any kind of agency service, this is kind of a must-have.
That being said, let's talk about the second version. So, it starts pretty much the same. Schedule trigger again, cron, Monday at midnight. That works for me. Set variables. In this case, it was easier for me to save as a variable, spreadsheet ID, spreadsheet name, where the stats should go. Also, start date, end date, and like to to split like only dates and dates and times. And then this is something that I've encountered as a small problem. If we want to access later on here to add leads and the name, if it's dynamic, we're using expression to build this leads then date and that. So, for whatever reason, sometimes it's working, sometimes it's not. So my workaround is to be sure it's going to work to just save to build here dynamically and save it as a variable and then later on just reference it and use it. So that's why we have this additional node.
Then we are going to create the sheet and then like the title of the sheet is going to be this. The good thing is if the sheet already exists, it will not be created. No duplicates will be created. No errors will be thrown. The only thing that will happen is empty value will be passed along and we just need to turn this on, always output data, so we don't break our workflow. And then we have an IF node. So if this value that is coming is empty. If it's not empty, meaning that the sheet has been created, then we define what we want to set as the header, the first row, like the columns. And this is also a workaround. There's no easy way to do that as part of a spreadsheet node for whatever reason. Maybe that was not of interest to anyone to build it up until now. So we'll see in the future. But this, there is a workaround. So we defined as strings and like the names of the columns and just set null with this curly brackets as expressions and then set those values to the spreadsheet. That will create like if a new fresh sheet has been created, this branch from IF will set these values. If the sheet exists, it's an empty value from this node. There's no operation here. This node serves the purpose just to merge multiple branches.
And then we are fetching the stats as before. So we have total stats, weekly stats, and something that happens with APIs that sometimes they can throw an error, say, hey, you're making too many requests in a short period of time. That's why in settings, it's not a bad idea to just turn this on and say retry on fail. And for example, I said two seconds, maximum three times. So just to give it a little bit of time to actually return data to us.
Now, this is a new part where we retrieve all campaigns from Hey Reach. So as we can see, this is one big collection of items and then we're splitting that into 10 items, not because we defined 10 items, but because it has 10 items. And then we are using a different here, each node to retrieve leads per campaign and that's why we have 10 items going out. It's pure accident that there's 10 leads. And then we have a filter. So if for example, LinkedIn user profile, and this is information about one of the leads, so lead message status as value, message reply, meaning this person replied. This value was defined by the Hey Reach team. So that's the value I'm using to pull out all the people that actually replied. So two items out of 10 has the filter. And then we are sure that these people actually replied and we can add leads to the spreadsheet again, mapping out all the fields that we want to have about them. And then if we take a look, so this is the thing. So it created a header and this information is relevant about these people.
So what we want to do is go back and actually prepare text for email. So this is a code node that is actually taking values and just creating a string with empty rows and formatting, etc. So we want to push that information into our Gmail node. So we can just say, okay, JSON leads, this is what we're getting. And we can see the preview. And that's pretty much decent, if you ask me. So in that way, we can achieve this additional feature functionality for getting our reports more rich, more detailed, and provide more value to whoever we're sending it to, for example, clients. So that's how you can automatically generate your reports for your outbound campaigns.
But what if your outbound campaigns are not set properly with unlimited leads and enrich data? If that's the case, click on the video in the overlay and go watch the next one where I walk you through a step-by-step process how you can build an amazing automated system for generating leads on LinkedIn where we use Clay for enrichment, n8n for automation, and Hey Reach to actually send messages so you don't have to lift a finger.