JSON text line break

Hi, I need to separet lines from a text the bot is recieving by JSON
On whatsapp the text shows \n instead of line break. How can I fix this?

Same question was solved in this post, but sadly I cant see images on the answer.

Best regards,
Martin

1 curtida

Good afternoon, welcome to our community :smiley:

1 - As input variable use contact.identity
image

  1. In the dynamic content put the return of the script
    image

3 - Try setting the message to a constant. And in the WhatsApp component pass this variable.

That way on WhatsApp it should work. Internally we use it and it works.
Try it this way and see if it works.

1 curtida

Hi, thanks for your answer!
In this case, I’m not trying to pass a menu.
I’m just trying to add some format to text.

I have a text variable which comes from a JSON, like this:

{
  "data_SN": "Ticket: HRC2055278; Descripçao: Deseja informações sobre a inclusão de dependente (21 anos); Resoluçao: Informamos que até o momento não houve a manutenção de dependente da Fernanda de Oliveira Leal.\n\nTicket: HRC2055279; Descripçao: Deseja informações sobre a inclusão de dependente (21 anos); Resoluçao: Informamos que até o momento não houve a manutenção de dependente da Fernanda de Oliveira Leal.\n\nTicket: HRC2055280; Descripçao: Deseja informações sobre a inclusão de dependente (21 anos); Resoluçao: Informamos que até o momento não houve a manutenção de dependente da Fernanda de Oliveira Leal.\n\nTicket: HRC2055281; Descripçao: Deseja informações sobre a inclusão de dependente (21 anos); Resoluçao: Informamos que até o momento não houve a manutenção de dependente da Fernanda de Oliveira Leal.\n\n"
}

The problem is that I’m not geting the line breaks (\n) on the message, they are appearing literal as “\n”

So, I understand that if I capture my JSON, and use a script I can format this text to be shown as:

Ticket: HRC2055278; Descripçao: Deseja informações sobre a inclusão de dependente (21 anos); Resoluçao: Informamos que até o momento não houve a manutenção de dependente da Fernanda de Oliveira Leal.

Ticket: HRC2055279; Descripçao: Deseja informações sobre a inclusão de dependente (21 anos); Resoluçao: Informamos que até o momento não houve a manutenção de dependente da Fernanda de Oliveira Leal.

Ticket: HRC2055280; Descripçao: Deseja informações sobre a inclusão de dependente (21 anos); Resoluçao: Informamos que até o momento não houve a manutenção de dependente da Fernanda de Oliveira Leal.

Ticket: HRC2055281; Descripçao: Deseja informações sobre a inclusão de dependente (21 anos); Resoluçao: Informamos que até o momento não houve a manutenção de dependente da Fernanda de Oliveira Leal."

on the whatsapp message.

This is how the message looks on the builder

How can I achieve that?

2 curtidas

If this is the result you want:

image

Do the following:

In blip chat you must use
image
and in WhatsApp channel “\n”.

To differentiate, just put the contact.identity system variable in the script.
A simple example flow follows.
llalaa.json (8,2,KB)

1 curtida

Hi! Thanks for your answer.
That’s not the result I need. Well that’s the format of the result I need.

I dont need the text to be always the same. My text is coming from an HTTP request, and it will change every time the robot executes.
When I display that text coming from HTTP, In the JSON formated as I showed before, the \n are displaying as characters “\n” and not as a line break.

So, my question is, how can I format this “HTTPResponse@MyData” where “HTTP Response” is the variable capturing the response from the HTTP request, which contains the field “MyData”. A string field containing “\n” for line breaks.

This is the JSON coming from HTTP. It’s saved on the variable HTTPResposta2

{
  "data_SN": "Ticket: HRC2055278; Descripçao: Deseja informações sobre a inclusão de dependente (21 anos); Resoluçao: Informamos que até o momento não houve a manutenção de dependente da Fernanda de Oliveira Leal.\n\nTicket: HRC2055279; Descripçao: Deseja informações sobre a inclusão de dependente (21 anos); Resoluçao: Informamos que até o momento não houve a manutenção de dependente da Fernanda de Oliveira Leal.\n\nTicket: HRC2055280; Descripçao: Deseja informações sobre a inclusão de dependente (21 anos); Resoluçao: Informamos que até o momento não houve a manutenção de dependente da Fernanda de Oliveira Leal.\n\nTicket: HRC2055281; Descripçao: Deseja informações sobre a inclusão de dependente (21 anos); Resoluçao: Informamos que até o momento não houve a manutenção de dependente da Fernanda de Oliveira Leal.\n\n"
}

This is how whatsapp shows HTTPResposta2@data_SN
image

This is how it’s on the builder

This is where I send the HTTP and capture the response

Where should I use the JSON you sent on the example? How do I applay it to my variable HTTP response?

Thank you very much for trying to help me!

Best regards,
Martin

2 curtidas

Welcome to our community, @Martin.Gesteira :sparkles::sparkles::sparkles:

2 curtidas

The result obtained by Whatsapp was this, I believe it is what you want.

1 - Make an http request with the object you want.

2 - In the return of this request, make a script separately with the input variable with the return of the request and in the script you treat the key that contains the text and return it. That way the “\n” takes effect.

3 - As the response of the request can change, maybe it’s cool to make a logic in the string to break the text in a certain part. For example: I check the string and where I have the word “Ticket” I can add the “\n\n”

It’s just important to note that for “\n” to work, the string key needs to be treated and returned pure.

Here’s a practical example:
testebot576.json (6,KB)

2 curtidas

Nice, thanks for your answer.
I understand that I must add a “Script” Actuion, afther I get the HTTP Response.
But, do you have an example of how this script should look like? I’m quite new to Blip and How it works.

Thank you very much for all your help!

2 curtidas

So, to develop this script you need to guarantee that the request will always come in this format. Is there a possibility that this format will change, or did I come something different? Or follow this pattern? If you follow this pattern I can develop something here that can help you.

1 curtida

finally got it working with this!
Parse 1st, concat it’s values into a single string =)
image

Thank you for your help!

1 curtida

Shooooow! :star_struck: Now you can get anything on Blip, I’m glad I could help in some way, whenever you need you can count on us!!

1 curtida