Skip to content

sendbee/gupshup-python-api-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gupshup-python-api-client

Table of contents

Messaging


Register git repository as a dependency in your project

git+ssh://git@github.com/sendbee/gupshup-python-api-client.git@master
from gupshup_python_api_client import GupshupApi

api = GupshupApi('__your_api_key_here__')
from gupshup_python_api_client import GupshupApi


api_key = '__your_api_key_here__'
app_name = '__your_gupshup_app_name_here__'

api = GupshupApi(api_key)

response = api.opt_in(app_name, user='phone_number')

response.status

For supported message types and data, see Gupshup documentation

from gupshup_python_api_client import GupshupApi
import ujson as json


api_key = '__your_api_key_here__'

api = GupshupApi(api_key)

# example text message
text_message = {
    'isHSM': False,
    "type": "text",
    "text": "sample text message"
}
# example image message
image_message = {
    "type": "image",
    "originalUrl": "https://images.pexels.com/photos/248797/pexels-photo-248797.jpeg",
    "previewUrl": "https://images.pexels.com/photos/248797/pexels-photo-248797.jpeg",
    "caption":"Sample image"
}
# example file message
file_message = {
    "type": "file",
    "url": "http://enterprise.smsgupshup.com/doc/GatewayAPIDoc.pdf",
    "filename": "Sample file"
}
# example audio message
audio_message = {
    "type": "audio",
    "url": "https://file-examples.com/wp-content/uploads/2017/11/file_example_MP3_700KB.mp3"
}

source_number = '__your_whatsapp_business_number__'
destination_number = '__contact_phone_number__'

# JSON-encode the desired message 
message_payload = json.dumps(text_message)
response = api.send_message(
    source=source_number,
    destination=destination_number,
    message=message_payload
)

response.status
response.message_id

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages