Customers can programmatically receive MO messages with attachments sent to their application. These MO messages with attachment could be of the following Channels:
- MMS
- WhatsApp Business Messaging
Receiving MO messages with Attachment
Assuming you already have a MMS capable Sender ID in the case of a Shortcode or Longcode or have a WhatsApp capable sender ID provisioned.
When an end-user sends you a MO message with an image or video to your shortcode, long code or any other media capable Sender Address, the message will be deposited directly into your Inbox. For you to receive this in your application, you will be required to setup a webhook and have subscription configured for receiving messages. This will enable you to get MO events. For more information on setting up a webhook, please visit our webhook knowledgebase
MO Events with Attachments
MO message events are POSTED to your webhook once you have the event and delivery configuration setup. Below is a sample of an event you will get for a MO MMS with an attachment. Please note that Syniverse's platform scans all MMS related contents (attachments) for virus before sending and notifying you of the event.
{
"topic": "SCG-Message",
"attempt": 1,
"event": {
"fld-val-list": {"attachment_ids": " Mno4Xayql1oVOYAvP7Iy25",
"sender_id_alias": "ljX2KJbs8zowzC8rFexzn6",
"mo_price": 0.015,
"company-id": 1500,
"sender_id_id": "ljX2KJbs8zowzC8rFexzn6",
"message_body": "",
"message_id": "WGqCwdXm2szqkIGq2Xmy06",
"to_address": "18322222222",
"has_attachment": true,
"fragments_count": 1,
"from_address": "+14086080000",
"anti_virus_scan_status": "OK",
"application_id": 17226
},
"evt-tp": "mo_message_received",
"timestamp": "2019-07-16T16:16:17.579Z"
},
"event-id": "mNdHyWhdQWW2wACUWh84Wg"
}
Retrieving MO Message content using the Attachment ID
To confirm that you have an event with a media content sent to you by a user, the event (JSON) sent to you will include having the following parameter and values:
- {has_attachment}: {True}
- {attachment}: {attachment ID}
Now that you have an attachment ID, complete the following sequence:
Step 1 : Create an Access Token for the attachment
curl -X POST
https://api.syniverse.com/scg-external-api/api/v1/access_tokens
-H Authorization: Bearer {TOKEN}
-H Content-Type: application/json
-d {"resource": "ATTACHMENT","resource_id": " WGqCwdXm2szqkIGq2Xmy06”}
The value for the resource ID parameter should be the same as the attachment ID you got in your event
Response: {“ ARuMnnEtpiqEUrlxvbOeS4”}
Step 2: Get/Download your Attachment
Using the ID received from creating the access token: {“ ARuMnnEtpiqEUrlxvbOeS4”}, run a GET on with the ID embedded in the resource below. Ensure that you have the correct heards configured if you want to download the content.
curl -X GET \
https://api.syniverse.com/scg-attachment/api/v1/messaging/attachments/ARuMnnEtpiqEUrlxvbOeS4/content
-H Authorization: Bearer {TOKEN}
-H Content-Type: image/jpg
Your content should be downloaded now!
Please note that each channel may have different requirement in the type of content type that is supported. For MMS related content, please visit the Syniverse knowledge base portal for content type supported.
For information on the API resources used in here, please visit our API reference page.
0 Comments