Wednesday, August 07, 2013

Plivo SMS gateway API in ColdFusion

In one of my project there was some requirement to send receive SMS using Plivo( http://plivo.com/ ) SMS gateway. Plivo doesn't provides any documentation for integration with ColdFusin but it's not so difficult to do as you will see below. So, I thought to provide the exact implementation in ColdFusion it might save save you time.

Before going to coding part we must have the credential for Plivo SMS gateway. :)

This SMS API integration have 2 parts:

- Send SMS and get Sent/Received SMS details(from,to,message id, time).
- Receive inbound SMS and initiate some ColdFusion logic.

1. Send SMS and get Sent/Received SMS details

You can download the code from below URL directly.  https://gist.github.com/roulupen/153845250fdab07c82bc or you can look for the below code.

2. Receive inbound SMS and initiate some ColdFusion logic

For receiving SMS instantly you need to make the following set up in Plivo server.
Login to Plivo Account - > Numbers

Then you will see the following screen.

So, here you can see the no linked to your Application and click on the "Demo Play" it may be different for you. Then you will see the following screen.


In the above screen you have to set the Message URL and Message method to receive the incoming message to your application

So, here I can set:
Message URL as: http://myplivotesting.com/receiveMessage.cfm
Message Method: POST/GET

So, when one incoming message will come Plivo will make a HTTP call to that particular URL. So, what are the fields we will get?
As shown in the above image you will get the red marked form fields form the Plivo Server and other fields are generated by my application.

So, you can write your logic in receiveMessage.cfm file to receive SMS make perform your business logic.

Hope it will save your time.
For detail API information please visit following URL:  http://plivo.com/docs/api/message/

No comments:

Post a Comment

Followers