How to extract text from Anthropic Claude "Create a Prompt" output variabl

:bullseye: What is your goal?

How to extract text from Anthropic Claude module output to use in HTTP JSON body

:thinking: What is the problem & what have you tried?

The final HTTP module cannot correctly map the output variable from the Anthropic Claude — Create a Prompt module into the JSON body.
Errors Received
Attempt 1 — using 8.Content directly in the JSON body:

DataError: Function ‘replace’ finished with error! ‘{array}’ is not string or number.

Attempt 2 — using first(8.Content).text:

DataError: Function ‘first’ finished with error! ‘8.Content’ is not a valid array.

Questions for the Community

What is the correct output variable from the “Anthropic Claude — Create a Prompt” module to retrieve the response text?
Would “Simple Text Prompt” be a better choice for this use case instead of “Create a Prompt”?
How do we correctly insert that variable into a JSON string body without breaking the JSON format?

Additional Context

The WhatsApp API call itself works correctly — the URL, token and headers are all properly configured.
The Tools module successfully aggregates all Google Sheets rows into a single variable texto_resumen.
The Anthropic Claude module executes without errors — the issue is only in reading its output.

Ready to post, Jorge. :wrench:como lo lleno?10:23 PMLlénalo así:
Título (brief sentence):

How to extract text from Anthropic Claude “Create a Prompt” output variable

Category: Questions (ya está seleccionado con “error”)
Tags: anthropic, http, json
Cuerpo del mensaje — pega el informe que generamos en inglés.
¿Quieres que te lo reformatee para pegarlo directamente en ese editor? :memo:

Hey Jorge
Can you show some screenshots of what the output looks like and where you are feeding it to?

Cause you can’t get both errors at the same time -that it’s an array and that it is not an array.

Title: How to correctly insert Anthropic Claude “Text Response” into HTTP JSON body without breaking JSON?

SCENARIO FLOW:
Google Sheets (Search Rows) → Tools (Set variable: texto_resumen) → Anthropic Claude (Create a Prompt) → HTTP (POST to WhatsApp API)

GOAL:
Read rows from Google Sheets, concatenate them into a single variable, send to Claude AI for summarization, then forward the response to WhatsApp via Graph API.

THE PROBLEM:
The Text Response output from Anthropic Claude contains line breaks (
) that break the JSON string body of the HTTP module.
Body input method only offers “JSON string” — no Raw, no JSON application/json available.

ATTEMPT 1 — Direct mapping of 8.Text Response:
Error: InvalidConfigurationError → Bad control character in string literal at position 108

ATTEMPT 2 — replace(replace(8.Text Response; "
"; " "); char(34); “'”):
Error: DataError → Function ‘char’ not found

ATTEMPT 3 — replace(replace(8.Text Response; "
"; " "); "
"; " "):
Error: InvalidConfigurationError → Expected ‘,’ or ‘}’ at position 119

QUESTIONS:

  1. What is the correct way to sanitize Claude’s Text Response before inserting into a JSON string body?
  2. Is there a Make.com equivalent to char(34) to escape double quotes?
  3. Is there a better approach — different module or body input method — to avoid this entirely?

Welcome to the Make community!

Modules Using Raw JSON

The HTTP “Make a request” or an app’s universal “Make an API call” modules uses raw JSON to transmit data. The HTTP body content field does not automatically escape variables mapped into it, and if the mapped variables contain JSON reserved characters (e.g. from the output of an AI module, or another JSON string), it breaks the structure of your outermost JSON.

Simple text string in the value is okay :white_check_mark:

Inserting special characters (like " and line-breaks), makes the JSON invalid. :cross_mark:

Correctly escaped special JSON characters in the value :white_check_mark:

Escaping Variables Before Mapping Into Another JSON (string)

Most of the time, you cannot directly map variables containing text content into another JSON string without escaping them, as the variable might contain special characters that are reserved. Special characters in JSON needs to be escaped (encoded) as a “literal” character, otherwise they make the whole JSON invalid when you map the variable value when creating another JSON string.

A. Using “Transform to JSON” Module

You can escape variables by passing the text into the “Transform to JSON” module. You can also build a valid JSON string by using a Data Structure with the “Create JSON” module. Then, you can map the output of the Transform module into another JSON, or simply use the whole output of the Create module.

:warning: Note:

When using the “Transform to JSON” module on a string-type variable, the output should already contain the double quotes " " around your text, so when you map this output into your JSON, do not wrap another pair of double quotes around it!

B. Using “Replace” Function

Alternatively, you can use the built-in function replace to replace those special characters with their escaped versions. To do this, simply paste this into the field, and replace the 1.text variable:

{{ replace(replace(1.text; "/([""\\])/g"; "\$1"); "/\r?\n\r?/g"; "\n") }}
:high_voltage: Make Input Markup: Copy-paste the above into the field, including start/end curly brackets for it to import as intended :warning:

Further Information

For more information on JSON and escaping special characters, see:

There is no such function char( ) in Make. Where did you get this idea from?
To resolve this issue, simply remove the char function, and/or try one of the other methods above.

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

@samliew