Giter Site home page Giter Site logo

text-sdk-python's Introduction

Text-sdk-python

publish to PyPi PyPi

A helper library to sending messages using python.

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

Installing

Include the SDK by downloading the files manually or running the following command in a Python Shell.

    pip install CM_Text_sdk_python

Instantiate the client

Use your productToken which authorizes you on the CM platform. Get yours on CM.com

    from CMText.TextClient import TextClient

    client = TextClient(apikey=key)

Send a message

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)

Sending multiple messages

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()

Sending a rich message

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()

Sending a Whatsapp Template message

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.

Get the result

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()

text-sdk-python's People

Contributors

ericsmekens avatar joepb avatar jorispenningscm avatar michaelvdnet avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.