In https://www.twilio.com/docs/content/send-templates-created-with-the-content-template-builder explains how to send whatsapp messages.
How do we send messages with newlines in placeholder values?
The current sample is:
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
Message message = Message.creator(
new com.twilio.type.PhoneNumber("whatsapp:+18551234567"),
new com.twilio.type.PhoneNumber("whatsapp:+15551234567"),
"HXXXXXXXXX")
.setContentVariables("{\"1\":\"Name\"}")
.setMessagingServiceSid("MGXXXXXXXX")
.create();
What is the proper way to add new lines to Twilio Whatsapp messaging?
Tried .setContentVariables("{\"1\":\"Name\\nSex\"}") and caused an error.
I assume you are getting error 63005 which means WhatsApp rejected the message. This could be for a number of reasons, but it's very likely, that it happened because of the line break.
Instead, I would recommend adding the line break in the template and a second content variable, or comma-separate the values.