Afrinet Telecoms Enabling Solid Customer Relations

Integrations Customer Survey

  • Home
  • Integrations Customer Survey
image
image
image
image
Quick Start

Leverage the power of SurveySasa API and have multiple integrations with any of your system.
SurveySasa API is meant to smoothen your business process and minimize the need to have multiple systems when serving your customers.
With a click of a button, you will have the power to push the current survey to your customer instantly.
For convenience, we left it open on which point of the service process you can push the survey from.
This is to ensure you can do implementation(s) that suits your business.

# Endpoints

SurveySasa ships with two default endpoints

                                
1. Get Current Survey: "https://surveysasa.com/api/v1/surveys/survey" 
2. Send Survey : "https://surveysasa.com/api/v1/surveys/send"
# Authorization

SurveySasa uses Access Token to Authorize API calss. Create API Key to get the access token

                                
CURLOPT_HTTPHEADER => array(
'Accept: application/json',
'Authorization: Bearer {access-token}'
),
                                
                            
Current Survey

Current survey is determined by two factors:

  • User: User that belongs to a department will only push the current survey linked to their department. If a user is not linked to any department, the system will pick the latest survey with no departments.
  • Survey: Survey should be linked to API
# Payload
PHP
                                            
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://surveysasa.com/api/v1/surveys/survey',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('email' => 'user-email'),
CURLOPT_HTTPHEADER => array(
'Accept: application/json',
'Authorization: Bearer access-token'
),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
                                            
                                        
NodeJs
C#
                                            
var client = new RestClient("https://surveysasa.com/api/v1/surveys/survey");

var request = new RestRequest(Method.POST);

request.AddHeader("Accept", "application/json");
request.AddHeader("Authorization", "Bearer access-token");
request.AddParameter("email", "user-email");

IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
                                            
                                        
Python
                                            
import requests

url = "https://surveysasa.com/api/v1/surveys/survey"

payload={'email': 'user-email'}

headers = {
'Accept': 'application/json',
'Authorization': 'Bearer acess-token'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
                                            
                                        
Ruby
                                            
require "uri"
require "net/http"

url = URI("https://surveysasa.com/api/v1/surveys/survey")

https = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Accept"] = "application/json"
request["Authorization"] = "Bearer access-token"
form_data = [['email', 'user-email']]

request.set_form form_data

response = https.request(request)
puts response.read_body
                                            
                                        
# Response
Validation Error
                                            
//email not valid
{
"code": 400,
"message": "You must provided a valid email address"
}

//user not found
{
"code": 404,
"message": "User with that email address not found"
}
                                            
                                        
Success
# Send Survey

When sending survey, you need to provide the user and customer data.
Customer phone number must be present and be formatted as follows 254712345678

# Payload
PHP
                                            
$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => 'https://surveysasa.com/api/v1/surveys/send',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array(
//user data
'user' => 'user-email',
//customer data
'first_name' => '',
'last_name' => '',
'phone' => '254xxxxxxxxx',
'email' => ''
),
CURLOPT_HTTPHEADER => array(
'Accept: application/json',
'Authorization: Bearer access-token'
),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
                                            
                                        
NodeJs
                                            
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://surveysasa.com/api/v1/surveys/send',
'headers': {
'Accept': 'application/json',
'Authorization': 'Bearer access-token'
},
formData: {
//user data
'user': 'user-email',
//customer data
'first_name': '',
'last_name': '',
'phone': '254xxxxxxxxx',
'email': ''
},
};

request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
                                            
                                        
C#
                                            
var client = new RestClient("https://surveysasa.com/api/v1/surveys/send");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Accept", "application/json");
request.AddHeader("Authorization", "Bearer access-token");
request.AlwaysMultipartFormData = true;
//user data
request.AddParameter("user", "user-email");
//customer data
request.AddParameter("first_name", "");
request.AddParameter("last_name", "");
request.AddParameter("phone", "254xxxxxxxxx");
request.AddParameter("email", "");

IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
                                            
                                        
Python
                                            
import requests

url = "https://surveysasa.com/api/v1/surveys/send"

payload={
# user data
'user': 'user-email',
# customer data
'first_name': '',
'last_name': '',
'phone': '254xxxxxxxxx',
'email': ''
}


headers = {
'Accept': 'application/json',
'Authorization': 'Bearer access-token'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
                                            
                                        
Ruby
                                            
require "uri"
require "net/http"

url = URI("https://surveysasa.com/api/v1/surveys/send")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Accept"] = "application/json"
request["Authorization"] = "Bearer access-token"

form_data = [
# user data
['user', 'user-email'],
# customer data
['first_name', ''],
['last_name', ''],
['phone','254xxxxxxxxx'],
['email', '']
]

request.set_form form_data, 'multipart/form-data'
response = https.request(request)

puts response.read_body
                                            
                                        
# Response
Validation Error
                                            
// no data or invalid input
{
"code": 400,
"message": "Validation Errors",
"error": {
"user": [
"The user field is required."
],
"phone": [
"The phone field is required."
]
}
}

{
"code": 400,
"message": "Validation Errors",
"error": {
"user": [
"The user must be a valid email address."
],
"phone": [
"The phone format is invalid."
]
}
}

//user not found
{
"code": 400,
"message": "Validation Errors",
"error": {
"user": [
"The user must be a valid email address."
]
}
}
                                            
                                        
Success