49714 Programming for Online Prototypes
· 9 members
A hands on introduction to building online products and services through code
Chengbot is basically a personal portfolio introduction chatbot. The target users of the Chengbot are employers, professors, and someone who feels interested in my design projects. Chengbot can provide users with a relatively comprehensive explanation of some detailed information about the architecture and UX/UI designs.
Chengbot is my project assistant, which can help others to know some specific information about me, especially for my design projects.
The main users for this platform are the employers, professors, friends, and people who would like to know something about me from the internet. My specialization is architecture design and computation design and I have already created lots of design projects. Although I have uploaded my design projects on the website, the interaction between views and information on the website is not efficient. Personally, I want to expand my life circle and make my design projects powerful enough to influence more people. In addition, when the employers and professors see this platform, they will have a better understanding of my purpose of creating these projects and learn some basic information about me. Therefore, there will be more likely for me to find an ideal job as well as take part in some interesting labs in the university.
The users can type into some specific keywords suggested by the Chengbot and then they will get some detailed information about what they want to know, such as design topic, design purpose, design approach, personal skills, personal experience, personal website, personal contact information, etc. Users can also try to use their own words to have a conversation with Chengbots and they will have similar feelings that they are talking to me as well. What’s more, the users can leave their personal contact information on this platform and the Chengbot can collect this information for me, which is easier for me to know the users’ requirements. Thus, I can contact them later if necessary.
Chengbot can identify the keywords from the user's output. In the workflow of Chengbot, every question is unique and every keyword is different. Therefore, it is much easier for the Chengbot to identify the keywords from the users. Also, the users will be guided by the specific questions asked by the Chengbot to make the conversation successful.
For the functionality matrix, the high priority in my chatbot project is to continue to provide users with specific questions to answer. Thus, the scope of the conversation will not beyond the capability of the Chengbot. Also, the users can go through the dialogue in a more efficient way because they can always find the right direction to chat with Chengbot.
require 'sinatra'
require "sinatra/reloader" if development?
require 'twilio-ruby'
require 'httparty'
require 'json'
require 'did_you_mean'
enable :sessions
configure :development do
require 'dotenv'
Dotenv.load
end
get "/" do
redirect to ("/about")
end
get "/about" do
"Hi, I am Cheng"
end
get "/sms/incoming" do
session[:counter] ||= 0
count = session[:counter]
sender = params[:From] || ""
body = params[:Body] || ""
# session["last_intent"] ||= nil
# session["users_name"] ||= nil
message = determine_response body
# Build a twilio response object
twiml = Twilio::TwiML::MessagingResponse.new do |r|
r.message do |m|
# add the text of the response
m.body( message )
end
end
# increment the session counter
session[:counter] += 1
# send a response to twilio
content_type 'text/xml'
twiml.to_s
end
get "/test/sms" do
client = Twilio::REST::Client.new ENV["TWILIO_ACCOUNT_SID"], ENV["TWILIO_AUTH_TOKEN"]
#\n means add the words into the new line (\n\n means adding two lines)
message = "Hello, I am Cheng\nIt works!"
# this will send a message from any end point
client.api.account.messages.create(
from: ENV["TWILIO_FROM"],
to: ENV["TEST_NUMBER"],
body: message
)
"Test Message Sent"
end
GREETINGS = ["Hello", "Hi", "Hey", "What's up", "Good to see you", "Hey there"]
def determine_response body
q = body.to_s.downcase.strip
if q == "hi" or q == "hello" or q == "hey"
# session["last_intent"] = "hello"
send_sms_message_to get_greeting + "👋, I am Cheng"
sleep(3)
send_sms_message_to "An architecture and computation designer 👨💻"
sleep(3)
message = "Do you want to know more? or get in touch?"
elsif q.include? "more"
# session["last_intent"] = "more"
send_sms_message_to "Well, I am a graduate student from CMU 👨🎓"
sleep(3)
send_sms_message_to "My program is master of architecture"
sleep(3)
message = "Are you a student? or working already?"
elsif q.include? "work" or q.include? "student"
# session["last_intent"] = "ask_if_designer"
send_sms_message_to "That's cool! It's nice to meet you! 😊"
sleep(3)
message = "Are you a designer? or you just feel interested?"
#elsif session["last_intent"] == "ask_if_designer"
#if q.include? "design"
#elsif q.include? "interested"
#else
#end
elsif q.include? "design"
send_sms_message_to "Wow! I thought so...😊"
sleep(3)
send_sms_message_to "I am willing to talk to designers"
sleep(3)
send_sms_message_to "I am passionate about architecture design as well as UX&UI design"
sleep(3)
message = "Do you design the same or different?"
elsif q.include? "interest"
send_sms_message_to "Interesting...I really appreciate your interests in design though"
sleep(3)
send_sms_message_to "I guess you might be interested in my projects ✍️"
sleep(3)
message = "Do you want to see my projects? or use email to get in touch? 📧"
elsif q.include? "same"
send_sms_message_to "Cheers! I am glad to hear that..."
sleep(3)
send_sms_message_to "Actually, I think you might be interested in my projects ✍️"
sleep(3)
message = "Do you want to see my projects? or use email to get in touch? 📧"
elsif q.include? "different"
send_sms_message_to "Nice! Design is a big family! We are all part of it"
sleep(3)
send_sms_message_to "Actually, I think you might be interested in my projects ✍️"
sleep(3)
message = "Do you want to see my projects? or use email to get in touch? 📧"
elsif q.include? "project"
send_sms_message_to "Nice! I studied B.Arch in Zhejiang Sci-Tech University and M.Arch in Carnegie Mellon University"
sleep(3)
message = "Do you want to see my projects of bachelor degree? or master degree?"
elsif q.include? "master"
send_sms_message_to "Well, there exists one M.Arch project 1️⃣"
sleep(3)
send_sms_message_to "5.Environment, form and feedback"
sleep(3)
message = "You can type the number to see the details or you can type bachelor to see the others"
elsif q.include? "bachelor"
send_sms_message_to "Well, there exist four B.Arch projects 4️⃣"
sleep(3)
send_sms_message_to "1.Inspiration Palace\n" + "2.Truemanism\n" + "3.On the Wing\n" + "4.Between the Wall"
sleep(3)
message = "You can type the number to see the details or you can type master to see the others"
elsif q.include? "5"
send_sms_message_to "Here is the link:\n" + "https://www.behance.net/gallery/91462971/Environment-Form-Feedback"
sleep(3)
message = "Do you want to see other bachelor's projects? or contact with me? ✉️"
elsif q.include? "1"
send_sms_message_to "Here is the link:\n" + "https://www.behance.net/gallery/91463111/Inspiration-Palace"
sleep(3)
message = "Do you want to see other master's projects? or contact with me? ✉️"
elsif q.include? "2"
send_sms_message_to "Here is the link:\n" + "https://www.behance.net/gallery/91463147/Truemanism"
sleep(3)
message = "Do you want to see other master's projects? or contact with me? ✉️"
elsif q.include? "3"
send_sms_message_to "Here is the link:\n" + "https://www.behance.net/gallery/91463363/On-the-Wing"
sleep(3)
message = "Do you want to see other master's projects? or contact with me? ✉️"
elsif q.include? "4"
send_sms_message_to "Here is the link:\n" + "https://www.behance.net/gallery/91463221/Between-the-Wall"
sleep(3)
message = "Do you want to see other master's projects? or contact with me? ✉️"
elsif q.include? "contact" or q.include? "email" or q.include? "touch"
send_sms_message_to "That's awesome! 🙌"
sleep(3)
message = "Do you want to ask me a question? or talk about the cooperation? 🤝"
elsif q.include? "cooperation" or q.include? "question"
send_sms_message_to "Great! I am looking forward to it! 😊"
sleep(3)
send_sms_message_to "Here is my email: czhou2@andrew.cmu.edu"
sleep(3)
message = "I will respond to you asap!"
else
# Sending unexpected answer to the Slack Channel
send_to_slack q
send_sms_message_to "Sorry 😢, " + error_response
sleep(3)
message = "Could you type your choice again? or say hello to start the conversation"
end
message
end
def send_sms_message_to message_body
client = Twilio::REST::Client.new ENV["TWILIO_ACCOUNT_SID"], ENV["TWILIO_AUTH_TOKEN"]
# this will send a message from any end point
client.api.account.messages.create(
from: ENV["TWILIO_FROM"],
to: ENV["TEST_NUMBER"],
body: message_body
)
end
def error_response
error_prompt = ["I didn't catch that", "Hmmm I don't know that", "I am confused with that"]
return error_prompt.sample
end
def get_greeting
return GREETINGS.sample
end
def send_to_slack message
# how to use HTTParty
# response = HTTParty.get('http://myurl.com/path/to/resouce')
# puts response.body, response.code, response.message, response.headers.inspect
# response = HTTParty.post('http://myurl.com/path/to/resouce')
slack_webhook = ENV['SLACK_WEBHOOK']
formatted_message = "*Recently Received:*\n"
formatted_message += "#{message} "
HTTParty.post slack_webhook, body: {text: formatted_message.to_s, username: "ChengBot" }.to_json, headers: {'content-type' => 'application/json'}
end
Click to Expand
This was my first time using Ruby to write a conversational UI project and it is quite interesting. I gained lots of technical skills as well as a basic understanding of the Zero-UI concepts. For now, my personal chatbot the first version which can respond to the user's simple questions. It can identify the keywords from the users and respond to the users in a more human way.
For the next step, I would like to add more content to the conversation with Chengbot. I would like to make it become more personal. For example, Chengbot can remember the users' names and careers, which could enable some users to remember the Chengbot too. In addition, based on the fact my Chengbot is to introduce my design-related work for users, I am going to add some project-related gifs in the conversation to show my designs in an efficient way. Finally, I would like to explore more useful APIs, which can help Chengbot to contain more information to deliver to the users.
A hands on introduction to building online products and services through code
Chengbot is basically a personal portfolio introduction chatbot. The target users of the Chengbot are employers, professors, and someone who feels interested in my design projects.
Chengbot can provide users with a relatively comprehensive explanation of some detailed information about the architecture and UX/UI designs.
May 18th, 2020