How to Send and Receive SMS Using Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ก.พ. 2025
  • Create a free Twilio account at twilio.com/try...
    You can find the text version of this content at www.twilio.com... and www.twilio.com...
    Please refer to the following documentation for information on Twilio phone numbers:
    www.twilio.com...
    For information on US 10-digit long code (10DLC) numbers, read our updates on regulatory compliance here: support.twilio...

ความคิดเห็น • 98

  • @yashaspong2054
    @yashaspong2054 ปีที่แล้ว

    Great video, super helpful and easy to understand, I am a Twilio fan!

  • @thefitnesscrew2940
    @thefitnesscrew2940 5 ปีที่แล้ว +6

    how can I store an SMS received from the user to my database?

  • @mohammedbaig9569
    @mohammedbaig9569 2 ปีที่แล้ว +2

    hey great video, was super helpful! I was wondering if there was perhaps someway for our application to not just automatically reply upon recieving an sms, but also somehow a way to store that incoming text for later? I know its a bit late so i understand if you don't have time to replt

    • @sha7r193
      @sha7r193 ปีที่แล้ว

      you could save it in an sql database, text file, or just a regular variable

  • @vatsalaykhobragade
    @vatsalaykhobragade 5 ปีที่แล้ว +5

    Thanks for the tutorial Straight to the point (:

  • @IAfoke
    @IAfoke 4 ปีที่แล้ว +2

    Hiya Mate,
    First and foremost, thank you for your videos. They’ve been such a great help to me and I’m sure, to a lot of people that watch them.
    I'm currently trying to automate a login process that uses a two-step authentication method and I was wondering if you would know how to create a listener for the text messages on my Mac to pick up the authentication code sent to my messages.
    Kind regards,
    Mani

  • @fenilpatel2858
    @fenilpatel2858 4 ปีที่แล้ว +3

    Is there any validity time period for a particular phone number for sending a sms and minimum limit number of sms?

  • @kensav
    @kensav 7 ปีที่แล้ว

    This is a great example of what to do with my Twilio number. Can you make a suggestion on how I can learn to create an app to have another number I can text with?

  • @jubair1440
    @jubair1440 ปีที่แล้ว

    nice to get the information from the original source

  • @sandovaldanny7
    @sandovaldanny7 3 ปีที่แล้ว

    I'm doing a project. I was just wondering if i can send images ? this for school

  • @r7butler
    @r7butler 4 ปีที่แล้ว +2

    Question: When a user responds to a text, will my application be able to tell the phone number that it came from?

  • @brendananukwu9149
    @brendananukwu9149 3 ปีที่แล้ว

    is there a way to set this up so it will notify clients before their appointments?

  • @Arunava_Sar
    @Arunava_Sar 2 ปีที่แล้ว

    hey, hello
    i can only send the message
    if you can just tell
    how to get the message from phone to pc ?

  • @swapnilchavan6794
    @swapnilchavan6794 4 ปีที่แล้ว

    I have a doubt about what to do if I have to send those particular messages to different numbers ? not me random different numbers which will be taken from a python variable?

  • @JohnWu
    @JohnWu 7 ปีที่แล้ว +1

    How can I receive sms to my twilio number and then just print into my terminal the body of the sms text?

  • @jamilgonzalez1198
    @jamilgonzalez1198 4 ปีที่แล้ว +1

    Great video! Is there any way to call sms_reply() from another python file? I want to take a text message response and store it in a variable in a separate python file. Any help would be amazing! Thanks!

    • @techcomparisons7289
      @techcomparisons7289 4 ปีที่แล้ว

      Yes, you can save the reply.py file and import it as a module into the other script you want to use it in. Then, you can call the function.

  • @muhammaddaud3184
    @muhammaddaud3184 4 ปีที่แล้ว +1

    Hey, so i want to actually receive that text to view it or reply to it, is there any way to do that or reroute it to my actual number?

  • @sahalasolusiindustri
    @sahalasolusiindustri 5 ปีที่แล้ว +1

    great tutorial. I have question for you ; How do you do on twillio code using python run alywas and automatically when PC server startup. thank you

    • @twilio
      @twilio  5 ปีที่แล้ว

      What operating system is the server using?

  • @snapmakertutorial3798
    @snapmakertutorial3798 2 ปีที่แล้ว

    What do you mean "Stored in environment variables? "

  • @kakudila242
    @kakudila242 7 ปีที่แล้ว

    At 3:20 for the "ngrok http 5000" it shows me this "You may only specify one port to tunnel to on the command line, got 2: [http 5000]" ... What can i do??

  • @HeartShapedEnd
    @HeartShapedEnd 7 ปีที่แล้ว +1

    For the minute 1:40
    What happens if fail to sent message. How I catch the exception or code error, or similar?

    • @HeartShapedEnd
      @HeartShapedEnd 7 ปีที่แล้ว +2

      twilio.rest.TwilioException
      :DD

    • @pikopapadoc2423
      @pikopapadoc2423 6 ปีที่แล้ว

      use try...except like all python code Roberto.

  • @QuimZangui
    @QuimZangui 4 ปีที่แล้ว +1

    Hi, does anyone know how to use with Django?

  • @hrithikasarkar7601
    @hrithikasarkar7601 4 ปีที่แล้ว

    I am only able to send a sms to the number with which I have an account in Twilio. Can't I send it to any other number instead?I get an error every time I try to do that.

  • @parthvivala4018
    @parthvivala4018 7 ปีที่แล้ว

    Why does `message.status` always return 'queued' ? I created a message, `message=client.messages.create(to,from_,body)`, instead of returning 'sent' or 'delivered', it always returns 'queued'. Why is that?

  • @maindepth8830
    @maindepth8830 4 ปีที่แล้ว

    is is possible to use my own number to send a message

  • @kashifumar4552
    @kashifumar4552 5 ปีที่แล้ว

    hi twilio i want to read inbound sms reply and to store it in a variable b/c i want to take decisions on reply.

    • @twilio
      @twilio  5 ปีที่แล้ว

      Inbound SMS trigger a webhook - an HTTP request to your server that you can use to run whatever code you want. For more information see th-cam.com/video/aLjSNfoJCYc/w-d-xo.html for more information

  • @meeraalmansoori5830
    @meeraalmansoori5830 4 ปีที่แล้ว

    I have tried that code there's no error in it, but I didn't receive the message on my number, could it effect that my name is Emirate (UAE) not a US number?

    • @twilio
      @twilio  4 ปีที่แล้ว

      Do you have any errors in the Twilio Console log? Also if you’re on a trial account you can only send to the number you verified.

  • @joseluismartins8340
    @joseluismartins8340 4 ปีที่แล้ว

    Where moment twilio stores env varibles into your Operating System?

    • @twilio
      @twilio  4 ปีที่แล้ว

      Twilio doesn’t store them, you need to: www.twilio.com/docs/usage/secure-credentials

    • @joseluismartins8340
      @joseluismartins8340 4 ปีที่แล้ว

      @@twilio Got it

  • @eviljeromepowell
    @eviljeromepowell ปีที่แล้ว

    Does this work if you have only a trial account... I did exactly what you did and it does not work at all. doesnt even show any received messages in the message logs.

  • @mehuljadav810
    @mehuljadav810 6 ปีที่แล้ว +4

    ERROR : ModuleNotFoundError: No module named 'twilio.rest'; 'twilio' is not a package

    • @twilio
      @twilio  6 ปีที่แล้ว +1

      Hi Mehul! Check to see if any of the points in this StackOverflow answer get you going in the right direction: stackoverflow.com/a/35185982

    • @mehuljadav810
      @mehuljadav810 6 ปีที่แล้ว +2

      @@twilio solved.. thank you

    • @twilio
      @twilio  6 ปีที่แล้ว +1

      Happy to hear that!

    • @caiofab
      @caiofab 5 ปีที่แล้ว +1

      @@mehuljadav810 How do you solved your code? ps: I'm a Win10 user.

    • @comradepeter87
      @comradepeter87 5 ปีที่แล้ว +1

      @@caiofab simply do pip install twilio

  • @anthonygrooms8459
    @anthonygrooms8459 5 ปีที่แล้ว

    how do i know make it so that i can text and receive the messages through the idle shell?

    • @twilio
      @twilio  5 ปีที่แล้ว

      I am not familiar with the differences with the IDLE shell but the basics of sending and receiving are the same. To send an SMS you make a request to the Twilio REST API and to receive a message you need a web endpoint for Twilio to make a request to.

  • @haiyuzhang4622
    @haiyuzhang4622 5 ปีที่แล้ว

    How can I send and receive picture messages by using Twilio?

  • @nishant6809
    @nishant6809 3 ปีที่แล้ว +1

    Sir can you help me for getting a single message of another device and number for resetting the Facebook password
    Love from India ❤️❤️❤️

    • @nishant6809
      @nishant6809 3 ปีที่แล้ว

      Sir my facebook account was hacked plz help pe 😭😭😭

  • @stefanv.d.b818
    @stefanv.d.b818 6 ปีที่แล้ว +2

    How much does it cost to receive/send an SMS?

    • @twilio
      @twilio  6 ปีที่แล้ว

      This depends on the country you are sending from and to. Here’s where you can find the exact price for your use case: www.twilio.com/sms/pricing

  • @lucaslugvib6673
    @lucaslugvib6673 5 ปีที่แล้ว

    Want to use the twilio number to verify a site but didn't get the verification code from the site. I need help

    • @twilio
      @twilio  5 ปีที่แล้ว

      Most likely the verification mechanism the site uses blocks phone numbers categorized as voip because people use them to get around verifying a physical phone they own.

  • @unique8721
    @unique8721 6 ปีที่แล้ว

    can someone please help im not sure how to even get to the commands where he is even typing this stuff in very frustrating hope you guys can help

  • @pragatisrivastava3259
    @pragatisrivastava3259 5 ปีที่แล้ว

    What if i need to send a message and store it on database? How can we do that..any help please

    • @twilio
      @twilio  5 ปีที่แล้ว

      Do you already have a database to work with or are you starting fresh?

  • @pickledmemes9517
    @pickledmemes9517 4 ปีที่แล้ว

    my ngrok does not work when I type it in. Any help?

  • @okaythisisepic3212
    @okaythisisepic3212 5 ปีที่แล้ว +1

    How would I access the received message?

    • @twilio
      @twilio  5 ปีที่แล้ว

      The text that was sent in is available in the 'Body' request parameter sent by Twilio to your server code.

  • @manishjain143
    @manishjain143 4 ปีที่แล้ว

    How and where do I read the message that was sent to Twilio?

    • @twilio
      @twilio  4 ปีที่แล้ว +1

      It’s sent to your webhook but you can also use the API to retrieve messages that have been sent.

  • @romboom2405
    @romboom2405 7 ปีที่แล้ว

    Hello I don't know why but i've an error report : "No module named 'twilio.twiml.messaging_response'; 'twilio.twiml' is not a package " but i install twilio as you recommand if it can help I'm on windows 10

    • @romboom2405
      @romboom2405 7 ปีที่แล้ว

      Great ! Such a common mistake I suppose. Thank you

    • @romboom2405
      @romboom2405 7 ปีที่แล้ว +1

      In fact yes. Fist of all I have checked my twilio account on "Programmable sms" and I've both incoming and outgoing messages. So when I send a sms with my phone to my twilio account it works. I tried to use your 2 different python scripts (" Hello mobile monkey" and "Robots are comming") to receive an sms but only the URL from the first one works. My browser return 404 not found for the 2nd one. Consequently I decided to work with the "Hello mobile monkey" to follow the last tutorial' instructions.So I run "ngrok http 5000" and copy/ past the https link on Twilio as indicated. But I don't have the line Account (Twilio plan : Twilio) and when i send a sms with my phone to my twilio account ngrok return me "POST /sms 502 Bad Gateway " So if you can help it would be great thank you !

    • @joshm7125
      @joshm7125 7 ปีที่แล้ว +1

      I was having the same Issue and was wondering if you happened to fix the problem? the 502 Bad Gateway.

  • @ahgrigor2453
    @ahgrigor2453 4 ปีที่แล้ว

    i get an error saying my "to" number is not valid even though it is verified. ??help

  • @subhamtiwari5579
    @subhamtiwari5579 5 ปีที่แล้ว

    how can i see inbound message on server (actually I want to see the message on server)

    • @twilio
      @twilio  5 ปีที่แล้ว

      The message text is available as the Body parameter in the request Twilio makes to your server.

  • @willhawkins4112
    @willhawkins4112 5 ปีที่แล้ว

    I'm unable to port using ngrok. Any help?

  • @bryansettles2686
    @bryansettles2686 6 ปีที่แล้ว

    "Trial accounts must verify a phone number before purchasing a Twilio number." I've verified my phone number 3 times and it's still saying this?

    • @twilio
      @twilio  6 ปีที่แล้ว

      Please reach out to our support team for help with this issue: support.twilio.com/hc/en-us/requests/new

  • @IQ88612
    @IQ88612 6 ปีที่แล้ว

    can i use django instead of flask?

    • @twilio
      @twilio  6 ปีที่แล้ว +1

      Sure can! Whatever framework works best for you. Here’s an example using django www.twilio.com/docs/sms/tutorials/server-notifications-python-django

    • @IQ88612
      @IQ88612 6 ปีที่แล้ว

      @@twilio thank you

    • @twilio
      @twilio  6 ปีที่แล้ว

      @@IQ88612 You're welcome!

  • @vasanth.s1658
    @vasanth.s1658 6 ปีที่แล้ว

    code is compiled succesfuly but when i reply to it in my phone...it is not responding to me

    • @pikopapadoc2423
      @pikopapadoc2423 6 ปีที่แล้ว

      This is python, it does not compile. It is an interpreted language.

    • @rimjhimjay7656
      @rimjhimjay7656 5 ปีที่แล้ว

      use a while True: loop and it will work

  • @dxviidmg4776
    @dxviidmg4776 7 ปีที่แล้ว +1

    great video but how can i send messages to different numbers without registering?

  • @germantellez2710
    @germantellez2710 5 ปีที่แล้ว +1

    How can i send 10 or 10k sms from python?

    • @dgajsek
      @dgajsek 5 ปีที่แล้ว

      same question. Have you made it work?

  • @osamaakhtar6525
    @osamaakhtar6525 5 ปีที่แล้ว

    How do I send a message to a WhatsApp group? Please help!

  • @mdimamul5163
    @mdimamul5163 4 ปีที่แล้ว

    Twilio i need help

  • @pakistanigamerayan6348
    @pakistanigamerayan6348 5 ปีที่แล้ว

    keyerror showing now how can i fix it

    • @twilio
      @twilio  5 ปีที่แล้ว +1

      Can you provide some more details than this? What line is giving the error?

    • @pakistanigamerayan6348
      @pakistanigamerayan6348 5 ปีที่แล้ว +1

      thanks for your reply its woking now and wanna ask u something that its just sending sms on my registered number how can i send messages to others number

    • @twilio
      @twilio  5 ปีที่แล้ว

      @@pakistanigamerayan6348 Sending SMS to your registered number is all you can do until you upgrade from the trial by providing payment information.

    • @pakistanigamerayan6348
      @pakistanigamerayan6348 5 ปีที่แล้ว

      all u mean to say that i have pay to upgrade my account

    • @twilio
      @twilio  5 ปีที่แล้ว

      @@pakistanigamerayan6348 That is correct!

  • @mistermanlysir
    @mistermanlysir 4 ปีที่แล้ว

    brain hurts fml

  • @richardwescott6433
    @richardwescott6433 5 ปีที่แล้ว

    You need to slow down this is not a speed reading course. You are trying to teach someone else. I know you know how but slow down so that someone else can learn how!

    • @twilio
      @twilio  5 ปีที่แล้ว

      Hi Richard! Thanks for watching. Sorry the pace of this didn’t work out for you. These quickstarts were designed to accompany the documentation they go with and to fit within a specific time window. Pacing can be a tricky thing to get right and I’m sorry we missed the mark on this one for you.

    • @richardwescott6433
      @richardwescott6433 5 ปีที่แล้ว

      @@twilio I found someone else on TH-cam his name is Rafeh the clever programmer. Just right and he explains everything! As I am a customer of Twilio. I would like to learn a much as I can. To use the products to the utmost. The more I can understand your products the more money I can spend with you!

  • @Schecter1989
    @Schecter1989 4 ปีที่แล้ว

    Wait... what? Why would I want to send a text message... to myself? I thought I was going to learn how to send a text message to (example) my friend's phone using Python. This was a bit disappointing.

  • @christianbautista9820
    @christianbautista9820 2 ปีที่แล้ว

    I get the error: ("Credentials are required to create a TwilioClient")
    twilio.base.exceptions.TwilioException: Credentials are required to create a TwilioClient.
    Any solution?