Combing text from across operations

I’ve been having a heck of a time trying to combine data from across operations into one variable.

Goal: Automatically crosspost from Instagram to my blog

  1. Watch my Instagram account
  2. Download the images and videos in each post when I upload something new
  3. Upload those media files via API requests to my blog’s CDN which returns an image URL for each one (each image has to be uploaded with its own API request)
  4. Format the image URLs returned from each of those API requests, format them as inline Markdown image text, and then combine them all onto separate lines and save everything as a variable
  5. Make a new blog post with a final API post request that includes the original caption, and the variables that include all the Markdown images (and HTML videos, which are done with a similar method via the middle route)

I’m getting stumped in the top route (step 4 above) when there are multiple images in a post. I get them all uploaded to the CDN correctly, but the URLs returned are done in their own operation and I can’t get them to combine with the Text Aggregator. So I end up with only one image in the variable at the end instead of all of them.

Text not getting aggregated; they’re all in their own operation and bundle:

My Text Aggregator settings (each image URL should get put into Markdown format and onto a new line):

How it should all come together in the end:

I’ve tried playing with the Iterator, putting in Array Aggregators, but nothing seems to get those operations down to one. Does anyone know of a solution?

Right now there is no way to access variables from another route.

You can submit this suggestion to the Idea exchange, under Platform ideas. Don’t forget to search for it first, just in case someone already suggested it!

You’ll have to do a workaround, temporarily storing the variable you want in storage, like a data store or Google Sheet.

Then, in the final route, you could fetch all of the saved items to concatenate, and then clear/delete the store for the next scenario run.

Alternatively, you could try to arrange your modules so that they run linearly, without the use of routers.

2 Likes

I actually have been able to get variables from across routes to work by following a method outlined in this video. Meaning I’ve been able to get both the combined_image_md and combined_video_html variables to get pulled into the final (bottom) route.

But it’s getting data from across operations within the same route that I’m having trouble with — that is getting data from multiple images processed in the first (top) route to save to as one variable in the end. Is that possible without resorting to an external data storage?

I’d prefer to keep it simple and all within Make, but I’ll experiment with writing out to a Google Sheet or something in the meantime.

3 Likes

Well, it took many hours and dozens of trials, but I figured it out. Actually, I figured it out and then some!

My solution, thanks to @samliew’s suggestion, was to write data out to new rows in a Google Sheet and then pull that data back in to write the Markdown and HTML, and then clear the sheet’s contents after each successful run.

A few tricky bits

  • The Instagram modules are separate for posts with a single image or video and posts with multiple items. The only way I could work out to account for both was to use several routers with filters. This meant a lot of duplicated modules, but at least it’s very clear about what’s happening.
  • Variable contents kept getting reused when multiple posts were processed in the same go, so I ended up renaming them depending on which route they are on. I also did a ‘Set Multiple Variables’ module at the end of Row 3 which sets the variables to be blank, although I’m not sure if that’s necessary. It’s working, so I’m not going to bother changing it.
  • Getting the Iterator set to the right source module was an exercise in patience. In the end, I figured out it needed to be the ‘Get Album Media’ module.

Extra AI fun

Since I was storing data per image upload anyway, I figured I would experiment with OpenAI’s Vision API module to create Alt Text for each of the images. Here is the prompt that I wrote (stored in the vision_api_prompt variable at the beginning and reused in both routes):

Please provide a functional, objective description of the image in no more than around 30 words so that someone who could not see it would be able to imagine it. If possible, follow an “object-action-context” framework: The object is the main focus. The action describes what’s happening, usually what the object is doing. The context describes the surrounding environment.

If there is text in the image, please include that verbatim (without extra line breaks), even if it extends the word count beyond 30 words. If there is no text, there is no need to mention it.

It does a great job! For example, here’s a photo it analyzed:
A pile of opened packages and respiratory N95 masks rests on a table, suggesting recent unpacking or sorting, in an indoor setting. The text on packaging includes "PRIORITY MAIL" and "STANLEY personal protection N95 Disposable Respirator."

And the alt text it generated:

A pile of opened packages and respiratory N95 masks rests on a table, suggesting recent unpacking or sorting, in an indoor setting. The text on packaging includes “PRIORITY MAIL” and “STANLEY personal protection N95 Disposable Respirator.”

Some Module Settings

Sharing

I’m pretty new to Make.com, so I don’t know if there’s an easy way to share blueprints without including sensitive data like access to my Instagram account, or my API keys for OpenAI or Micro.blog, but if anyone wants help with replicating this scenario, please let me know!

And if you have suggestions on how to simplify or improve this scenario, I’m all ears.

I’ll probably be sharing more about how I put this together on my blog soon, and you’ll be able to see it in action on my microblog/Mastodon.

3 Likes

Glad I could help, and thanks for returning to share your final solution (and extra tidbits).

Looking forward to reading it on your blog!

3 Likes