Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a line break in my Twilio SMS message?

Using Java/Scala. I am sending this string (an sms message) to a user mobile number by a Twilio Account.

var body = "Hello from Govind Singh Nagarkoti! Your verification code is " + code

This goes out to the user mobile, in 1 line.

I want a newline after the first sentence. I want the user to receive:

"Hello from Govind Singh Nagarkoti!
 Your verification code is 240190" 

How can I enter a line break?

like image 594
Govind Singh Avatar asked Jun 14 '14 10:06

Govind Singh


People also ask

What is a line break in texting?

Also called "EOL" (end-of-line), "newline," and "hard return," a line break code is generated when the Enter key is pressed, When typing a command on a command line, pressing Enter executes the command. When typing text, pressing Enter signifies the end of the paragraph, and subsequent text goes to the next line.

How do I add a new line in API?

Using a <br> tag will give you a new line. Or you can use <p></p> tags to break your content into paragraphs. The raw parameter is markdown, so you need two newlines to make a new paragraph. You may need both carriage return and line feed.

How do I send a message to multiple numbers in Twilio?

Each new SMS message from Twilio must be sent with a separate REST API request. To initiate messages to a list of recipients, you must make a request for each number to which you would like to send a message. The best way to do this is to build an array of the recipients and iterate through each phone number.


1 Answers

If you are using an official Twilio library, the proper syntax is \n.

In your case, this should work:

var body = "Hello from Govind Singh Nagarkoti! \n Your verification code is " + code
like image 125
alphaleonis Avatar answered Oct 24 '22 18:10

alphaleonis