GiriBot

Made by Sarthak Giri

Found in SMS Bot and Conversational Service · UNLISTED (SHOWN IN POOLS)

The goal of the project is to code a Bot that gives basic information about me.

0
require 'sinatra'
require "sinatra/reloader" if development?

require 'dotenv'
Dotenv.load

require 'twilio-ruby'
enable :sessions

# create a twilio client using your account info
@client = Twilio::REST::Client.new ENV["TWILIO_ACCOUNT_SID"], ENV["TWILIO_AUTH_TOKEN"]
get "/sms/incoming" do
    session["last_intent"] ||= nil

    session["counter"] ||= 1
    count = session["counter"]

    sender = params[:From] || ""
    body = params[:Body] || ""
    body = body.downcase.strip

    if session["counter"] == 1
      message = "Hi. Please type one of the following to know more about me. Type 'Name', 'Age', 'Education', 'Favorite color', 'Favorite food'"
      media = "https://media.giphy.com/media/l2YWFGWKH3b32bEIg/giphy.gif"
  end

    if body == "Name"
    message = "Sarthak Giri"
  end

  if body == "Age"
    message = "27"
end

  if body == "education"
    message = "Masters of Integrated Innovation in Product and Services"
end

if body == "favorite color"
    message = "blue"
end

  if body == "favorite food"
      message = "Dal bhat"
    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
    #3

    content_type 'text/xml'
    twiml.to_s

  end
Click to Expand
0

Intention

The goal of this project is to learn the basics of programming a working bot that has limited but functional capabilities.

Context

The idea was to creaete a MeBot that would talk to other people about the developer of the app. Anyone who wants to know more about the developer of the app can ask a series of questions from the menu.

Process

I used atom to write and edit my code. I then used Ruby to run the code and test it. Then I uploaded the code to local Github desktop, pushed it to Github cloud. Then I connected that to Heroku to host my website. To make it conversational, I setup a twilio account and connected that to heroku. Then, the Giribot was ready to answer your questions about me

Reflection

Coding requires attention to detail. Even small things like capital letters can ruin the whole program.

x
Share this Project

This project is only listed in this pool. Be considerate and think twice before sharing.


Courses

49714 Programming for Online Prototypes

· 15 members

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

49714 Programming for Online Prototypes

· 15 members

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


Focused on
Tools
About

The goal of the project is to code a Bot that gives basic information about me.

Created

September 21st, 2017