Otherwise, the user is informed that the message could not be scheduled. ![]() If the message was successfully scheduled, its SID (the message's unique id) and status are printed to the terminal. With the parameters initialised, they're passed to the call to create the scheduled message, (params). Note that the schedule type is set to fixed, which is required for scheduled messages. They cannot be scheduled more than seven days in advance.They cannot be scheduled less than fifteen minutes beforehand.However, keep two things in mind when scheduling messages: Feel free to change the duration to something further out in the future, if you desire. Then, the time that the message will be sent is initialised to seventeen minutes after the code is run. Each one of these must be publicly accessible, so that they can be downloaded and attached to the message.Īfter that, the message's validity period is set to three minutes. Then, a list of attachments to attach to the message, making it an MMS, is initialised. It sets the sender and recipient phone numbers, the message's body, and the Message Service to use. env, before initialising the new message's parameters ( params). The code starts off by loading the environment variables from. Log.Fatalf("Could not schedule the message. Log.Fatalf("Could not determine the time to schedule the message. Params.SetMessagingServiceSid(os.Getenv("TWILIO_MESSAGING_SERVICE_SID"))ĭuration, err := time.ParseDuration("17m") Params.SetTo(os.Getenv("RECIPIENT_PHONE_NUMBER")) To do that, change into the new project directory, and add module support to it, run the commands below.Īpi "/twilio/twilio-go/rest/api/v2010" The first thing to do is to set up a new Go project. Some prior experience with Go would be beneficial, though isn't necessary.Your favourite IDE or text editor for writing Go code.WhatsApp, whether on your mobile phone or desktop.A mobile phone number that can receive MMS.An MMS-enabled Twilio phone number and Messaging Service SID.If you are new to Twilio, click here to create a free account A Twilio account, whether free or paid.You don't need a lot to follow along with this tutorial, just: ![]() So, in this tutorial, I'm going to build on Miguel's tutorial and show how to send scheduled MMS and WhatsApp messages with Go and Twilio's Programmable Messaging API. Through these two technologies, you can send more engaging messages and reach up to two billion monthly active users. SMS, however, is just the beginning for communicating with your users. His tutorial was an excellent start to learning how to integrate communications functionality into your Go applications. Late last year, Miguel Grinberg showed how to send scheduled SMS with Go and Twilio.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |