LINE bot to Claude API - newlines in customer messages break JSON

:bullseye: What is your goal?

I’m building a LINE chatbot that sends customer messages to Claude API via HTTP module. It works with single-line messages, but breaks when customers press Enter (line break).

:thinking: What is the problem?

Error: “The provided JSON body content is not valid JSON - Bad control character in string literal”

My HTTP Body:
{“model”:“claude-sonnet-4-20250514”,“max_tokens”:1024,“messages”:[{“role”:“user”,“content”:“{{3.events.message.text}}”}],“system”:“{{6.Prompt}}”}

I tried replace(text; newline; " ") in Set Variable but Make adds extra quotes/brackets that break JSON.

What’s the correct way to escape newlines before passing to HTTP JSON body?

:test_tube: What have you tried so far?

  1. Used Set Variable module with replace(3.events.message.text; newline; " ") - Make.com adds extra quotes and brackets that break the JSON

  2. Typed the replace function manually - same problem

  3. Used the variable picker - adds unwanted Events pill

Single line messages work perfectly. Only breaks when customer message contains a line break.

1 Like