Exotel¶
Important
Please refer to linked Exotel API docs for more details
- class exotelpy.exotel.Exotel(sid, key, token, baseurl='https://api.exotel.com')¶
Object to initialize and interact with Exotel API
It holds the authentication details
- Parameters:
sid (str) – Exotel Account SID
key (str) – API Key
token (str) – API Token
baseurl (str, optional) – Account Subdomain. Defaults to “https://api.exotel.com”.
Campaigns
- create_campaign(caller_id, app_id, from_=None, lists=None, name=None, call_duplicate_numbers=None, schedule=None, campaign_type='static', call_status_callback=None, call_schedule_callback=None, status_callback=None, retry=None)¶
The parameter information is available at https://developer.exotel.com/api/campaigns#create-campaign
- Parameters:
caller_id (str) – This is your ExoPhone
app_id (str) – Identifier of the flow that you want to connect to once the from number picks up the call, this is used to build the url param for API
from_ (List[str], optional) – from equivalent
lists (List[str], optional) – Defaults to None.
name (str, optional) – Defaults to None.
call_duplicate_numbers (bool, optional) – Defaults to None.
schedule (Schedule, optional) – Defaults to None.
campaign_type (str, optional) – Defaults to “static”.
call_status_callback (str, optional) – Defaults to None.
call_schedule_callback (str, optional) – Defaults to None.
status_callback (str, optional) – Defaults to None.
retry (Retry, optional) – Defaults to None.
- Raises:
- Returns:
json containing API response
- Return type:
dict
- create_campaign_with_list(numbers, list_name, caller_id, app_id, **kwargs)¶
Slightly customized to create list with numbers passed as argument implicitly
- Parameters:
numbers (List[str]) – List of numbers in E.164 format
list_name (str) – name of contact list that will be created implicitly
caller_id (str) – This is your exophone
app_id (str) – Identifier of the flow that you want to connect to once the from number picks up the call, this is used to build the url param for API
**kwargs – accepts the rest of the arguments of create_campaign
- Returns:
json containing API response
- Return type:
dict
- get_campaign_details(campaign_id)¶
Retrieve the details of a specific campaign in your account
https://developer.exotel.com/api/campaigns#campaign-details
- Parameters:
campaign_id (str) – ID of the campaign
- Returns:
json object containg the API response
- Return type:
dict
- delete_campaign(campaign_id)¶
Delete a specific campaign
https://developer.exotel.com/api/campaigns#delete-campaign
- Parameters:
campaign_id (str) – ID of the campaign
- Returns:
json object containing the API response
- Return type:
dict
- get_campaign_call_details(campaign_id, offset=None, limit=None, status=None, sort_by=None)¶
https://developer.exotel.com/api/campaigns#call-details-single-campaign
- Parameters:
campaign_id (str) – ID of the campaign
offset (int, optional) – Defaults to None.
limit (int, optional) – Defaults to None.
status (str, optional) – Defaults to None.
sort_by (str, optional) – Defaults to None.
- Returns:
json object containing the API response
- Return type:
dict
- get_bulk_campaign_details(offset=None, limit=None, name=None, status=None, sort_by=None)¶
Allows you to fetch bulk campaign details with sorting and searching capabilities https://developer.exotel.com/api/campaigns#bulk-campaign-details
- Parameters:
offset (int, optional) – _description_. Defaults to None.
limit (int, optional) – number of records on single page. Defaults to None. (Exotel applies its own default, refer docs)
name (str, optional) – Search on Campaign name. Defaults to None.
status (str, optional) – Defaults to None.
sort_by (str, optional) – Defaults to None.
- Returns:
json object containing the API response
- Return type:
dict
Contacts
- create_contacts(numbers)¶
Create contacts
https://developer.exotel.com/api/campaigns-contacts#create-contacts
- Parameters:
numbers (List[str]) – List of E.164 formatted phone numbers
- Returns:
json object containing API response
- Return type:
dict
- get_contact_details(contact_id)¶
https://developer.exotel.com/api/campaigns-contacts#get-details-of-a-contact
- Parameters:
contact_id (str) – Contact SID
- Returns:
json object containing API response
- Return type:
dict
- delete_contact(sid)¶
https://developer.exotel.com/api/campaigns-contacts#delete-a-contact
- Parameters:
sid (str) – contact sid
- Returns:
json object containing API response
- Return type:
dict
- delete_contacts(sids)¶
Utility method for deleting multiple contact at once
- Parameters:
sids (List[str]) – List of E.164 formatted numbers
- Returns:
List of json object containing API response for each contact
- Return type:
List[dict]
Lists
- create_list(name, tag='demo', numbers=None)¶
Slightly modded implementation that takes number as arguments and add those numbers to list after creation
https://developer.exotel.com/api/campaigns-lists#create-lists
- Parameters:
name (str) – Name of the list
tag (str, optional) – Defaults to “demo”.
numbers (List[str], optional) – List of E.164 formatted phone numbers. Defaults to None.
- Raises:
UniqueViolationError – When contact list with same name already exists
- Returns:
json object containing API response
- Return type:
dict
- add_contacts_to_list(sids, list_id)¶
https://developer.exotel.com/api/campaigns-lists#add-contacts-to-a-list
- Parameters:
sids (List[str]) – List of contact sids to add
list_id (str) – Contact List ID
- Returns:
json object containing API response
- Return type:
dict
- delete_list(list_id)¶
Deletes a list
https://developer.exotel.com/api/campaigns-lists#delete-a-list
- Parameters:
list_id (str) – Contact List ID
- Returns:
json object containing API response
- Return type:
dict
- get_list_details(list_id)¶
https://developer.exotel.com/api/campaigns-lists#get-details-of-a-list
- Parameters:
list_id (str) – Contact List ID
- Return type:
dict
- get_bulk_lists(offset=None, limit=None, name=None, sort_by=None)¶
https://developer.exotel.com/api/campaigns-lists#getbulklists
- Parameters:
offset (int, optional) – Defaults to None.
limit (int, optional) – Defaults to None.
name (str, optional) – Defaults to None.
sort_by (str, optional) – Defaults to None.
- Returns:
json object containing API response
- Return type:
dict
- get_list_contacts(list_id, limit=None, offset=None)¶
https://developer.exotel.com/api/campaigns-lists#get-contacts-in-a-list
- Parameters:
list_id (str) – Contact List ID
limit (int, optional) – Defaults to None.
offset (int, optional) – Defaults to None.
- Returns:
json object containing API response
- Return type:
dict
SMS Campaigns
Danger
SMS Campaign Methods will be soon deprecated as Exotel has deprecated the endpoint
- create_sms_campaign(content_type, lists, dlt_entity_id, dlt_template_id, sender_id, sms_type, template, name=None, schedule=None, status_callback=None, sms_status_callback=None)¶
Deprecated
- Returns:
json object containing API response
- Return type:
dict
- create_sms_campaign_with_list(numbers, list_name, *args, **kwargs)¶
Slightly customized to create list with numbers passed as argument implicitly https://developer.exotel.com/api/sms-campaigns#create-sms-campaigns
- Parameters:
numbers (List[str]) – List of E.164 formatted phone numbers
list_name (
str
) – Name of the contact list which will be used implicitly
- Returns:
json object containing API response
- Return type:
dict
- Raises:
ValidationError – raised when any of the parameters isn’t passed correctly
- create_message_campaign(content_type, lists, dlt_entity_id, template_id, sender_id, message_type, template, name, channel, schedule=None, status_callback=None, message_status_callback=None)¶
Create SMS Campaign https://developer.exotel.com/api/sms-campaigns#create-sms-campaigns
- Parameters:
content_type (str) – static or dynamic
lists (List[str]) – List of contact list IDs
dlt_entity_id (int) – DLT Entity ID
template_id (int) – Template ID
sender_id (str) – Sender ID
message_type (str) – Transactional/Promotional
template (str) – Body of the SMS
name (str) – Name of the campaign
channel (str) – SMS or Whatsapp
schedule (Schedule, optional) – Defaults to None.
status_callback (str, optional) – Defaults to None.
message_status_callback (str, optional) – Defaults to None.
- Returns:
json object containing API response
- Return type:
dict
- create_message_campaign_with_list(numbers, list_name, *args, **kwargs)¶
Slightly customized to create list with numbers passed as argument implicitly
https://developer.exotel.com/api/sms-campaigns#create-sms-campaigns
- Parameters:
numbers (List[str]) – List of E.164 formatted phone numbers
list_name (
str
) – Name of the contact list which will be used implicitly
- Raises:
ValidationError – raised when any of the parameters isn’t passed correctly
- Return type:
dict
- get_sms_campaign_details(campaign_id)¶
Get details of the SMS Campaign https://developer.exotel.com/api/sms-campaigns#sms-campaigns-details
- Parameters:
campaign_id (str) – SMS Campaign ID
- Returns:
json object containing the API response
- Return type:
dict
- get_bulk_sms_campaign_details(offset=None, limit=None, name=None, status=None, sort_by=None)¶
https://developer.exotel.com/api/sms-campaigns#bulk-sms-campaign-details
- Parameters:
offset (int, optional) – Defaults to None.
limit (int, optional) – Defaults to None.
name (str, optional) – Defaults to None.
status (str, optional) – Defaults to None.
sort_by (str, optional) – Defaults to None.
- Returns:
json object containing API response
- Return type:
dict
- get_sms_campaign_sms_details(campaign_id, limit=None, offset=None, sort_by=None)¶
https://developer.exotel.com/api/sms-campaigns#sms-details-single-campaign
- Parameters:
campaign_id (str) – SMS Campaign ID
limit (int, optional) – Defaults to None.
offset (int, optional) – Defaults to None.
sort_by (str, optional) – Defaults to None.
- Returns:
json object containing API response
- Return type:
dict
SMS
- get_sms_details(sms_sid)¶
https://developer.exotel.com/api/sms#sms-details
- Parameters:
sms_sid (str) – sms_id is an alpha-numeric unique identifier generated for all the SMS sent via Exotel
- Returns:
json object containing API response
- Return type:
dict
- send_bulk_sms(from_, to, body, encoding_type=None, priority=None, status_callback=None, dlt_entity_id=None, dlt_template_id=None, sms_type=None)¶
https://developer.exotel.com/api/sms#send-bulk-static-sms
- Parameters:
from (str) – Refer Exotel docs
to (List[str]) – Refer Exotel docs
body (str) – Refer Exotel docs
encoding_type (str, optional) – Defaults to None.
priority (str, optional) – Defaults to None.
status_callback (str, optional) – Defaults to None.
dlt_entity_id (str, optional) – Defaults to None.
dlt_template_id (str, optional) – Defaults to None.
sms_type (str, optional) – Defaults to None.
- Returns:
json object containing API response
- Return type:
dict
Exophones
- get_all_exophones()¶
Get a list of all the ExoPhone numbers that have been assigned to an account https://developer.exotel.com/api/exophones#list-exophones
- Returns:
json object containing API response
- Return type:
dict
- get_exophone_details(exophone_sid)¶
Get the details of a specific ExoPhone number of an account
https://developer.exotel.com/api-console/exophone#get-details-of-an-exophone
- Parameters:
exophone_sid (str) – Exophone SID
- Returns:
json object containing API response
- Return type:
dict
- get_exophone_heartbeat(exophone_sid)¶
Get the details of a specific ExoPhone in your account including connectivity information
https://developer.exotel.com/api-console/heart-beat#get-exophone-details-v2
- Parameters:
exophone_sid (str) – Exophone SID
- Returns:
json object containing API response
- Return type:
dict