Telerivet makes it easy to send airtime credits or bundles automatically in response to an incoming message as part of a poll/survey or other automated service, or via an API.
Sending Airtime from Polls and Custom Actions
The “Send airtime” action can be added within a poll or a Custom Actions service to send airtime in response to an incoming message or when triggered via Telerivet.
Within a Custom Actions service, add a "Send airtime" action. For each of the mobile networks you want to support, first select the country, then the mobile network; then the type of value to send (e.g. airtime credits, data bundle, or bundle) if the mobile network supports multiple types of values, then select the value to send.
To support multiple mobile networks, click "Add mobile network" and repeat for each mobile network. Because each mobile network offers different airtime products, you must specify which airtime value to send for each mobile network you want to support.
Each “Send airtime” action also acts like an if/then condition that is “true” if the contact is on one of your supported mobile networks, and “false” if the contact is on a different mobile network. This way, you can perform other actions such as sending a SMS message telling the contact that they should expect to receive airtime. It is also possible to add an "else" condition that will be triggered if the contact is not on one of the supported mobile networks.
Within Custom Actions, it is possible to trigger other actions if an airtime transaction succeeds or fails. To do this, click "add action on transaction success" or "add action on transaction failure", then add actions to a subroutine as in the example below:
To send airtime as a reward for completing a poll or survey, click "Add action for all responses" in your last question, then click "More actions...", then "Send airtime".
Be careful -- when adding a “Send airtime” action to an automated service that can be triggered by a contact, you are essentially letting anyone take money from you, simply by sending an SMS! There is no way to “undo” an airtime transfer or get a refund from Telerivet for airtime transfers, even if someone abuses an automated “Send airtime” action.
We highly recommend that you prevent contacts from triggering a “Send airtime” action multiple times.
When creating an poll that may be triggered by receiving a message from a contact, make sure that your poll settings only allow one response from each contact:
When using a “Send airtime” action, you can also add the contact to a group, and only trigger the “Send airtime” action if the contact is not yet in the group.
If you want to avoid the risk of sending airtime automatically, you can use the Approval Rules to set your daily limit to $0. Then, one of your project administrators could simply approve all airtime transfers before they get sent out.
Sending Airtime via Cloud Script API
Telerivet’s Cloud Script API doesn't have an API method specifically for sending airtime. However, you can use the generic service.invoke method to trigger a “Send airtime” action created via Custom Actions.
On the Services page, add a Custom Actions service, and click “When manually triggered for a contact”. Then, add a “Send airtime” action with each of the mobile networks you want to support, and the amount of airtime you want to send.
After saving the service, get the ID of the service from the address bar (it starts with “SV”).
Then, in a separate Cloud Script API service, you can trigger the send airtime action like so:
var SERVICE_ID = "<ID of Rules Engine service with Send airtime rule>";
var airtimeService = project.getServiceById(SERVICE_ID);
airtimeService.invoke({
context: 'contact',
contact_id: contact.id
});
Sending Airtime via the REST API
Like the Cloud Script API, Telerivet’s REST API doesn't have an API method specifically for sending airtime, so instead you can invoke a service created via Custom Actions containing a “Send airtime” action:
curl -s -u YOUR_API_KEY: \
"https://api.telerivet.com/v1/projects/PROJECT_ID/services/SERVICE_ID/invoke" \
-H "Content-Type: application/json" \
-d '{
"context": "contact",
"contact_id": "CONTACT_ID"
}'
Comments
0 comments
Please sign in to leave a comment.