Skip to content
Advertisement

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?

Advertisement

Answer

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
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement