Forums

YOU GUYS ROCK

No real issue, just wanted to say thanks. 8 or 9 weeks ago I joined with very limited Python knowledge. I had a rough idea of what I wanted to do and only the vaguest idea of how I wanted to go about it.

Late last night I slid the final block into place and now have a fully-functional, made-from-scratch chatbot that communicates with customers via SMS. It adapts to their input, collects callback input and customer feedback, confirms their email address, and sends me an email with a detailed log at the end of every conversation. It's also adaptable to nearly any response they offer.

And I couldn't have done it without you guys! The value you've provided me far exceeds the $5 membership I have here. Your hosted tutorials have been incredibly helpful, and you've been patient with my audacity in the face of things I clearly did not understand (which is not likely to slow down, btw).

Before joining pythonanywhere:

  • I had only a basic understanding of Python itself from a single Udacity course.
  • I'd never done a POST or GET request.
  • I had no idea how Flask worked.
  • I'd never successfully set up a virtualenv.
  • I'd never hosted a website, let alone working code.
  • JSON objects and dictionaries were a complete mystery.
  • Despite a decade in working with Excel, I'd never used SQL or an actual database.
  • I'd never passed arguments between files.

I really appreciate your help and everything you guys do here, and anyone reading who's on the fence about joining up should definitely take the plunge. To be fair I'm exceptionally motivated (I had a substantial sum on the line) and I DO have some experience building unnecessarily complex spreadsheets, but the resources are here!

That is all. More questions to follow later, sometime soon I'll need to figure out feeding CSV files into the database. :-)

How did you make an SMS chatbot?

Hopefully I can do it for fee

*free

@MRG - Thanks so much for the kind words. We're delighted that we could help you get where you are.

what did you use to make the sms chatbot?

Plivo, flask, SQL and a python processing file. I mapped out the messages and status names using Lucidchart, which is incredibly handy for pseudo-code.

When they send a text to the number, Plivo automatically sends a POST request to my URL.

Flask checks the incoming number against my database. If it's not there, it sends a standard text using a function imported from the processing file. If it is there, it loads up a bunch of values from that row of the database, logs the incoming message to the Chat_Log table, and passes all those values off to the processing file in an imported function.

In the processing file, the incoming arguments are converted into a dictionary of values. The bot checks the incoming status against a dictionary of functions, calls the appropriate function, updates the appropriate values in the inputDict, sends the appropriate text messages, and then passes the outputDict back to flask. The processing file is about 1200 lines of code.

In flask, the outputDict is checked for whether a reply was sent. If it was, flask loads up the necessary items and passes them to the Chat_Log database. Then it updates the Chat_User database with all relevant statuses like "call offered", "email offered", and "incoming status." That way, next time the customer responds, the processing file knows which function to call.

If at any point you respond 'start over' exactly or if you make it to the last message, the "send log" status is set to True. Flask sees that, loads up all matching items in the Chat_Log table, sends them to me in an email using render_template, and erases all matching items in the log.

Every incoming message is checked against a global filter for DNC, upset keywords, requests to call or send something, and even asking if we're real. That's done by checking items in a list against the incoming message, i.e. if item in inputDict["incoming message"] and calling the appropriate function if there's a match.

Past that, it's just polish--a nicer email option, more robust filtering lists, more filtering options to make it unbreakable for the user. I'm working now on adding a "notes" status in the table so I can see if the guest was upset, wants a call, etc. without having to read through the whole log.

I'm really fortunate to only need the database info for a relatively short term. That means when I want to change my table options, I just drop the existing table, add some columns in the flask code, and re-create it.