- Messente API version: 2.0.0
- Python package version: 2.2.0
Messente is a global provider of messaging and user verification services. * Send and receive SMS, Viber, WhatsApp and Telegram messages. * Manage contacts and groups. * Fetch detailed info about phone numbers. * Blacklist phone numbers to make sure you're not sending any unwanted messages. Messente builds tools to help organizations connect their services to people anywhere in the world.
Install Messente API library with pip install messente-api
.
Messente API has the following features:
- Omnichannel (external docs),
- Phonebook (external docs).
Messente API Library provides the operations described below to access the features.
- Adds a phone number to the blacklist
add_to_blacklist
- Deletes a phone number from the blacklist
delete_from_blacklist
- Returns all blacklisted phone numbers
fetch_blacklist
- Checks if a phone number is blacklisted
is_blacklisted
- Sends a bulk Omnimessage
send_bulk_omnimessage
- Adds a contact to a group
add_contact_to_group
- Creates a new contact
create_contact
- Deletes a contact
delete_contact
- Lists a contact
fetch_contact
- Lists groups of a contact
fetch_contact_groups
- Returns all contacts
fetch_contacts
- Removes a contact from a group
remove_contact_from_group
- Updates a contact
update_contact
- Retrieves the delivery report for the Omnimessage
retrieve_delivery_report
- Creates a new group with the provided name
create_group
- Deletes a group
delete_group
- Lists a group
fetch_group
- Returns all groups
fetch_groups
- Updates a group with the provided name
update_group
- Requests info about phone numbers
fetch_info
- Cancels a scheduled Omnimessage
cancel_scheduled_message
- Sends an Omnimessage
send_omnimessage
- Requests statistics reports for each country
create_statistics_report
Type: HTTP basic authentication
Read the external getting-started article which explains API keys and Sender ID logic.
from pprint import pprint
from messente_api import (
OmnimessageApi,
Omnimessage,
OmnimessageMessagesInner,
Configuration,
ApiClient,
Viber,
SMS,
WhatsApp,
WhatsAppParameter,
WhatsAppComponent,
WhatsAppTemplate,
WhatsAppLanguage,
)
from messente_api.rest import ApiException
# API information from https://dashboard.messente.com/api-settings
configuration = Configuration()
configuration.username = '<MESSENTE_API_USERNAME>'
configuration.password = '<MESSENTE_API_PASSWORD>'
# create an instance of the API class
api_instance = OmnimessageApi(ApiClient(configuration))
wa_parameters = [WhatsAppParameter(type='text', text='hello whatsapp')]
wa_component = WhatsAppComponent(type='body', parameters=wa_parameters)
wa_template = WhatsAppTemplate(name='<template name>', language=WhatsAppLanguage(code='<language_code>'), components=[wa_component])
whatsapp = WhatsApp(sender='<sender name (optional)>', template=wa_template)
whatsapp_inner = OmnimessageMessagesInner(whatsapp)
viber = Viber(
sender='<sender name (optional)>',
text='hello python',
)
viber_inner = OmnimessageMessagesInner(viber)
sms = SMS(
sender='<sender name (optional)>',
text='hello python',
)
sms_inner = OmnimessageMessagesInner(sms)
# The order of items in 'messages' specifies the sending order:
# WhatsApp will be attempted first,
# then Viber,
# and SMS as the final fallback
omnimessage = Omnimessage(
messages=(whatsapp_inner, viber_inner, sms_inner),
to='<recipient_phone_number>',
) # Omnimessage | Omnimessage object that is to be sent
try:
# Sends an Omnimessage
response = api_instance.send_omnimessage(omnimessage)
print(
'Successfully sent Omnimessage with id: %s that consists of the following messages:' % response.omnimessage_id
)
for message in response.messages:
pprint(message)
except ApiException as exception:
print('Exception when sending an omnimessage: %s\n' % exception)