Issues when trying using Twilio to send SMS messages

97 views Asked by At

Good morning guys. I'm new using twilio and I'm strugging to make it work for me. I need use it to send SMS messages basically. I'll give you guys some context. I'm currently located in Brazil and I'm using a twilio free account. My twilio virtual phone number is from US. I was expecting to receive the SMS in my local number (Brazil) from my twilio virtual number. Actually, I'm confused because I read there are some restrictions, policies and details. Not sure if I'm doing something wrong in my code or if something is missing.

  1. Shoud I be able to receive the SMS messages in my local number (Brazil) from my twilio number (US)? Or the numbers need to be in the same country?

  2. I'm using Java.The only thinhg a did for now was adding twilio as maven dependency. Is it required to add any other config or install something to make it work?

Please, any help would be very helpful. This is my code. When the create method is called, it seems something is crashing. It never gets to the line where I'm printing the message's SID.

Twilio.init(ACCOUNT_SID, AUTH_TOKEN, ACCOUNT_SID);
Message message = Message.creator(
       new com.twilio.type.PhoneNumber(""), // using a phone from Brazil
       new com.twilio.type.PhoneNumber(""), // using my twilio from 
       "HI TEST!")
       .create();
System.out.println(message.getSid());
1

There are 1 answers

0
Luis Leao On

SMS capable numbers in Brazil are Private Beta numbers and they are available through our sales team.

Anyway if you need one there are some steps you need to create your regulatory bundle, which means send you company document (cartão CNPJ) and a valid billing address (comprovante de endereço válido) for the type of number you like. This documents are required by Anatel (the Brazilian telecommunication agency).

About the code, it looks fine to me, except that the from and to numbers looks like they are in a different order. Without the error message isn't possible to go further with some other explanations, so I'll try to go into some patterns that could help you solve this.

Both numbers should use the standard E164 format (+ country code, regional code and number).

Please also keep in mind that you need to import some of the classes:

import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Message;
import com.twilio.type.PhoneNumber;