What's the best way to get a raw file from Github and then parse it?

Hi everyone,
I have a few scenarios where I send automated and personalized HTML emails to customers. These emails are being used in multiple scenarios and platforms, so I got a GitHub repo and I’m downloading the HTML EMAIL CODE from there because if I need to edit the email content, I just edit from my repo, push a commit, and voila.

Here on make.com, I’m getting that file using githack raw, and then I replace some variables or tags like /EMAIL/, /NAME/, /DATE/ or whatever, with the module Replace. The problem is that I have to go 1 by 1, and it uses a lot of operations for each parsing. I couldn’t find a way to optimize those replaces.

Any suggestions about how can I optimize this process? Any Regex code or something that I can use to replace all the variables in 1 operation?

I appreciate your suggestions and ideas. thanks

Hi @Juani,

What you can do is utilize replace function in Make for this. This way you don’t have to use the Text Parser Replace Module. What you want to do is chain all of the variables using replace function as in the screenshot.

I would however suggest you have a unique replace token so that it doesn’t overlap with your other texts in Email like MK_EMAIL or something like this, which I think you have already done that though.

There are other options as well to do this in a better way though, If it is feasible for you you can also use Google Docs or MS365 Doc Template to do the same.

1 Like

yeah! I knew that was any other way to do it. I was doing something more complex.
Thank you for taking the time to understand and for explaining to me!

Anyway, I’m able to replace those variables on a string variable perfectly, but, when I try to download the content from GitHub with an HTTP request “get a file”, gives me this error:

DataError

Failed to map ‘value’: Function ‘replace’ finished with error! Function ‘replace’ finished with error! Function ‘replace’ finished with error! Function ‘replace’ finished with error! Function ‘replace’ finished with error! ‘{buffer}’ is not string or number.

Origin Make

Data from the HTTP request is OK.

I’m not sure what’s going on. I tried many ways, converting the “data” output into a variable, but the same happens. The only way I’m able to do it is with plain text, not downloading the file text, which this last, would be the same as replacing the email content manually on the email content field.

Any ideas?
Thanks again.

I’ve just used toString() function and it works.
It was a problem with the text format.+

Final “Set Variable”:

{{replace(replace(replace(replace(replace(toString(48.data); “#SUMMARY#”; “summary”); “#HANGOUTLINK#”; “hangoutlink”); “#DIA#”; “dia”); “#HORA#”; “hora”); “#HTMLLINK#”; “htmllink”)}}

Thanks!

Heya @juani :wave:

Awesome that you managed to figure this out! Thanks so much for circling back here and sharing your solution with the community. We 100% appreciate that :pray:

1 Like