Explorer
Explorer

Reputation: 421

How to send whatsApp message to any number by using twilio using c#

I am new to Twilio

below is my code to send whatsapp message using C#

    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        TwilioClient.Init(Model.AccountSid, Model.AuthToken);
       
        var message = MessageResource.Create(
           
           //whatsapp message 
           to: new PhoneNumber(Model.To), from: new PhoneNumber(Model.From),
           body: "Ahoy from Twilio!!!!!"
         );
        
        Console.WriteLine("Message SID: " + message.Sid);
    }

Model.To have my whatsapp number which I have used while registering with twilio.

Model.From have Twilio's WhatsApp number

if I run this console application then I get message on my whatsapp number

but when I try to send message to my friend's WhatsApp number by assigning that number to Model.To, I am not getting message on that number

How can I achieve it? is there any other way to achieve it without twilio?

Thanks in advance.

Upvotes: 0

Views: 4075

Answers (2)

Explorer
Explorer

Reputation: 421

If you are using the Trial account then

1)first verify that number from here https://www.twilio.com/console/phone-numbers/verified

2)after verifying the number ,send whatsapp message from verified number to the twilio's whatsapp number using your sandbox code (code will be like e.g join XYZ-PQR)

3)after sending the whatsapp message that number will join your sandbox and you will be able to send message on that number

Upvotes: 0

Alan
Alan

Reputation: 10791

Did you check the Twilio Debugger for errors. If you are sending the first message from Twilio out to the WhatsApp user, you must initially use a Template, as detailed here.

Upvotes: 1

Related Questions