Send WhatsApp Messages From Excel With VBA Using Twilio | Step-by-Step Tutorial 💬

Sdílet
Vložit
  • čas přidán 4. 06. 2024
  • 🔥 PLEASE NOTE 🔥
    According to Twilio, please be aware that the Twilio Sandbox for WhatsApp is meant for testing and discovery purposes only.
    The Sandbox expires three (3) days after joining. After this time, you need to re-join (by re-sending the 'code' to Twilio's number) to continue testing.
    More details can be found here:
    www.twilio.com/docs/whatsapp/...
    ___________________________________________________
    In this tutorial, I will show you, how you can send WhatsApp messages directly from Microsoft Excel with VBA.
    We will build a POST Request to Twilio’s API using VBA.
    ✅ Chapters:
    0:00 Demo
    0:31 Get ready with Twilio
    3:50 VBA Code
    10:01 Outro
    👉 Download the Excel template here: pythonandvba.com/twilio-whatsapp
    🤷‍♂️ If you have questions or encounter any errors, please feel free to post them in the comments section. I would be glad to answer your queries when time permits.
    🚩 VBA CODE:
    ___________________________________________________
    Sub WhatsApp()
    'Authentication
    ACCOUNTSID = "YOUR ACCOUNT SID" '-- REPLACE ME
    AUTHTOKEN = YOUR AUTH TOKEN" '-- REPLACE ME
    'Variables
    fromNumber = "%2B14155238886"
    toNumber = "RECEIVER NUMBER" '-- REPLACE ME
    BodyText = "YOUR MESSAGE TEXT" '-- REPLACE ME
    'Use XML HTTP
    Set Request = CreateObject("MSXML2.ServerXMLHTTP.6.0")
    'Specify URL
    Url = "api.twilio.com/2010-04-01/Acc..." & ACCOUNTSID & "/Messages.json"
    'Post URL with authentication
    Request.Open "POST", Url, False, ACCOUNTSID, AUTHTOKEN
    'Request Header
    Request.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    'Concatenate PostData
    postData = "From=whatsapp:" & fromNumber & "&To=whatsapp:%2B" & toNumber & "&Body=" & BodyText
    'Send the Post Data
    Request.send postData
    '[OPTIONAL] Get response text (result)
    MsgBox Request.responseText
    End Sub
    ◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️
    𝗖𝗢𝗡𝗡𝗘𝗖𝗧 𝗪𝗜𝗧𝗛 𝗠𝗘:
    🌎 Website: pythonandvba.com
    📝 GitHub: github.com/Sven-Bo
    ⭐ Discord: pythonandvba.com/discord
    ▶️ Subscribe: czcams.com/users/CodingIsFun?sub...
    🎉 𝗙𝗥𝗘𝗘 𝗘𝘅𝗰𝗲𝗹 𝗔𝗱𝗱-𝗶𝗻 𝘁𝗼 𝗯𝗼𝗼𝘀𝘁 𝘆𝗼𝘂𝗿 𝗽𝗿𝗼𝗱𝘂𝗰𝘁𝗶𝘃𝗶𝘁𝘆
    Get it here: pythonandvba.com/mytoolbelt
    📚 𝗥𝗲𝘀𝗼𝘂𝗿𝗰𝗲𝘀 𝗳𝗼𝗿 𝗹𝗲𝗮𝗿𝗻𝗶𝗻𝗴 𝗩𝗕𝗔 & 𝗣𝘆𝘁𝗵𝗼𝗻
    Check out my recommendations: pythonandvba.com/resources
    ☕ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲❓
    If you want to support this channel, you can buy me a coffee here:
    pythonandvba.com/coffee-donation

Komentáře • 83

  • @tunkyi7162
    @tunkyi7162 Před 3 lety +2

    That's awesome! You are such a contributor to the VBA world. I really love your channel. Keep going mate!

    • @CodingIsFun
      @CodingIsFun  Před 3 lety +1

      Thank you ver much! Glad you are enjoying the videos

  • @gabrielebasaglia5063
    @gabrielebasaglia5063 Před 3 lety +1

    Great video, it's very well done!
    Now I'm interested in sending also images.
    Thank you again!

    • @CodingIsFun
      @CodingIsFun  Před 3 lety

      Hi Gabriele,
      Thank you very much.
      Besides Twilio, there is also another method on how to send WhatsApp messages in Excel using VBA (& Selenium).
      If you are interested, kindly have a look at my tutorial:
      👉 czcams.com/video/Wn9L1MD_y0Y/video.html
      In the tutorial, I am not going to show how to send images, but I added this feature in the following Workbook:
      👉 bit.ly/2LIfHO6
      Hope that helps.
      Cheers,
      Sven

    • @gabrielebasaglia5063
      @gabrielebasaglia5063 Před 3 lety

      Hi Sven! Sorry for the late reply.
      I watched your video "WhatsApp messages in Excel using VBA (& Selenium)" and tried to make my Excel program. Besides, I was inspired by this other video czcams.com/video/3klMEX40fwg/video.html for the image sending part. So I write this lines of code in VBA to send images and it works:
      "'Click on Image icon
      bot.FindElementByXPath("//input[@accept='image/*,video/mp4,video/3gpp,video/quicktime']").SendKeys (imagePath)
      bot.Wait 2000
      bot.FindElementByXPath("//span[@data-icon = 'send']").Click"
      Today I watched your video "Send Bulk Messages/Images/Videos/Documents from Excel [Free Tool / Software]" and it's super interesting!
      Many thanks!
      Cheers,
      GB

    • @CodingIsFun
      @CodingIsFun  Před 3 lety

      @@gabrielebasaglia5063 Hi Gabriele,
      Thank you very much for your feedback. Your solution sounds great - well done!
      Cheers,
      Sven

  • @muntadher8087
    @muntadher8087 Před 2 lety

    Thank you so much! this has really helped me

  • @formulahallforall8934
    @formulahallforall8934 Před 3 lety +1

    Great cool idea thanks for video

  • @ermalgashimramori
    @ermalgashimramori Před 3 lety +2

    Great Content.

  • @pubudupanapitiya7208
    @pubudupanapitiya7208 Před 2 lety

    Wow this is really helpful !! Is there a way we can stop the auto closing chrome once the task is done

    • @CodingIsFun
      @CodingIsFun  Před 2 lety

      Thank you for watching the video. Actually, in this video, we did not automate the chrome browser.

  • @eingedi1231
    @eingedi1231 Před 3 lety

    Hi, I'm building an excel file to help me do the basic office tasks for my small business. I would like to send a picture from excel to a specific group in WhatsApp. the picture will be a print of one of the excel sheets. it will always be the same group and the same sheet which will be sent. I looked at both your videos of excel interacting with WhatsApp (Twilio and Selenium) and would like to ask will one of them could make that job? with the proper changes of course...
    And, your videos are really helpful, thank you very much for the time spent... !

    • @CodingIsFun
      @CodingIsFun  Před 3 lety +1

      Hi there,
      Thank you for watching the video.
      My approach would be as follows:
      1) Use the following version: czcams.com/video/lt2xhww_wcE/video.html
      2) Select as the 'Send Method': Searchbox
      3) Enter the WhatsApp GroupName in column A
      4) In Column B, enter the file path to the Image. (take the screenshot of the Daily Excel File and save it under the file name again)
      [Optional] You could automate taking & saving the screenshot of the specific Excel range using VBA as well
      Hope it helps!
      Cheers,
      Sven ✌

    • @eingedi1231
      @eingedi1231 Před 3 lety

      @@CodingIsFun What are the limitations of this metod:
      a. Can i change it and send picture with it?
      b. Can i send to a group and not just specific contact?
      Thanks

    • @gabrieltio1234
      @gabrieltio1234 Před 2 lety

      @@CodingIsFun i just download this version a week ago , but now the video is taken down by youtube,
      btw i also have a question, why the delay setting said it's in seconds, while the reality it's work in Minutes? i try to input "3" and the delay between the message is 3 minutes, then i tried again input "2" , the delayed time now changing into 2 minutes.
      so is it work in minutes? not seconds?

  • @formulahallforall8934
    @formulahallforall8934 Před 3 lety +1

    (I don't want to type phone numbers again and again) if you upload a video for 10 or 20 numbers we will put in excel and it will send messeges to all numbers with one click(messege would one by one or all at the same time)? For 20 or more numbers

    • @CodingIsFun
      @CodingIsFun  Před 3 lety +1

      Hi,
      you could do that with a "for loop" for instance.
      Here is a template I have created for you:
      bit.ly/38nXzC6
      Please keep in mind, with the free trial from Twilio, EVERY number needs to be registered beforehand.

    • @CodingIsFun
      @CodingIsFun  Před 3 lety +1

      Hi,
      I just wanted to inform you, that I have created an alternative solution using VBA & Web automation to send WhatsApp Bulk Messages in Excel for free.
      You can find the video here:
      👉 czcams.com/video/Wn9L1MD_y0Y/video.html
      Hope this solution works for you 🙏

  • @whoodiniiam
    @whoodiniiam Před 3 lety

    I am getting error and I would just like to ask do I substitute ​ " & ACCOUNTSID & "_from the section that you have commented specifyURL then do I also substitute ACCOUNTSID, AUTHTOKEN in the section for 'Post URL with authentication- with my own values??? thank u for the video

    • @CodingIsFun
      @CodingIsFun  Před 3 lety +1

      *Thanks for watching the video* What does the error message say?
      You only need to replace it once here:
      'Authentication
      ACCOUNTSID = "YOUR ACCOUNT SID" '-- REPLACE ME
      AUTHTOKEN = YOUR AUTH TOKEN" '-- REPLACE ME

    • @whoodiniiam
      @whoodiniiam Před 3 lety

      @@CodingIsFun {"code":20003,"detail":"Your AccountSid or AuthToken was incorrect."," message": "Aunthetication error_invalidusername","moreinfo":"www.twilio.com/docs/errors/20003","status":401}

    • @CodingIsFun
      @CodingIsFun  Před 3 lety +1

      @@whoodiniiam Thank you. Indeed it seems to be an authentication problem. Could you kindly check that you have entered a valid Authtoken & Accountsid? Thank you :)

  • @VisualKreation
    @VisualKreation Před 3 lety

    Nice helpful and informative video....TQ....Please make video for WA Group all contact save in Excel.

    • @CodingIsFun
      @CodingIsFun  Před 3 lety

      Thank you very much for your comment & video suggestion 😃

  • @darkmemes5867
    @darkmemes5867 Před 2 měsíci

    hello, how can we do this through whatsapp sender? after purchasing the premium. I am getting stuck there please help

    • @CodingIsFun
      @CodingIsFun  Před 2 měsíci

      Thanks for watching. Sorry, but I am not sure what you mean or what exactly you are looking for. Cheers, Sven ✌️

  • @sharafatalimalik7295
    @sharafatalimalik7295 Před 2 lety

    Hi you have any attendance system code? Which built in python ?

  • @tradingfield1439
    @tradingfield1439 Před 2 lety

    i keep getting "runtime error 429 activeX component can't create object. how can i fix this

    • @CodingIsFun
      @CodingIsFun  Před 2 lety

      Thank you for watching the video. Could you please try out the following solution?
      czcams.com/video/iW9PqsbwDc8/video.html
      I hope it helps!

  • @jolalla1
    @jolalla1 Před 3 lety +1

    Hey thanks so much for the code , but I am getting an error "Invalid TLS version,Upgrade required"...Please help

    • @CodingIsFun
      @CodingIsFun  Před 3 lety

      Hi. Which operating system are you using? Windows 10?

    • @jolalla1
      @jolalla1 Před 3 lety

      @@CodingIsFun windows 7

    • @CodingIsFun
      @CodingIsFun  Před 3 lety

      I was googling a solution for this error. A potential fix might be this one here: support.microsoft.com/en-us/help/3140245/update-to-enable-tls-1-1-and-tls-1-2-as-default-secure-protocols-in-wi

    • @jolalla1
      @jolalla1 Před 3 lety

      @@CodingIsFunI tried with windows 10 and it worked like magic!!...thank you once again..
      I have a couple of questions though..
      1.how can i post a message to a group ?
      2. how long will twilio trial account work because I realised that I was not getting charged from the credit balance of my trial account.
      .

    • @CodingIsFun
      @CodingIsFun  Před 3 lety +1

      @@jolalla1 Glad it is working for you.
      In regards to your questions:
      1. As for my understanding, sending messages to GroupChats is not (yet) supported.
      2. The sandbox is completely free. However, the Sandbox expires three (3) days after joining. After this time, you need to re-join (by re-sending the 'code' to Twilio's number) to continue using the Sandbox.

  • @MingAnIsAwesome
    @MingAnIsAwesome Před 2 lety

    How can we add pictures or pdfs together with the messages?

    • @CodingIsFun
      @CodingIsFun  Před 2 lety

      Thanks for watching the video. I have not implemented it, but it is also possible:
      www.twilio.com/blog/whatsapp-media-support
      You need to add the following to the 'postData'-string, which will be sent via the Post request:
      "MediaUrl=demo.twilio.com/owl.png"
      I hope this helps!

  • @giustinociccarelli2263

    Hi, I can't get it to work.
    This error shows up, could you help me?
    {code": 20404, "message": "The requested resource 12010-04-01/Accounts/STWILIO_ACCOUNT_SID/Messages.json was not found", "more_info": "www.twilio.com/docs/errors/20404", "status": 404)

    • @CodingIsFun
      @CodingIsFun  Před 3 lety

      Hi there,
      Could you kindly check if your URL variable looks like this one [Link to screenshot]:
      👉 prnt.sc/wgfrlm
      By the way, I have also another solution on how to send WhatsApp Messages via VBA [Link to video]:
      👉 czcams.com/video/Wn9L1MD_y0Y/video.html
      Please let me know if you need further support.
      Cheers,
      Sven

  • @moodraatu8733
    @moodraatu8733 Před 3 lety +1

    That's awesome!
    but Is there another way to send messages to phone numbers that I don't know (not my friends)
    because I can't tell them to send "join sense-lady" code to the twilio number???

    • @CodingIsFun
      @CodingIsFun  Před 3 lety

      Unfortunately, WhatsApp offers its API only to businesses.
      Other workarounds would involve Web automation using the online interface [web.whatsapp.com], e.g. using VBA Selenium.
      However, in my opinion, I find this kind of web automation also not ideal.

    • @moodraatu8733
      @moodraatu8733 Před 3 lety

      @@CodingIsFun yes you're right, web automation is not ideal.
      Can I use Whatsapp API as a normal person, is there any chance to me??
      and if I use web automation, is there any way to ensure that the message is sent usign Excel VBA code????
      thank you very much

    • @CodingIsFun
      @CodingIsFun  Před 3 lety +1

      @@moodraatu8733
      The requirements to use the WhatsApp API are listed down here:
      👉 developers.facebook.com/docs/whatsapp/getting-started/?locale=en_US
      There are actually many ways on how you could achieve this in Excel VBA.
      My prefered solution would be to use VBA Selenium.
      In the past I have uploaded a video on how to use VBA Selenium to retrieve stock information:
      👉 czcams.com/video/HZU2OtDa2eI/video.html&ab_channel=CodingIsFun
      Once you got familiar with Selenium, you could also automate/send WebWhatsApp using VBA.
      However, it would be a semi-automated solution as every time you would be asked to scan the QR Code in order to log-in.
      I shortly wrote a "starter-code", if you want to give it a try with Selenium:
      [You need to have VBA Selenium installed on your machine, as well as the current Chrome Webdriver, to run the code below]
      🚩 VBA CODE:
      Sub WebWhatsApp()
      Dim bot As New WebDriver
      'Init New Chrome instance
      bot.Start "chrome", "web.whatsapp.com/"
      bot.Get "/"
      MsgBox "Please scan the QR Code. After you are logged in, please confirm this MessageBox by clicking 'Ok'"
      ' ...open conversation
      ' ...send message
      End Sub
      Sorry, that I cannot help you further.
      Cheers,
      Sven

    • @moodraatu8733
      @moodraatu8733 Před 3 lety

      @@CodingIsFun thank you so much I really appreciated

    • @moodraatu8733
      @moodraatu8733 Před 3 lety

      Is this code you wrote a good to send hundreds of messages to hundreds of number phones?

  • @CodingIsFun
    @CodingIsFun  Před 3 lety +1

    🔥 PLEASE NOTE 🔥
    According to Twilio, please be aware that the Twilio Sandbox for WhatsApp is meant for testing and discovery purposes only.
    The Sandbox expires three (3) days after joining. After this time, you need to re-join (by re-sending the 'code' to Twilio's number) to continue testing/sending WhatsApp messages.
    👉 More details can be found here:
    www.twilio.com/docs/whatsapp/sandbox

  • @saddamskst
    @saddamskst Před 3 lety

    Its awesome but if we will use twilio then receiver will not get our number they are getting twilio's number and how much twilio's price if i planned to purchase

    • @saddamskst
      @saddamskst Před 3 lety

      Sir reply

    • @CodingIsFun
      @CodingIsFun  Před 3 lety

      Hi.
      Thank you for your feedback 🙏
      I totally agree with you. The solution is not ideal.
      In regards to the pricing, I would kindly refer you to the official Twilio pricing overview:
      www.twilio.com/whatsapp/pricing/us

    • @CodingIsFun
      @CodingIsFun  Před 3 lety

      @@saddamskst Hi,
      I just wanted to inform you, that I have created an alternative solution using VBA & Web automation to send WhatsApp Bulk Messages in Excel for free.
      You can find the video here:
      👉 czcams.com/video/Wn9L1MD_y0Y/video.html
      Hope this solution works for you 🙏

  • @vematrixtv8770
    @vematrixtv8770 Před 2 lety

    If we are using a business WhatsApp, is there still a need for this

    • @CodingIsFun
      @CodingIsFun  Před 2 lety

      Thank you for watching the video & your question.
      It depends on your use case. Kindly have a look at the following article, which explains the difference between WhatsApp, WhatsApp Business, and WhatsApp Business API:
      www.telemessage.com/difference-between-whatsapp-whatsapp-business-and-whatsapp-business-api/
      The main advantage of using an API is that you send programmatically multiple WA messages.
      I hope this helps!

  • @larryshamala8929
    @larryshamala8929 Před 2 lety

    Hi i have 2 queries;
    1. How do we attach videos, pictures or documents i.e pdf
    2. Is there way we can use Google sheet or app script so as it becomes automatic?

    • @CodingIsFun
      @CodingIsFun  Před 2 lety

      Thanks for watching.
      1. You need to adjust the code and pass an additional parameter to the API call, 'MediaUrl'. Please see below the documentation:
      support.twilio.com/hc/en-us/articles/360017961894-Sending-and-Receiving-Media-with-WhatsApp-Messaging-on-Twilio
      2. I am not familiar with Google Sheet / App script, so I cannot answer that question.

  • @thebiril1981
    @thebiril1981 Před 3 lety

    Good job but i have still an error.. Error run time 2147012889 (80072ee7). What i have to do ?

    • @CodingIsFun
      @CodingIsFun  Před 3 lety

      *Thank you for watching the video*
      Could you let me know what line in the VBA is code is highlighted after clicking "Debug" on the error message?
      Additionally, does the error message say "The Server Name or Address can not be resolved "?
      *BTW* I also have another tutorial on how to send WhatsApp messages directly from Excel (instead of using Twilio). Perhaps it might be interesting for you:
      👉 czcams.com/video/Wn9L1MD_y0Y/video.html
      Cheers,
      Sven ✌

  • @mohdzeeshan5437
    @mohdzeeshan5437 Před rokem

    I downloaded template and do all process but not working pls help

    • @CodingIsFun
      @CodingIsFun  Před rokem

      Thanks for watching. Unfortunately, with that bit of information, I cannot help you. You might want to take some time to write down which line of code is causing the error; let me know if you have modified the code from the tutorial, explain in more depth what you did to troubleshoot the problem and provide some more context. Thanks!

  • @leandrosantoscosta9621

    voce pode me enviar o primeiro video que fez sobre o whatsapp?

  • @edulinkinternationalcampus3189

    What happened to the video with the automated excel that sends whatsapp messages?

  • @riyazshroff1875
    @riyazshroff1875 Před 3 lety

    How can I send a single msg to multiple numbers using this??

    • @CodingIsFun
      @CodingIsFun  Před 3 lety

      Thank you for watching the video. I have created the following solution for this:
      👉 Excel template for sending a message to multiple numbers [Google Drive]: bit.ly/38nXzC6

    • @riyazshroff1875
      @riyazshroff1875 Před 3 lety

      @@CodingIsFun hey i saw your file but how it works??

    • @CodingIsFun
      @CodingIsFun  Před 3 lety

      @@riyazshroff1875 By time, I will make a dedicated tutorial about it. You would just need to input your number in Column A and select 'Text' if you want to send a text message. Once done, click the send button. If you download the file, I have inputted some sample messages. Kindly try it out :)

  • @eiehuicc
    @eiehuicc Před 3 lety

    first This is a free trial account
    Second you can only send to your phone
    Basically This is not working

    • @CodingIsFun
      @CodingIsFun  Před 3 lety

      Thank you comment.
      Yes, this is true. This method definitely comes with a lot of limitations.
      An alternative approach would be to automate the WebWhatsApp Interface via Excel VBA.

    • @CodingIsFun
      @CodingIsFun  Před 3 lety

      Here is the video I have created to show you an alternative solution on how to send WhatsApp Messages from Excel:
      👉 czcams.com/video/Wn9L1MD_y0Y/video.html&ab_channel=CodingIsFun

    • @AmazedExcel
      @AmazedExcel Před 9 měsíci

      @codingisfun how I can sent attachment to multiple WhatsApp contacts.