Want to send messages in your Python application? Then you are at the right address. If you want to get all the functionalities, go to: CM.com API Docs
Include the SDK by downloading the files manually or running the following command in a Python Shell.
pip install cm_text_sdk_python
Use your productToken which authorizes you on the CM platform. Get yours on CM.com
from cm_text import TextClient
client = TextClient(apikey=key)
By calling SendSingleMessage
and providing message text, sender name, recipient phone number(s).
client = TextClient(apikey=key)
client.SendSingleMessage(message=message, from_='CM.com', to=Recipients)
By calling AddMessage
and providing message text, sender name, recipient phone number(s) you can queue multiple messages. Send them by calling send
.
client = TextClient(apikey=key)
client.AddMessage(message=message, from_='pythonSDK', to=Recipients)
client.AddMessage(message=message2, from_='pythonSDK', to=Recipients2)
response = client.send()
By calling AddRichMessage
and providing Media
, message text, sender name, recipient phone number(s) you can queue multiple Rich messages. Send them by calling send
.
media = {
"mediaName": "conversational-commerce",
"mediaUri": "https://www.cm.com/cdn/cm/cm.png",
"mimeType": "image/png"
}
client = TextClient(apikey=key)
client.AddRichMessage(message=message, from_='pythonSDK', to=to, allowedChannels=allowedChannels, media=media)
response = client.send()
By calling AddWhatsappTemplateMessage
and providing Template
, sender name, recipient phone number(s) you can queue multiple Whatsapp Template messages. Send them by calling send
.
template_namespace = "Your-Template-Namespace"
template_element_name = "Replace with Template Name"
template = WhatsappTemplate(template_namespace, template_element_name)
client = TextClient(apikey=key)
client.AddWhatsappTemplateMessage(from_='pythonSDK', to=to, template=template)
response = client.send()
See Examples folder for more examples.
See the example file for an example.
Sending a message by calling send
returns the response body. Response is of type: https://requests.readthedocs.io/en/master/user/quickstart/#response-content
response = client.send()