SMS Gateway in Kentico CMS
Have you ever dreamt of sending SMS messages directly from Kentico CMS? If your answer is YES, you should definitely read this post.
Following SMS gateway integration is based on Clickatell - the largest online SMS gateway covering 819 networks in 221 countries and territories. There are several ways how you can connect to Clickatell and send SMS messages, we have chosen the most popular way - HTTPS conection. Our goal was to deliver you the base Clickatell API integration which enables you to send SMS messages, that's what we made. However Clickatell gateway also supports some advanced features such as sending bulk SMS messages, receiving message delivery status, pushing MMS messages etc.
I am sure the price for a single SMS message is what you are interested in. Unfortunately, SMS messages are NOT FREE! See Clickatell message pricing for more details. Anyway, I think it's worth it. Their service seems to be really on a high level. We also found no problems while we were testing it. SMS messages were delivered immediately as if they had been sent from the cell phone.
Now let's have a look at the SMS gateway integration package, it includes:
1) SMS gateway
Following two classes represent the base API for sending SMS messages.
SMSMessage.cs - Simple data container representing SMS message.
string From - Phone number the SMS message should be sent from. If not set, phone number from settings is used.
string To - Phone number the SMS message should be sent to. It must be entered in international format.
string Text - Message text.
SMSProvider.cs - Simple SMS provider which enables you to send SMS messages.
string ApiID - API ID of your Clickatell account. If not se, API ID from settings is used.
string Login - Login of your Clickatell account. If not set, login from settings is used.
string Password - Password of your Clickatell account. If not set, password from settings is used.
SendSMS(SMSMessage message) - Ensures Clickatell account authentication (if not already authenticated) and sends specified SMS message
2) SMS notification gateway
Following class represents notification gateway for sending SMS messages to content changes.
SMSNotificationGateway.cs - custom nofitification gateway, integration is built on the customization model described here. It uses SMSMessage and SMSProvider classes mentioned above.
3) SMS sender web part
Simple web part which demonstrates how easy is to initialize and send SMS message.
4) SMS gateway settings
SMS Login - Login of your Clickatell account.
SMS Password - Password of your Clickatell account.
SMS API ID - API ID of your Clickatell account.
SMS From - Phone number the SMS messages are sent from.
Download SMS gateway integration package
Backup your original project so you can restore it in case something goes wrong.
Move export_sms.zip file into <your web project folder>/CMSSiteUtils/Import folder
Go to CMS Site Manager -> Sites and click Import site or objects link.
Choose export_sms.zip file and import it:
SMS notification gateway will be registered in CMS Site Manager › Development › Notifications section.
New SMS Sender web part will be created in SMS web part category.
New settings will be created in SMS gateway category in Site Manager › Settings.
Copy content of CMS folder into your web project folder:
\Bin\[ ALL DLLs from 5.5 version ]
Create your account at Clickatell.com. You will receive several free SMS credits to test the service for free.
Get your API ID.
Follow these instructions if you plan to make some changes to SMS gateway code:
Go to CMS Site Manager -> Settings and setup information about your Clicatell account
Now you are ready to send SMS messages (you can try SMS Sender web part as simple usage example).
Open your web project in Visual Studio and click File -> Add -> Existing project. Locate SMS gateway project folder which is included in the installation package and choose its project file. SMS gateway project will be added to your solution.
Remove all the references to the Kentico CMS libraries from the SMS gateway project and replace them with references to the corresponding DLLs from <your web project folder>/Bin folder.
Right click Bin folder in your web project folder, choose Add Reference option, click the Projects tab and choose SMS gateway project.
Make your changes to SMS gateway and compile the solution.
I hope that some of you will find it useful ;)