You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: messages/README.md
+67Lines changed: 67 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,5 +6,72 @@ This package contains the code to use [Vonage's Messages API](https://developer.
6
6
7
7
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`.
8
8
9
+
### How to Construct a Message
10
+
11
+
In order to send a message, you must construct a message object of the correct type. These are all found under `vonage_messages.models`.
12
+
13
+
```python
14
+
from vonage_messages.models import Sms
15
+
16
+
message = Sms(
17
+
from_='Vonage APIs',
18
+
to='1234567890',
19
+
text='This is a test message sent from the Vonage Python SDK',
20
+
)
21
+
```
22
+
23
+
This message can now be sent with
24
+
25
+
```python
26
+
vonage_client.messages.send(message)
27
+
```
28
+
29
+
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.
30
+
31
+
The different message models are listed at the bottom of the page.
32
+
33
+
Some message types have submodels with additional fields. In this case, import the submodels as well and use them to construct the overall options.
34
+
35
+
e.g.
36
+
37
+
```python
38
+
from vonage_messages import MessengerImage, MessengerOptions, MessengerResource
0 commit comments