Search code examples
c#asp.net-mvc-5twiliotwilio-apitwilio-programmable-chat

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.


Solution

  • 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