Extracting nested text property from JSON array in HTTP module response (aka the problem Claude got me into but can't get out of)

:bullseye: What is your goal?

I want to automate a weekly industry news report, compiled and organized in a specific way by Claude, that’s sent to my Gmail at the same time every week.

:thinking: What is the problem?

Background:
I have a working 4-module scenario:

Webhook trigger
Set Variable (stores today’s date)
HTTP - Make a Request (calls Anthropic Claude API)
Gmail (sends HTML email)

The Problem:
The HTTP module returns a JSON response from the Anthropic API. I need to extract a specific text value from a nested array inside that response and pass it to the Gmail module as the email body.

What I need:
I need to extract the text property from the last item in the content array, which contains my HTML report.

What I know for certain:
Parse response is set to true in the HTTP module
When I click the HTTP module output bubble, I can see content as a collapsible section with numbered items inside
The last numbered item (currently item 12, but this number changes each run depending on how many web searches Claude performs) has type: text and contains either all or part of my HTML report
When I click through the output tree to map it, Make.com generates: 13.data.content.text

:test_tube: What have you tried so far?

What I’ve tried (and what I’m unsure about):

{{13.data.content.text}} — mapped automatically by clicking through output tree — returns blank email
referencing content item 12 text - hardcoded index — returns blank email
referencing last content item text — returns blank email (I was told last is a valid Make function but I’m not confident this is correct syntax)
‘13.data.content’ is not a valid array

Key uncertainties I have — likely where the problem lies:

Is 13.data.content the correct way to reference this array, or should it be 13.content or something else?
Is hardcoded index syntax [12] correct for Make, or does Make use different syntax for accessing array items by index?
Is there a correct Make function to get the last item of an array, or to filter array items by a property value (e.g. get all items where type = “text”)?
The map function error suggests Make may not be recognizing 13.data.content as a valid array at all — is there a different way to reference it?

What would a working solution look like:
Either a way to reliably extract the last text-type item from the content array, or a way to filter the array by type = “text” and get the last matching item’s text property.

Hi @Kendal_Carlson,

Welcome to the Community!

First of all, please invalidate the Anthropic API key. It became public when you shared the scenario above.

Answer to your question, follow these steps:

  1. Set ‘Yes‘ for Parse Response in the HTTP module

  1. put the following in Gmail’s content field to get the last key
    {{get(last(13.data.content); “text”)}}

last() function fetches the last array key, and get() is used to fetch any value path of a collection/array.

Also, you could have used the Anthropic API module instead of using the HTTP module.

Also 2, you can use the Authentication Type in the HTTP Request module and save the API key in the Keychain.

Use the formula like this: {{last(13.data.content.text)}}