This is my old website presence for back date links compatability. Please click here to go to our new look. Or, you will be redirected in a minute.

Recently I was working on whatsapp integration for one of my app in php. I found that Twilio.com have no Coldfusion resource for api integration and I was not able to find any tutorial on web for this. So I thought lets wok on it for few hours.  


Step 1: First sign up on www.twilio.com
Verify your email and login to your twilio dashboard.

Step 2: Get a Trial Number & Verify your phone numbers
Here click on 'Get a Trial Number'. Wizard will give a virtual US based phone number with a trial balance of $15 approx.

Note down this  phone number, ACCOUNT SID and AUTH TOKEN


Verify list of your phone numbers that you want to  use for testing clicking 'verified numbers' link. Now verify them with otp received.

Step 3: Set up Sandbox on Twilio
Click on  'Programmable Messaging' link on Dashboard of twilio.

Click 'Try it out'. Click 'Try WhatsApp'. You will be on 'Twilio Sandbox for WhatsApp' screen.

Send the code to mentioned phone number from your one of verified phone number whatsapp app.

Click 'Verification Codes' template. You will be provided with a form to send message. Make a request and check your whatsapp device.
If you received the message, all is set. Sandbox for whatsapp message is set for 3 days.



 


Step 4: Writing code and testing.
Now go to you coldfusiion server web root folder and create file twilio.cfm and write following code.
(please refer ColdFusion 2018 Installation if you are lost in finding the folder)


<cfhttp    url='https://api.twilio.com/2010-04-01/Accounts/ACCOUNTSID/Messages.json' method='POST' multipart='yes'  username='ACCOUNTSID' password='AUTHTOKEN' result='res'>
   <cfhttpparam type='FORMFIELD' name='To' value='whatsapp:YOUR PHONE NUMBER' encoded='yes'>
   <cfhttpparam type='FORMFIELD' name='From' value='whatsapp:YOUR VIRTUAL PHONE NUMBER'  encoded='yes'>
   <cfhttpparam type='FORMFIELD' name='Body' value='Your Twilio code is hello' encoded='yes'>
</cfhttp>\
<cfdump var='#res#' />


(You can also download the file at https://github.com/ravapps/ColdfusionCodeTwilio)

Replace the following with values from your twilio dash board in the  code.
ACCOUNTSID
AUTHTOKEN
YOUR PHONE NUMBER
YOUR VIRTUAL PHONE NUMBER

Open browser window and navigate to url http://127.0.0.1:8500/twilio.cfm

You will receive a message 'Your Twilio code is hello' on  your whatsapp.

Ok Readers! Bye for now. More will come but please help me to keep me out of shackles of poverty. For this please pay a small amount of money of your choice on my payment page. I will keep putting articles here. --- Dheeraj
 





Views: 0