Menu

The Sms Menu

Integration with Twilio

Playbasis platform can integrate with a Twilio account to be able to send sms. All users doing a specific valuable action (buy a product, etc…) can be for example rewarded and allowed to redeem and get a coupon by sms. The small tutorial below shows how to do.

Create a rule

Configure interface with Twilio

Create Goods

Import list of Goods

Set points to deduct when Redeem

API usage

Send http requests to Playbasis API following these steps below in order a user can redeem and get a sms coupon.

Step 1
Register a User. Fill up the mobile number : +6681234567

Step 2
When a User do a valuable action (buy a product, etc…), send the corresponding action to API. The received action will trigger the matched Rule and the User will get the points associated to this Rule / action. For example : 100 points.

Step 3
Send Redeem request to API for a User.
The system will deduct the number of points to redeem this good (100 points for example) from the User account. The user will receive a sms coupon with the good to redeem. The system remove one good from the list of available goods.
If the user has not enough points, cannot redeem this good.
If the good is not available in the system, cannot redeem this good (no points deducted).

Step 4
When a group of goods quantity is empty or almost empty, upload a new file of same group of goods to increase the quantity of goods in the Dashboard.

Example :
POST https://api.pbapp.net/Auth
Content-Type: application/x-www-form-urlencoded
api_key=1013164265&api_secret=ee37a5a85ac496841b42f2f94ac0b362

Get the token in return :
0cc9eb0bd6c57186xxxxxxxc3721b9039db7

Register a user :

POST https://api.pbapp.net/Player/player1/register
Content-Type: application/x-www-form-urlencoded
token=0cc9eb0bd6c57186xxxxxxxc3721b9039db7&username=player1&email=pascal+player1@playbasis.com&image=https://www.pbapp.net/images/default_profile.jpg&phone_number=+6681234567 Just in case, Update User without phone number :

POST https://api.pbapp.net/Player/player1/update
Content-Type: application/x-www-form-urlencoded
token=0cc9eb0bd6c57186xxxxxxxc3721b9039db7&phone_number=+6681234567

Send an action to engine :

POST https://api.pbapp.net/Engine/rule
Content-Type: application/x-www-form-urlencoded
token=0cc9eb0bd6c57186xxxxxxxc3721b9039db7&action=like&player_id=player1

Get user information :
GET https://api.pbapp.net/Player/player1/data/all?api_key=1013164265

Get the availability of a good in a group of good : GET https://api.pbapp.net/redeem/goodsGroup?api_key=1013164265&group=Gredeem100&player_id=player1 player Redeem a good in a group of good :

POST https://api.pbapp.net/redeem/goodsGroup
Content-Type: application/x-www-form-urlencoded
token=0cc9eb0bd6c57186xxxxxxxc3721b9039db7&group=Gredeem100&player_id=player1

Get in return
8830644924 => redeem code or use variable {{ code }}
54253396be4321404d2664b9 => ref_id of the redeem transaction done by the user

Send SMS coupon :

POST https://api.pbapp.net/Sms/goods
Content-Type: application/x-www-form-urlencoded
token=0cc9eb0bd6c57186xxxxxxxc3721b9039db7&ref_id=54253396be4321404d2664b9&player_id=player1&message=Congratulation, here is your coupon code: {{code}}.

For the moment, only 1 Variables you can use : {{code}} which display the code of the coupon to redeem.
We will have more variables available in future version.

Any special char used in the sms message (like ', ", ...) must be url encoded.

All the HTTP requests above can be sent using the Playbasis API Explorer http://doc.playbasis.com/pbapp

Example to redeem a good in a group of goods: