Reputation: 1110
In my previous question, I listed how I'm currently using a functional MVC controller on an ASP.NET IIS site to handle some of the incoming SMS/MMS messages for my Twilio phone number. However, I've been unable to find the appropriate documentation for the next stage of what I'm wanting to accomplish:
How do I respond with an MMS message?
The full code listing for my SMSController
is in the linked SO question and seems to work fine for sending basic text-only SMS messages, but I'm running into difficulty trying to get it to send MMS messages. I've tried constructing a Messaging.Message
object by setting the .Body()
and .Media()
options:
[...]
If SMSMessage.ToUpper.Trim = "JEDI" Then
Dim Response As New Messaging.Message
Response.Body(JediCode)
Response.Media(New Uri("https://my.domain.com/content/media/jedi.gif"))
SMSResponse.Message(Response)
[...]
This method overload seems to almost work - it sends the image, but the GIF's animation is somehow lost - but, for one thing, the IDE is flagging it with a warning that that method is deprecated and to use the .Append()
method instead. I tried that but it seems to fail to send anything and the Error Logs in my Twilio console show an HTTP retrieval failure
.
Obviously, the above code is just while I play around and test things, but there is a definite possibility that we would be sending animated images as a part of the business flow of our use case. Is there something I'm missing here to properly send an MMS message as a response to an incoming SMS?
Upvotes: 0
Views: 97
Reputation: 7164
I created an MVC sample with VB.NET to send an MMS using TwiML the same way you are. When I receive the MMS the GIF does move, so it is likely that the SMS app you're using doesn't support moving GIFs. Here's the code I used:
Imports Twilio.AspNet.Mvc
Imports Twilio.TwiML
Imports Twilio.TwiML.Messaging
Public Class HomeController
Inherits TwilioController
Function Index() As TwiMLResult
Dim response As New MessagingResponse
Dim message As New Message
message.Body("Check out this GIF:")
message.Media(New Uri("https://upload.wikimedia.org/wikipedia/commons/2/2c/Rotating_earth_%28large%29.gif"))
response.Append(message)
Return TwiML(response)
End Function
End Class
Here's what the MMS looks like in my SMS app:
Regarding using .Message
vs .Append
, they should work the same but .Message
with that specific method signature is deprecated meaning it may be removed in the future. Ultimately, when you return the MessagingResponse
using the TwiML
method, or use .ToString
on it, the resulting TwiML string should be the same.
Upvotes: 1