Multiline string in Slack Blocks

I am getting a response from OpenAI and trying to create a slack message. The response is in multiple lines and this breaks the slack JSON.

What is the best way to make this work

Quick and dirty would be to replace every newline with an emptystring
like this:
image
Copy past to sceanrio:
{{replace(1.text; newline; emptystring)}}

1 Like

Ha that is where i have been going wrong. I have been trying to use \n … Do you know where i can see a list of these variables like newline and emptystring

I tried this as well to no avail

{{replace(2.choices[].message.content; "/\n/gmi"; "")}}

image
Only those are available to be replaced.

2 Likes

FYI this seems to get the job done

{{replace(decodeURL(replace(encodeURL(2.choices[].message.content); "%0A"; "\n")); "\""; )}}

Hey @Tech_Bpeneur :wave:

I just wanted to quickly step in and say awesome work figuring this out with the help of @Levin :clap:

And thanks a lot for circling back to the community and letting us know what did the trick for you. This is super valuable stuff and we all 100% appreciate it :pray:

Just FYI: I marked your reply as a solution so that folks who are searching for similar info in the future know where to look :white_check_mark:

1 Like

@Levin how did you get to that screen to see those keywords that could be replaced?

@Michaela this may be a slightly better solution

{{decodeURL(
  replace(
    replace(
      encodeURL(2.choices[].message.content); 
      "%0A"; "\n"
    ); 
    "%22"; emptystring
  )
)}}
2 Likes

3 Likes