Short Message Service (SMS) has become a common tool for communication all over the world. It is very simple to send SMS from Odoo to any mobile number in the world using a web application programming interface (API). Let's have a look at how it works.
Web Application Interface (API)
To send SMS, we need an SMS Service provider. There are a lot of websites that provide Sms API Gateway. Some of them are listed below.
1. Twilio
2. Nexmo
3. Msg91
4. Textlocal
5. Sms Horizon
You can have a look at the video on
How to Configure MSG91 Odoo SMS Integration
How to get API from SMS Service Providers
To get SMS API, First, you need to set up an account on any one of the providers listed above or anyone, which you know. You need to pay a certain amount for sending SMS. The amount varies on providers you suggest. First, select a provider and then take a free trial.
1. Sign up using your mobile number and email address,
2. A message with a secret code is sent to your registered mobile number.
3. Login using that secret key.
4. Get SMS Authentication key and URL (This is what we need to send SMS).
Integrating Odoo with SMS
1.Create a file named
First, we need to create a .py file where we need to write code for sending SMS. This is the file that we run to send SMS to any mobile number
2.Code for sending SMS
import urllib
import urllib2
authkey =”xxxxxxxxxxxxxxxxxxx”
mobiles = “xxxxxxxxxxxxxxxxxxxxx”
message = "Connection Test Succeeded"
sender = "112233"
route = "default"
values = {
'authkey': authkey,
'mobiles': mobiles,
'message': message,
'sender': sender,
'route': route
}
url = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”
postdata = urllib.urlencode(values)
req = urllib2.Request(url, postdata)
response = urllib2.urlopen(req)
output = response.read()
print output
return True
3.Authentication key and URL
Paste authentication key, URL, and mobile number to above-described fields. You can also change the content of a message.
4. Free Trial
Take a free trial by running the above code in Odoo. You can see the message given below on the given number.