Jack's Bot "Sardis"

Made by jdoresky

Found in SMS Bot

0

Intention

Sardis was made to develop the character of the texter. He is mostly useless in practical applications. Rather, he motivates the user to take control of their own life and solve the problems they ask him to solve.

0

Context

Sardis is really only good to converse with. He builds identity of the user and that is his only purpose. 

0

Trial/Error

Using existing code, Sardis's personality was layered after he was confirmed to work to deepen his character. The creator worked with the professor to make a working sms bot. 

0

Product

Sardis can respond to a variety of questions depending on the keywords. He will continually lead the sender towards the end of the program trail. 

0

Reflection

Building on Sardis, he could actually serve some function or be made to actually be useful in some way. 

0
require "sinatra"
require 'sinatra/reloader' if development?
require 'twilio-ruby'
enable :sessions
@client = Twilio::REST::Client.new ENV["TWILIO_ACCOUNT_SID"], ENV["TWILIO_AUTH_TOKEN"]
configure :development do
  require 'dotenv'
  Dotenv.load
end
get "/" do
    404
end
get "/sms/incoming" do
  session["last_intent"] ||= nil
  session["counter"] ||= 1
  count = session["counter"]
  sender = params[:From] || ""
  body = params[:Body] || ""
  body = body.downcase.strip


  @client = Twilio::REST::Client.new ENV["TWILIO_ACCOUNT_SID"], ENV["TWILIO_AUTH_TOKEN"]

  if session["counter"] == 1
    message = "What's up?"

  elsif session["counter"]>=1
    if body.include?("wryd")
        message = "I'm at the gym lol. Why?"

      @client.api.account.messages.create(
         from: ENV['TWILIO_FROM'],
         to: params[:From],
         body: "I'm at the gym lol. Why?"
      )
    elsif body.include?("are you doing")
        message = "I'm at the gym lol. Why?"

    elsif body.include?("hw") || body.include?("homework")
      message = "Yeah a while ago."
    elsif body.include?("help")
      message = "No"
    elsif body.include?("weather")
      message = "Dude look yourself. You have an app"
    elsif body == "Can you remind me to do that thing?" || body.include?("remind")
      message = "Why do you need me to do that? Just set a reminder on your phone"
    elsif body.include?("jack")
      message = "jack? That's a cool kid. That's all you need to know"
    elsif body.include?("more")
      message = "I've said too much already"
    elsif body.include?("please")
      message = "https://media.giphy.com/media/26uf1obq3ifbbixVK/giphy.gif"
    else
      message = "We're done here."
    end

  end
  if session["counter"]==10
    message = "JACK'S PHONE IS ON DO NOT DISTURB NOW. TEXT SOMEONE ELSE."
    media = nil
  end
  if session["counter"]>=11
    message = "https://media.giphy.com/media/26uf1obq3ifbbixVK/giphy.gif"
    media = nil
  end
  session["counter"] += 1
  twiml = Twilio::TwiML::MessagingResponse.new do |r|
    r.message do |m|
      m.body( message )
      unless media.nil?
        m.media( media )
      end
    end
  end
  content_type 'text/xml'
  twiml.to_s
end
Click to Expand
x
Share this Project

This project is only accessible by signed in users. Be considerate and think twice before sharing.


Found In
Courses

49714 Programming for Online Prototypes

· 15 members

A hands on introduction to building online products and services through code


About

~

Created

September 19th, 2017