Skip to main content

Vonage messages package

Project description

Vonage Messages Package

This package contains the code to use Vonage's Messages API in Python.

Usage

It is recommended to use this as part of the main vonage package. The examples below assume you've created an instance of the vonage.Vonage class called vonage_client.

How to Construct a Message

In order to send a message, you must construct a message object of the correct type. These are all found under vonage_messages.models.

from vonage_messages.models import Sms

message = Sms(
    from_='Vonage APIs',
    to='1234567890',
    text='This is a test message sent from the Vonage Python SDK',
)

This message can now be sent with

vonage_client.messages.send(message)

All possible message types from every message channel have their own message model. They are named following this rule: {Channel}{MessageType}, e.g. Sms, MmsImage, MessengerAudio, WhatsappSticker, ViberVideo, etc.

The different message models are listed at the bottom of the page.

Some message types have submodels with additional fields. In this case, import the submodels as well and use them to construct the overall options.

e.g.

from vonage_messages import MessengerImage, MessengerOptions, MessengerResource

messenger = MessengerImage(
    to='1234567890',
    from_='1234567890',
    image=MessengerResource(url='https://example.com/image.jpg'),
    messenger=MessengerOptions(category='message_tag', tag='invalid_tag'),
)

Send a message

To send a message, access the Messages.send method via the main Vonage object, passing in an instance of a subclass of BaseMessage like this:

from vonage import Auth, Vonage
from vonage_messages.models import Sms

vonage_client = Vonage(Auth(application_id='my-application-id', private_key='my-private-key'))

message = Sms(
    from_='Vonage APIs',
    to='1234567890',
    text='This is a test message sent from the Vonage Python SDK',
)

vonage_client.messages.send(message)

Message Models

To send a message, instantiate a message model of the correct type as described above. This is a list of message models that can be used:

Sms
MmsImage, MmsVcard, MmsAudio, MmsVideo
WhatsappText, WhatsappImage, WhatsappAudio, WhatsappVideo, WhatsappFile, WhatsappTemplate, WhatsappSticker, WhatsappCustom
MessengerText, MessengerImage, MessengerAudio, MessengerVideo, MessengerFile
ViberText, ViberImage, ViberVideo, ViberFile

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vonage_messages-1.1.1.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vonage_messages-1.1.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file vonage_messages-1.1.1.tar.gz.

File metadata

  • Download URL: vonage_messages-1.1.1.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for vonage_messages-1.1.1.tar.gz
Algorithm Hash digest
SHA256 278e103b8089ff0fdd7b559539f54c91929f32d54878c48f80ac32be7e1c68e1
MD5 67502191e13fe4667acd65cf1dc3a03f
BLAKE2b-256 f7fd43da1d145bb07648f227dbd63bb44f47b63a8a4a8166b5d809f3aadfb834

See more details on using hashes here.

File details

Details for the file vonage_messages-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for vonage_messages-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c77d669d6d2bffefa6e0f1909b295a8e1271c2488b31c451f3b2f409b73c0c3d
MD5 7e314ed885e0a8f64fe2cd26e916e5a0
BLAKE2b-256 9a60960ba2e91d1f9dc2b30b6479acdf92c3fc53320a92228e68044751a7eb12

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page