Display Inline Image Attachments in Email Body from Survey123 Webhook

:bullseye: What is your goal?

I am trying to embed 3 images from Survey123 Watch Survey module into the body of an email. I do not want the images to be attachments.

:thinking: What is the problem?

Currently my scenario runs and the text information is visible in the email. However, the photos I want embedded into the body of the email show empty boxes. Occasionally the photos do get through and are visibly embedded in the email but rarely.

:test_tube: What have you tried so far?

I have tried multiple solutions from the community pages and web searches including iterators, download a file, aggregators, direct url in the body of an email and attachments. I have been unable to find a stable solution where the photos are visible in the body of the email.

:camera_with_flash: Screenshots: scenario setup, module configuration, errors



1 Like

Survey123 does not give normal image links. It gives links that only work for a short time. They are meant to be used right away and then they stop working.

When Make sends the email, it only sends the text. The images are not sent with it. Your email app tries to load the images later, when you open the email. At that point, the Survey123 link is often already expired, so the image cannot be loaded and you see an empty box.

That is why the images sometimes appear and sometimes do not. It depends on how fast the email is opened.

Potential solution to try:

Download → Re-host → Embed

Flow:

  1. Survey123 Watch Survey

  2. HTTP – Get a file

    • URL = attachmentInfo.field_x[].url
  3. Upload file to a public location

    • Make File Storage (public link)

    • S3

    • Cloudflare R2

    • Google Drive (anyone with link) / Dropbox (I usually use dropbox, much better than googledrive)

  4. Use the new public URL in <img src="">

Example email HTML

<p><b>Photo 1</b></p>
<img src="{{public_image_url_1}}" width="350">

<p><b>Photo 2</b></p>
<img src="{{public_image_url_2}}" width="350">

<p><b>Photo 3</b></p>
<img src="{{public_image_url_3}}" width="350">
1 Like

Welcome to the Make community!

You’ll need to use an Iterator-Array Aggregator, downloading the image data in-between. This allows you to insert the images in a specific array format with content ID.

Combining Bundles Using Aggregators

Every result/item from some module types (like Trigger / Iterator / List / Search / Match modules) can potentially and likely output more than one bundle. These multiple bundles will individually run subsequent modules once per bundle, which is not optimal in most cases:

  • one operation per bundle per module, which could lead to…
  • use of multiple credits per bundle per module (some modules use more than one credit)
View example screenshots

Aggregator Example

The “Search Rows” module runs one time, returning 999 results (999 bundles).

  • Without Aggregator: the tools module run 999 times (999 operations)


    (and if there are more modules, they run 999 times each)

  • With Aggregator: the tools module only runs 1 time (1 operation)

:warning: Warning: :police_car_light:
This can easily use your entire quota of credits if you are not careful or fail to understand this concept.

To “combine” multiple bundles into a single variable, so that you can process all of the items in a single operation, you’ll need to use an aggregator. Aggregators is a type of module that accumulates bundles and outputs one bundle (unless you are using “Group By”). An example of a commonly-used aggregator module is the Array aggregator module.

You can find out more about some other aggregator modules here:

Question: Which is the best aggregator do you think you’ll need for your use-case?

Setting the Correct Aggregator Source

You need to set the “Source Module” field of the aggregator to where the bundles are coming from. This is usually an iterator module, but can also be a search/list/repeater module, or even the trigger module!

Mapping a Complex (Collection) Structure Into an Array Field

The Array Aggregator module is very powerful because it allows you to build a new complex array of collections that matches a later module’s array field to map multiple items (collections) to it. Such fields initially may allow you to manually add individual items, but toggle the “Map” switch on, and you can map an array variable (from an Array Aggregator) containing multiple collections.

Simply select the respective “Target structure type” in an Array Aggregator module.

As you can see from the example above, the “Map” toggle on complex array fields are used when you have an array variable (like from an array aggregator).

:clipboard: Note: :light_bulb:
Other combinations of modules may also allow you to generate an array that matches a future module field’s array structure, like “Aggregate to JSON + Parse JSON”, or “Create JSON + Parse JSON”, but this is an advanced topic.

Question: Are you mapping your array into a field that accepts more than one item/collection?

For more information, see “Mapping with arrays” in the Help Centre. I also suggest going through the Make Academy, which also covers the use of Iterators & Aggregators.

— @samliew

Hope this helps! If you are still having trouble, please provide more details.

2 Likes