Beispiel #1
0
from CMText.TextClient import TextClient

# Message to be send
message = 'Examples message to be send'
message2 = 'Examples 2 message to be send'

# Recipients
to = ['003156789000', '002134567890']

# Instantiate client with your own api-key
client = TextClient(apikey=UNIQUE_API_KEY)

# Add a message to the queue
client.AddMessage(message=message, from_='pythonSDK', to=to)
client.AddMessage(message=message2, from_='CM.com', to=to)

# Send the messages
response = client.send()

# Print response
print(response.text)
Beispiel #2
0
import os
from CMText.TextClient import TextClient

# fetch the API key from environment variables
UNIQUE_API_KEY = os.getenv("CM_API_KEY")
if UNIQUE_API_KEY is None:
    print('Please fill an environment variable named CM_API_KEY with your API key.')

# Message to be sent
message = 'Examples message to be sent'

# Recipients
to = ['003156789000', '002134567890']

# Instantiate client with your own api-key
client = TextClient(apikey=UNIQUE_API_KEY)

# Send a single message
client.SendSingleMessage(message=message, from_='CM.com', to=to)
from CMText.TextClient import TextClient
from CMText.WhatsappTemplate import WhatsappTemplate

# Your api-Key
key = 'Your-Key'

# Recipients
to = ['00123456789','00986837265']

# Template
template_namespace = "Your_Template_Namespace"
template_element_name = "Your_Template_Name"
template = WhatsappTemplate(template_namespace, template_element_name)

# Instantiate client with your own api-key
client = TextClient(apikey=key)

# Add message to queue
client.AddWhatsappTemplateMessage(from_='pythonSDK', to=to, template=template)

# Send message
response = client.send()

# Response is an object of type: https://www.w3schools.com/python/ref_requests_response.asp
print(response.text)
if UNIQUE_API_KEY is None:
    print('Please fill an environment variable named CM_API_KEY with your API key.')

# Message to be sent
message = 'Examples message to be sent'

# Media to be sent
media = {
            "mediaName": "conversational-commerce",
            "mediaUri": "https://www.cm.com/cdn/cm/cm.png",
            "mimeType": "image/png"
        }

# AllowedChannels in this case Whatsapp
allowedChannels = ['Whatsapp']

# Recipients
to = ['003156789000', '002134567890']

# Instantiate client with your own api-key
client = TextClient(apikey=UNIQUE_API_KEY)

# Add a Rich message to the queue
client.AddRichMessage(message=message, from_='pythonSDK', to=to, allowedChannels=allowedChannels, media=media)

# Send the messages
response = client.send()

# Print response
print(response.text)