1

I've successfully configured Twilio on console as well as in my Salesoforce web application to send SMS to a given(authorized) mobile number. However I'm unable to find the proper way to find

  1. How my clients can reply to the SMSs they receive
  2. How I can retrieve their replies via API to my web application

I felt something called TwiML is related to this but not much clear the process. Can some body guide if you have done some similar implementation?

highfive
  • 628
  • 3
  • 12
  • 31

1 Answers1

0

You can find the answer for how your human clients/customers/users can reply here:

https://www.twilio.com/docs/sms/quickstart/python#install-flask-and-set-up-your-development-environment

Rather than "client", I will use the word "user" to mean client / customer / user / human.

Let me explain what these instructions tell you by example:

The instructions will tell you how to make a bot that can send a human user a text such as "Hi, How Are You?". Then the user can respond with e.g. "I need an espresso.".

Then the bot will detect that that user has sent a response and can reply with a canned answer such as "Oh, okay.".

The instructions are pretty involved, impossible to summarize here, and fairly well written (I just followed them successfully).

However, those instructions are not clear on how to make the bot actually process what the user says, for example respond conditionally based on whether the user says 'yes' or 'no'.

If you want to actually process the contents of the user's message (exemplified as detecting whether they replied 'yes', 'no', or something else, then you can take the run.py they have at the end of their tutorial and modify is like so:

from flask import Flask, request
from twilio.twiml.messaging_response import MessagingResponse

import sys

app = Flask(__name__)

@app.route("/sms", methods=['GET', 'POST'])  
def sms_ahoy_reply():
    """Respond to incoming messages with a friendly SMS."""
    # Start our response                                                                                        
    resp = MessagingResponse()

    message_body = request.form['Body']
    message_body = message_body.strip()
    if message_body == "yes":
        resp.message("You said yes.")
    elif message_body == "no":
    resp.message("You said no.")
    else:
        resp.message("You said neither yes nor no.")

    return str(resp)

if __name__ == "__main__":
    app.run(debug=True)
Bill
  • 111
  • 8
  • Thank you for your reply. However I'm using this on Salesforce(cloud) and without installing or additional configurations checking the possibility to achieve this. – highfive Oct 01 '18 at 09:09