I'm testing out Twilio SMS and I faced a couple of issues. I'm trying to do an inbound SMS and send a reply to the user with the message body that the user sent.
[HttpPost("Receive")]
public TwiMLResult Receive()
{
var messagingResponse = new MessagingResponse();
messagingResponse.Message("Hello to you too");
return TwiML(messagingResponse);
}
This is what I have done so far,
1. when I reply to the Twilio number I'm getting this message. How can I append the message the user sends into this message? Example: If the user sends "Hello", the respond message should be "Hello to you too and you said Hello"
Thanks
The request body from an inbound SMS has a POST form with fields for from
, to
and body
.
So to get the senders number you could use this code:
var from = Request.Form["From"];
Other fields
var to = Request.Form["To"]; // your twilio number
var body = Request.Form["Body"]; // the message they sent
There is a more detailed example in Twilio docs on conversations