Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions Campaign_Samples/js/bulk_get_campaigns.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ var accountSid = "<your Exotel Sid>";
var apiKey = "<Your API Key>"
var apiToken = "<Your API Token>";
var encoding = Buffer.from(apiKey + ':' + apiToken).toString('base64')
var options = { method: 'GET',
url: 'https://api.exotel.com/v2/accounts/'+ accountSid +'/campaigns',
qs: { page_size: '1', page: '1' },
headers:
{
Authorization: 'Basic ' + encoding,
'Content-Type': 'application/json' } };
var options = {
method: 'GET',
url: 'https://api.exotel.com/v2/accounts/' + accountSid + '/campaigns',
qs: {
page_size: '1',
page: '1'
},
headers: {
Authorization: 'Basic ' + encoding,
'Content-Type': 'application/json'
}
};

request(options, function (error, response, body) {
if (error) throw new Error(error);
Expand Down
36 changes: 21 additions & 15 deletions Campaign_Samples/js/create_campaign.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,27 @@ var accountSid = "<your Exotel Sid>";
var apiKey = "<Your API Key>"
var apiToken = "<Your API Token>";
var encoding = Buffer.from(apiKey + ':' + apiToken).toString('base64')
var options = { method: 'POST',
url: 'https://api.exotel.com/v2/accounts/'+ accountSid + '/campaigns',
headers:
{
Authorization: 'Basic ' + encoding,
'Content-Type': 'application/json' },
body:
{ campaigns:
[ { caller_id: '0XXXXXXXXX1',
url: 'http://my.exotel.in/start/189810',
from: [ '+91XXXXXXXXX4', '+91XXXXXXXXX5' ],
schedule: { send_at: '2018-11-08T14:20:00+05:30' },
status_callback: 'http://<callback custom domain>/1gvta9f1',
call_status_callback: 'http://<callback custom domain>/1gvta9f1' } ] },
json: true };
var options = {
method: 'POST',
url: 'https://api.exotel.com/v2/accounts/' + accountSid + '/campaigns',
headers: {
Authorization: 'Basic ' + encoding,
'Content-Type': 'application/json'
},
body: {
campaigns: [{
caller_id: '0XXXXXXXXX1',
url: 'http://my.exotel.in/start/189810',
from: ['+91XXXXXXXXX4', '+91XXXXXXXXX5'],
schedule: {
send_at: '2018-11-08T14:20:00+05:30'
},
status_callback: 'http://<callback custom domain>/1gvta9f1',
call_status_callback: 'http://<callback custom domain>/1gvta9f1'
}]
},
json: true
};

request(options, function (error, response, body) {

Expand Down
15 changes: 8 additions & 7 deletions Campaign_Samples/js/delete_campaign_byID.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ var apiKey = "<Your API Key>"
var apiToken = "<Your API Token>";
var encoding = Buffer.from(apiKey + ':' + apiToken).toString('base64')

var options = { method: 'DELETE',
url: 'https://api.exotel.com/v2/accounts/'+ accountSid +'/campaigns/<campaign SID>',
headers:
{
Authorization: 'Basic ' + encoding
} };
var options = {
method: 'DELETE',
url: 'https://api.exotel.com/v2/accounts/' + accountSid + '/campaigns/<campaign SID>',
headers: {
Authorization: 'Basic ' + encoding
}
};

request(options, function (error, response, body) {
if (error) throw new Error(error);

console.log(body);

});
37 changes: 21 additions & 16 deletions Campaign_Samples/js/edit_campaign.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,27 @@ var apiKey = "<Your API Key>"
var apiToken = "<Your API Token>";
var encoding = Buffer.from(apiKey + ':' + apiToken).toString('base64')

var options = { method: 'PUT',
url: 'https://api.exotel.com/v2/accounts/'+ accountSid +'/campaigns/<campaign SID>',
headers:
{
Authorization: 'Basic ' + encoding,
'Content-Type': 'application/json'
},
body:
{ campaigns:
[ { caller_id: '0XXXXXXXXX1',
url: 'http://my.exotel.in/exoml/start/189810',
from: [ '+91XXXXXXXX4', '+91XXXXXXXXX5' ],
schedule: { send_at: '2018-11-09T10:00:00+05:30' },
status_callback: 'http://<callback custom domain>/1gvta9f1',
call_status_callback: 'http://<callback custom domain>/1gvta9f1' } ] },
json: true };
var options = {
method: 'PUT',
url: 'https://api.exotel.com/v2/accounts/' + accountSid + '/campaigns/<campaign SID>',
headers: {
Authorization: 'Basic ' + encoding,
'Content-Type': 'application/json'
},
body: {
campaigns: [{
caller_id: '0XXXXXXXXX1',
url: 'http://my.exotel.in/exoml/start/189810',
from: ['+91XXXXXXXX4', '+91XXXXXXXXX5'],
schedule: {
send_at: '2018-11-09T10:00:00+05:30'
},
status_callback: 'http://<callback custom domain>/1gvta9f1',
call_status_callback: 'http://<callback custom domain>/1gvta9f1'
}]
},
json: true
};

request(options, function (error, response, body) {
if (error) throw new Error(error);
Expand Down
13 changes: 7 additions & 6 deletions Campaign_Samples/js/get_campaign_byID.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ var apiKey = "<Your API Key>"
var apiToken = "<Your API Token>";
var encoding = Buffer.from(apiKey + ':' + apiToken).toString('base64');

var options = { method: 'GET',
url: 'https://api.exotel.com/v2/accounts/'+ accountSid +'/campaigns/<campaign SID>',
headers:
{
Authorization: 'Basic ' + encoding
} };
var options = {
method: 'GET',
url: 'https://api.exotel.com/v2/accounts/' + accountSid + '/campaigns/<campaign SID>',
headers: {
Authorization: 'Basic ' + encoding
}
};

request(options, function (error, response, body) {
if (error) throw new Error(error);
Expand Down
13 changes: 8 additions & 5 deletions Campaign_Samples/python/bulk_get_campaigns.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import requests, base64, json
import requests
import base64
import json
accountSid = "<your Exotel SID>"
apiKey = "<your API key>"
apiToken = "<your API token>"
encoding = base64.b64encode(apiKey + ":" + apiToken)

url = "https://api.exotel.com/v2/accounts/"+ accountSid +"/campaigns"
url = "https://api.exotel.com/v2/accounts/" + accountSid + "/campaigns"

querystring = {"page_size":"1","page":"1"}
querystring = {"page_size": "1", "page": "1"}

payload = ""
headers = {
'Content-Type': "application/json",
'Authorization': "Basic " + encoding
}
}

response = requests.request("GET", url, data=payload, headers=headers, params=querystring)
response = requests.request(
"GET", url, data=payload, headers=headers, params=querystring)

print(response.text)
22 changes: 12 additions & 10 deletions Campaign_Samples/python/create_campaign.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
import requests, base64, json
import requests
import base64
import json
accountSid = "<your Exotel SID>"
apiKey = "<your API key>"
apiToken = "<your API token>"
encoding = base64.b64encode(apiKey + ":" + apiToken)

url = "https://api.exotel.com/v2/accounts/"+accountSid+"/campaigns"

payload = json.dumps({ "campaigns": [{
"caller_id": "0XXXXXXXXX1",
"url": "http://my.exotel.com/exoml/start_voice/208287",
"from": [ "+91XXXXXXXXX3", "+91XXXXXXXXX4" ],
"status_callback": "http://<callback custom domain>/1gvta9f1",
"call_status_callback": "http://<callback custom domain>/1gvta9f1"}]
})
payload = json.dumps({"campaigns": [{
"caller_id": "0XXXXXXXXX1",
"url": "http://my.exotel.com/exoml/start_voice/208287",
"from": ["+91XXXXXXXXX3", "+91XXXXXXXXX4"],
"status_callback": "http://<callback custom domain>/1gvta9f1",
"call_status_callback": "http://<callback custom domain>/1gvta9f1"}]
})
headers = {
'Content-Type': "application/json",
'Authorization': "Basic " + encoding
}
}

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

print(response.text)
print(json.dumps(json.loads(response.text), indent = 4, sort_keys = True))
print(json.dumps(json.loads(response.text), indent=4, sort_keys=True))
11 changes: 7 additions & 4 deletions Campaign_Samples/python/delete_campaigns_byID.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import requests, base64, json
import requests
import base64
import json
accountSid = "<your Exotel SID>"
apiKey = "<your API key>"
apiToken = "<your API token>"
encoding = base64.b64encode(apiKey + ":" + apiToken)

url = "https://api.exotel.com/v2/accounts/"+ accountSid +"/campaigns/<campaign SID>"
url = "https://api.exotel.com/v2/accounts/" + \
accountSid + "/campaigns/<campaign SID>"

payload = ""
headers = {
'Authorization': "Basic " + encoding
}
}

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

print(response.text)
print(json.dumps(json.loads(response.text), indent = 4, sort_keys = True))
print(json.dumps(json.loads(response.text), indent=4, sort_keys=True))
25 changes: 14 additions & 11 deletions Campaign_Samples/python/edit_campaigns.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
import requests, base64, json
import requests
import base64
import json

accountSid = "<your Exotel SID>"
apiKey = "<your API key>"
apiToken = "<your API token>"
encoding = base64.b64encode(apiKey + ":" + apiToken)
url = "https://api.exotel.com/v2/accounts/"+accountSid+"/campaigns/<campaign SID>"
url = "https://api.exotel.com/v2/accounts/" + \
accountSid+"/campaigns/<campaign SID>"

payload = json.dumps({ "campaigns": [{
"caller_id": "0XXXXXXXXX1",
"url": "http://my.exotel.com/exoml/start_voice/208287",
"from": [ "+91XXXXXXXXX4", "+91XXXXXXXXX5" ],
"status_callback": "http://<callback custom domain>/1gvta9f1",
"call_status_callback": "http://<callback custom domain>/1gvta9f1"}]
})
payload = json.dumps({"campaigns": [{
"caller_id": "0XXXXXXXXX1",
"url": "http://my.exotel.com/exoml/start_voice/208287",
"from": ["+91XXXXXXXXX4", "+91XXXXXXXXX5"],
"status_callback": "http://<callback custom domain>/1gvta9f1",
"call_status_callback": "http://<callback custom domain>/1gvta9f1"}]
})
headers = {
'Content-Type': "application/json",
'Authorization': "Basic " + encoding
}
}

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

print(response.text)
print(json.dumps(json.loads(response.text), indent = 4, sort_keys = True))
print(json.dumps(json.loads(response.text), indent=4, sort_keys=True))
12 changes: 7 additions & 5 deletions Campaign_Samples/python/get_campaigns_byID.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import requests, base64, json
import requests
import base64
import json

accountSid = "<your Exotel SID>"
accountToken = "<your Exotel token>"
encoding = base64.b64encode(accountSid + ":" + accountToken)
url = "https://api.exotel.com/v2/accounts/"+accountSid+"/campaigns/<campaign sid>"
url = "https://api.exotel.com/v2/accounts/" + \
accountSid+"/campaigns/<campaign sid>"

payload = ""
headers = {
'Authorization': "Basic " + encoding
}
}

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

print(response.text)
print(json.dumps(json.loads(response.text), indent = 4, sort_keys = True))

print(json.dumps(json.loads(response.text), indent=4, sort_keys=True))
48 changes: 26 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,42 @@

Exotel's Call and SMS API sample code

=======

# ExotelSampleCode
The repository contains sample code for using the Exotel APIs.

The repository contains sample code for using the Exotel APIs.

To understand more about the APIs, please go the below link:
https://developer.exotel.com/api/#intro

To understand more about the Applets in Exotel, please go to the below link:
https://developer.exotel.com/applet


# Example Programes:

## are covered for the below languages
C#
Go
Java
Node.JS
PHP
Ruby
Python


- C#
- Go
- Java
- Node.JS
- PHP
- Ruby
- Python

# API Credentials

Replace <your_api_key> and <your_api_token> with the API key and token created by you.
Replace <your_sid> with your “Account sid”
Replace <subdomain> with the region of your account
<subdomain> of Singapore cluster is @api.exotel.com
<subdomain> of Mumbai cluster is @api.in.exotel.com
<your_api_key> , <your_api_token> and <your_sid>
are available in the API settings page of your Exotel Dashboard

https://my.exotel.com/apisettings/site#api-credentials


- Replace `<your_api_key>` and `<your_api_token>` with the API key and token created by you.
- Replace `<your_sid>` with your "Account sid"
- Replace `<subdomain>` with the region of your account
- `<subdomain>` of Singapore cluster is `@api.exotel.com`
- `<subdomain>` of Mumbai cluster is `@api.in.exotel.com`

`<your_api_key>` , `<your_api_token>` and `<your_sid>` are available in the API settings page of your Exotel Dashboard

https://my.exotel.com/apisettings/site#api-credentials

# Read.me
Each of the subfolder have a separate Read.me for the details on the usage of the APIs.

Each of the subfolder have a separate README for the details on the usage of the APIs.
Binary file removed com/exotel/Connect/ExotelResponse.class
Binary file not shown.
Binary file removed com/exotel/Connect/ExotelStrings.class
Binary file not shown.
Binary file removed com/exotel/Connect/ExotelSuccessResponse.class
Binary file not shown.
11 changes: 5 additions & 6 deletions java/ConnectCustomerToFlow.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

package com.exotel.Connect;

public class ConnectCustomerToFlow {
public static void main(String[] args) {
ExotelCall calls = new ExotelCall();
ExotelResponse res = calls.connectCustomerToFlow();
}
public static void main(String[] args) {
ExotelCall calls = new ExotelCall();
ExotelResponse res = calls.connectCustomerToFlow();

}
}
Loading