Freud

Made by Jo Zhouzheng

Found in SMS Bot

Freud is a SMS-based bot that interprets and visualizes your dreams. He keeps your dreams securely in your personal dream collection and spot patterns in your dreams that will help you on your journey of self-discovery.

0
Freud Chatbot Demo
Jo Zhouzheng - https://vimeo.com/296092095
0

Background


Sigmund Freud referred to dreams as being the royal road to the unconscious. He believed they held huge significance to our unconscious thoughts, feelings and desires. Sadly, people forget their dreams soon after they woke up. This is where the idea of Freud chatbot was born. Freud helps people understand the unknown region of their psyche through dream interpretation and visualization, and helps them document an incredible resource to gain a deeper understanding of self.


Freud chatbot is intended to solve the following problem:


How to leverage the existing information and segmented databases on dream analysis to help in providing insight into the meanings and interpretations to the symbols of your dreams. 
0

Resources


Inspiration: The Interpretation of Dreams
I draw a lot of inspiration from the book'The Interpretation of Dreams’from Sigmund Freud and prepared a .txt file on symbols of dream and their representations. This is the source of verbal interpretations of dream.


Verbal interpretation: Txt file & IBM Watson’s Natural Language Understanding (NLU) API
Freud was built with IBM Watson’s Natural Language Understanding APIto identify keywords or, in this case, key symbols from users’ description of their dreams, and search from the .txt file for corresponding interpretations.


Visual Interpretation:Unsplash API
To add more color to text messages, Unsplash (an visual image website) API was build in to search for key symbols and find the most relevant image that visualize their dreams.


Dream journal: database
All dreams, interpretations and images are kept in a database. Users can search for past dreams by tying in key symbols. 
0

The Process


1. Designing bot personality
In order to gain a deeper understanding of dream analysis, I read the book Interpretations of Dreams by Freud. Since I have a real person as the persona behind the bot, designing the tonality and conversation is not something I struggle with.


I drew words from the book, especially in the user onboarding process, to guide users through a “dream interpretation counseling session”. The language that Freud speaks provides a lot of guidance. He sounds compassionate, well-educated, profession, yet personable. 
0
2. Dialog Flow


I started with writing down the conversations between Freud and the user, almost like writing a screenplay and I constantly switch the roles and play Freud and the user. The process was incredibly helpful in terms of thinking through the conversation flow. I then conducted usability tests with a few people to test it out. Basically I pretend I am Freud and chat with users and see what might go wrong and what doesn’t make sense in my current flow. Revised dialog flow has taken the following factors into consideration:


Visibility and Error prevention: I want to give users option to request information at key steps in the workflow, and give them options to ‘exit’ to leave unwanted conversations. Error messages were carefully designed to offer a "menu", giving users instructions when got stuck in a workflow. I present users a confirmation option before they commit to the action, asking questions such as "Water was a symbol in your dream, is it correct?"
0
3. Technical aspects
I started with using IBM Watson’s Natural Language Understanding API to search for key words in user’s dream descriptions. 
0
#Define methods 
get "/test-nlp" do

  text = "A hero can be anyone. Even a man doing something as simple and reassuring as
  putting a coat around a little boy's shoulder to let him know that the world hadn't ended."

  response = get_npl_for(text)

  puts response.to_json

  keywords = get_keywords_from_response response

  keywords.to_s
end

def get_keywords_from_response resp

  return [] if resp.nil?


  keywords = []
  puts resp
  resp["keywords"].each do |kw|
    keywords << kw["text"]
  end

  return keywords

end


def get_npl_for text


  features = {
   sentiment: {}, keywords: {}, concepts: {}, emotion: {}, entities: {}
  }

  data = {
   "features" => features,
   "text" => text
  }
  params = {  "version" => "2018-03-19"  }

  headers = {
   "Content-Type"=>"application/json"
  }

  auth = { username: "apikey", password: ENV['WATSON_API_KEY'] }

  data = data.to_json if data.instance_of?(Hash)

  url = ENV["WATSON_URL"]
  method = "/v1/analyze"


 response = HTTParty.post(
   url + method,
   basic_auth: auth,
   headers: headers,
   query: params,
   body: data
   )
end


#SEARCH FOR KEYWORDS

if body.include? "i dreamt"
      session[:dream] = body
      response = get_npl_for( body )

      keywords = get_keywords_from_response( response )
      puts keywords
      answer = search_answer_for (keywords[0])
      image = search_unsplash_for( keywords.join( ", ") )
      media = image
      message = keywords[0].capitalize + " was a symbol in your dream. " + answer

end
Click to Expand
0
After an extensive research on meanings of dream symbols from various of data sources such as dreammoods.com, psychologytoday.com, I compile a list of common dream symbol and its representation in .txt file. Here is the method I used 
0
#Define Method to search for symbols in symbols.txt file

def search_answer_for body
message = " "
array_of_lines = IO.readlines("symbols.txt")
array_of_lines.each do |line|

  items=[ ]
  items=line.split ("=")
  symbols=items[0]
  answers=items[1]


  if body.include?symbols.to_s
     message = items[1]
  
  end

  end

  return message.to_s
end
Click to Expand
0
The next step in the process is to connect with the key symbols with Unsplash API to search for images that visualize the dream for the user. 
0
#Define unsplash methods to search for images with keywords

def search_unsplash_for response

  Unsplash.configure do |config|
    config.application_access_key = ENV['UNSPLASH_ACCESS_KEY']
    config.application_secret = ENV['UNSPLASH_SECRET']
    config.utm_source = "ExampleAppForClass"

  end

  search_results = Unsplash::Photo.search( response, 1, 1)

  puts search_results.to_json

  images = ""

  puts search_results.size

  search_results.each do |result|
    #puts result.to_json

    puts "Result"

    image_thumb = result["urls"]["thumb"]

    puts result["urls"]["thumb"].to_json
    image_description = result["description"].to_s
    images += "<img src='#{ image_thumb.to_s }' /><br/>"
    images += "<hr/>"

    return image_thumb.to_s
  end
  images
end

#Search 
image = search_unsplash_for( keywords.join( ", ") )
Click to Expand
0

Next steps

I envision Freud becomes an educational bot as more functionalities rolling out.


1. Users can subscribe to receive articles on different aspects of dream interpretation, or type in keywords to find an article of their interests. Users has the flexibility to choose the frequency of notification, etc.


2.Freud will take dream interpretation to the next level to remind users of similar dreams they had in the past to help them spot patterns in their dreams.


These way Freud can truly empower users to not just understand their dreams as segmented interpretations, but use a longitudinal data to analyze the patterns and provide personalized insights. 
x
Share this Project

Found In
Courses

49714 Programming for Online Prototypes

· 15 members

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


About

Freud is a SMS-based bot that interprets and visualizes your dreams. He keeps your dreams securely in your personal dream collection and spot patterns in your dreams that will help you on your journey of self-discovery.

Created

October 19th, 2018