Send messages
Send SMS and WhatsApp messages, follow them, and cancel ones that haven't gone.
goomzo.messages sends messages, each to its own person, and reads them back. For the fields of a message, see
Send messages.
Send one message
message = goomzo.messages.send_one({
'to': '+255712345678',
'channel': 'sms',
'content': {'text': 'Amina, order #1042 is ready.'},
})send_one returns the message, its status sending, or scheduled with a sendAt.
Send up to 100
messages = goomzo.messages.send([
{'to': '+255712345678', 'channel': 'sms', 'content': {'text': 'Amina, order #1042 is ready.'}},
{'customerId': 'cus_4hq2v9n1c8x0t6pk', 'channel': 'whatsapp', 'content': {'text': 'Juma, order #1043 is ready.'}},
])They're queued all or none. If one isn't valid, none is sent, and the error names it, such as messages[1].to.
Send to many people
A broadcast sends one message to segments, numbers or every customer:
goomzo.broadcasts.create({
'name': 'Black Friday',
'channel': 'sms',
'content': {'text': 'Hi {{name|there}}, 20% off everything today.'},
'audience': {'segments': [{'name': 'VIP'}]},
})See Broadcasts.
Read messages
message = goomzo.messages.get('msg_7c1x9v2b4n6m8q0w')
for message in goomzo.messages.list(status='failed'):
print(message['to']['phone'], message['error'])Other methods
| Method | Does |
|---|---|
messages.cancel(id) | Cancels a message that hasn't gone. |
messages.senders() | Lists the SMS sender IDs you can send from. |
messages.media(received_id) | Gets a file a customer sent on WhatsApp. |
broadcasts.get(id) | Gets a broadcast, with how its messages are doing. |
broadcasts.list() | Lists broadcasts. |
broadcasts.cancel(id) | Cancels a broadcast that hasn't gone. |
Note: Follow a message's status with webhooks, not by asking again and again.
Next steps
Last updated