Google Docs getting content in Text

I am trying to “Get Content of a Document” from a Google Docs.
I have no problem connecting to my document.
Earlier in the scenario, I wrote down a list of “updates”, separated by line.
When I get the content of the document using the above stated model, it returns many arguments (such as Title, Revision ID, Document ID, Body, etc), that none of them contain the text, except for an argument called “Text Content”.
Problem is, that text content is all in a string, and doesn’t give me the desired result. It doesn’t create a new line where necessary, and has everything pasted in one running line.
How do I format it properly to be separated by line as it is written in the Google Doc?
For example:
Desired Result -
“Hello, my name is John.
I would like to speak with you today.”
Actual Result -
“Hello, my name is John. I would like to speak with you today.”

Additionally, I would love to know how to erase all content from that same Google Doc at the end of my scenario.
Thank you!

Under the “Body” collection is an array of Content. This has each element (including paragraphs) it it’s own element in the array. You could use that to iterate over each element.

Also, depending on what you want to do with the data you could use the “Download a Document” module instead and download the content as HTML (or something more useful for you in this context) that has formatting in the response.

2 Likes

That doesn’t really work…
My module does the following:
Watch on a Monday.com board for an update. When that trigger occurs, send an email to X with a list of all the updates, separated by time and by update creator.
The problem is, in order to get those updates, I have to iterate over all the updates and write them down somewhere. My solution was to write it all down in a Google Doc, then copy from that Google Doc and email the content. I can’t really iterate over the Content array as you said, because that would bring me back to my original problem before the Google Doc, which is that I have a list of items I need to send in one singular email.
Any thoughts?
Here attached is an image of what the text should look like in the email as I correctly wrote it into the Google Doc (first), and then what actually shows up in the email when I select the “Text Content” of the Doc as the email content (second).
original format

I don’t have access to Monday.com to test but if you are iterating over all the items, could you use a router with two paths, one that has no filter and adds the new item to a variable and the second that is filtered to only run when it is the last item in the collection and it gets the variable and uses that in the body of the email?

2 Likes

That sounds like a great idea! I’ve always wanted to use a dynamic variable in my scenarios, but how would I edit a variable value? The only options for modules of the variable variety are getting or setting variables, no updating existing ones.

Basically you get the variable and set it again with appended values each time. Here is how I would do it (replacing google sheets with Monday): https://video.techopsheroes.com/s2JdtmDv

2 Likes

This is an amazing solution, thank you!!

1 Like

Actually, just tried that, but there seems to be a problem with getting and setting the variable with each iteration.
For some reason every time it gets the variable, it gets the original variable, not the most updated version of it. Here below are pictures:
This is the overall scenario:


Here is how I initially set the variable:
image
Last Run Filter is adequate:

Both “Get Variable” modules are initialized correctly:


Here is how I initialized to set the variable:

First Operation of “Set Variable” works correctly:

Second Operation of “Set Variable” doesn’t:

It seems like the Get of the variable isn’t getting the most updated version, rather the initial version I set before the repetitions.
I have the same problem on the last run.
Any ideas??

When you set the variable here:

image

Don’t use the variable but actually put “EmailBody” in for the variable name like you did when you are getting it.

2 Likes

That worked great!
Next problem:
The output in the email isn’t as I wanted, it’s as if the variable forgets about the “new line” when inputting it in the email.
Here you can see that when I get the variable for the last time, it worked great:


And here you can see the output in the email is just plain text, without including the "newline"s:

Hi @Uriel ,

You have to use some HTML, for a basic usage (like adding new lines), there is another very interesting topic here, fortunately it is solved.

BR,

PBI

2 Likes

Thank you!
Seems like that still didn’t help. I am creating the email content iteratively using a variable.
Here is how the variable (which will be the email body content) looks at the end:


I tried sending an email using the stripHTML function as such:

As you can see here, it still is sending the email as just a chunk of text, without adding the new lines as I am trying to:

According to the documentation, stripHTML removes all the HTML tags.

1 Like

I understand, I thought it decodes it.
Well in a situation where I create the Email Body iteratively in a variable before writing the email, how would I implement new lines where necessary? Is there any way to take the formatted text I have saved in the variable and send it by email, not as a chunk of text, but split by paragraph?

You could use the “Compose a string” module, it is very useful when you want to concatenate different variables (and why not HTML tags) into a variable.
You just have to proceed step-by-step adding the HTML tags when necessary.

2 Likes

I made a recent post about how to insert new paragraphs for multi-line plaintext

see https://community.make.com/t/claude-gpt-new-line-outputs-for-html-email/16805/2

2 Likes

Can you just put the EmailBody variable into the body? Why are you using stripHTML at all?

1 Like

Have you tried the Text Aggregator? On the advanced settings you have the chance to choose new line as row separator. It’s like a join function on javascript.

1 Like