Thank you for choosing prositeweb, your web development agency in Montreal. Please call us at +1 (514) 548-2165 if you need immediate support.
Texting from your website with Twilio can be easy, depending on the programming language you use. Email marketing and phone calls have become relatively complicated. Indeed, a study was able to show that the rate of opening emails has dropped relatively in recent years. If you have a website and are planning to try SMS marketing as an additional way to target customers, this article is for you. In this article, we look at how you can send SMS from your website with Twilio . At the end of the article, you can add the Twilio SDK to your project and add a form to send SMS. You will also see how to get a Twilio number and an API for your project.
Our article is intended for three types of profiles:
To follow this tutorial and easily apply it to your project, you must have the following basics:
You can read the article to understand how it works. However, we have provided two options that can help you:
Please contact us if you have any questions. [the_call_to_action title="Get a copy of the code for sending SMS from your site. The code is ready to use and documented" action_text="Download" action_type="modal" action_link="exampleModal" data_title=" Get the extension download link directly in your email " data_action =" download " data_link="prositeweb_paiement"]
To configure being able to send SMS from your site, you must follow the steps below.
To start, you will need to create a Twilio account and acquire some parameters such as: API sid, API authentication code and phone number. For example, in your dashboard, you can create API credentials for your project. When you sign up, you get a personalized phone number that you can use to automate texting.
To create a Twilio account, go to twilio.com and click on “register”. From there, you will see a registration form that gives you the option to try for free. The next step will be to enter the email address, then the password you need. Then the software will send you an email confirmation, from which you can approve your account and access it. Initially, you will have free credit that you can use to send SMS from your site or benefit from other Twilio services.
The procedure for creating an account on Twilio may change depending on their terms and conditions. I advise you to follow and read the steps of the registration procedure.
After creating your account and then logging into your dashboard, you will find your Account SID then your authentication code under the Dashboard ⇒ General tab (the link is console/project/settings). You can then copy these two pieces of information for your project.
To get your Twilio phone number, click on the three-dot menu panel at the bottom left, then a menu tab will display the menu link. From there, you'll see a list of phone numbers under the super network heading.
Thanks to the PHP classes or the SDK, you will be able to easily interact with the APIs. You can either use the composer to download or do it manually. So, we generally recommend Compositor, because it downloads with all updates. A manual update may be outdated or missing a dependency. In addition, we will see how to use the two approaches:
In addition, you can find more information about using the composer on the getcomposer.org site. Thus, you will find instructions there as well as detailed documentation on how to use the composer within the framework of a project. Note that you must have command line access to use and download the composer. Below are the general steps:
Using the command line, you can run the code below. Note that you may need to change the version of the sha256 depending on the current version. See the article on getcomposer.org for more details. Running the above code will generate the composer.phar file. To get the composer.json file, you can do the following:
If you want to have more information on how to create the composer.json file, you can refer to the official documentation. For this tutorial, you just need to create the composer.json file and paste the following code. Then from the command line you can run the code
composer require twilio/sdk
If you follow the instructions carefully, you will see a new folder called vendor in your main directory with some PHP files for your projects.
If you followed the steps above carefully, you can now include the SDK and start sending SMS from your website. The code below will help you to text anyone from your website.
Now that you have the code to send an SMS, you can create a form that will save you from doing it manually. For example, with the code above, you can modify the message, the recipient's phone number to send the SMS. However, if you want to automate the process, you can create a form from your dashboard to accomplish this. Below is an example of a form you can use.
The HTML code corresponding to the above form is as follows.
In addition to the HTML code, we will need an action file (PHP) which will receive a variable and send it to the SMS recipient. The PHP action may look like the code below:
The process of sending SMS from your website is quite simple with Twilio. You can use different programming languages. Also, if you have skills in developing plugins or extensions, it might be a good idea to convert it to a CMS extension. If you have any questions, please contact us; we will be happy to help you.
We are the experts in creating websites, online stores and functionalities for websites based in Montreal. Contact us today to create your website starting at $1,200.