How to Send Audio MMS
Warning: Beta software This API is in beta stage and may be subject to change. Therefore, we do not recommend using this in production.
Interested in this feature? Please reach out to mobility-services-developer@cisco.com
Prerequisites
- An OAuth 2.0 client
- A client access token
- Any SMS Sender ID (sender name) must be added to the allowed list before it can be used as the sender of MMS. See "SMS sender IDs" on your product in Developer Portal.
Required Scope
mms.send.to_subscriber
mms.send.from_subscriber
Code Dependencies
<dependency>
<groupId>com.wgtwo.api.v0.grpc</groupId>
<artifactId>mms</artifactId>
<version>0.3.0</version>
</dependency>
Code
package com.example.mms
import com.google.protobuf.ByteString
import com.wgtwo.api.v0.common.PhoneNumberProto
import com.wgtwo.api.v0.mms.MmsProto
import com.wgtwo.api.v0.mms.MmsServiceGrpc
import io.grpc.ManagedChannelBuilder
fun main() {
val phoneNumber = "+47xxxxxxxx" // Target your desired user
val channel = ManagedChannelBuilder.forAddress("sandbox.api.shamrock.wgtwo.com", 443).build()
val stub = MmsServiceGrpc.newBlockingStub(channel)
val message = with(MmsProto.SendMessageToSubscriberRequest.newBuilder()) {
val audioContent = with(MmsProto.AudioContent.newBuilder()) {
this.wav = ByteString.readFrom(
this::class.java.classLoader.getResource("test.wav")
.openStream(),
)
build()
}
addMessageContent(MmsProto.MessageContent.newBuilder().setAudio(audioContent))
this.fromTextAddress = with(PhoneNumberProto.TextAddress.newBuilder()) {
this.textAddress = "Test"
build()
}
this.toSubscriber = with(PhoneNumberProto.PhoneNumber.newBuilder()) {
this.e164 = phoneNumber
build()
}
build()
}
val result: MmsProto.SendResponse = stub.sendMessageToSubscriber(message)
if (result.status == MmsProto.SendResponse.SendStatus.SEND_OK) {
println("Successfully sent message
$result")
} else {
println(
"""
Failure to send message:
request ID= ${result.requestId}
status=${result.status}
description=${result.description}"
""".trimIndent(),
)
}
}
Example Results
Successfully sent message
request_id: "fc47edd9-c5db-4dd9-b0ba-0745f2951b70"
status: SEND_OK