lib/dreaming_god/session.rb in dreaming_god-0.1.1 vs lib/dreaming_god/session.rb in dreaming_god-0.1.2

- old
+ new

@@ -22,11 +22,11 @@ @request = request case @request.type when 'LaunchRequest' # Prepare system card = response_card 'Dreaming God' - ssml_response(speak('Greetings User'), card, false) + ssml_response(speak('Greetings user. Tell me a fact for example, Cat is an animal.'), card, false) when 'IntentRequest' @intent = Alexagram::Intent.new(@request) intent_name = @intent.name.underscore case intent_name when 'list_rows' @@ -37,16 +37,16 @@ ssml_response(speak(result), card, false) else names = "" result = "Db#{(table_name.capitalize.singularize)}".constantize.all.limit(3) result.each do |r| - names << "#{result.name}," + names << "#{r.label}," end names = "#{table_name} is empty" if names.length == 0 res = "Here is the list of #{table_name}, #{names}" card = response_card res - ssml_response(speak(res), card, false) + ssml_response(speak(res), card, true) end when 'create_person' result = "" table_name = intent_name.split('_').last.pluralize name = @intent.slots['personname']['value'] #bob @@ -59,11 +59,11 @@ dbp.people_type = person dbp.save result = "Ok. #{name} is a #{person}" end card = response_card result - ssml_response(speak("#{result}"), card, false) + ssml_response(speak("#{result}"), card, true) when 'create_place' result = "" table_name = intent_name.split('_').last.pluralize name = @intent.slots['placename']['value'] # bahamas place = @intent.slots['place']['value'] # park @@ -75,11 +75,11 @@ dbp.place_type = place dbp.save result = "Ok. #{name} is a #{place}" end card = response_card result - ssml_response(speak("#{result}"), card, false) + ssml_response(speak("#{result}"), card, true) when 'create_thing' result = "" table_name = intent_name.split('_').last.pluralize name = @intent.slots['thingname']['value'] # bananna thing = @intent.slots['thing']['value'] # vegetable @@ -91,11 +91,11 @@ dbp.thing_type = thing dbp.save result = "Ok. #{name} is a #{thing}" end card = response_card result - ssml_response(speak("#{result}"), card, false) + ssml_response(speak("#{result}"), card, true) when 'select_row' column_a = @intent.slots['columna']['value'] #all case column_a when 'thing type' column_a = 'thing_type' @@ -115,11 +115,11 @@ result.each do |r| names << "#{r.send(column_b)}, " end names = "#{table_name} table is empty" if names.length == 0 card = response_card 'Dreaming God' - ssml_response(speak("I have found the following, #{names}"), card, false) + ssml_response(speak("I have found the following, #{names}"), card, true) when 'update_row' table_name = @intent.slots['table']['value'] #people column_a = @intent.slots['columna']['value'] #label value_a = @intent.slots['valuea']['value'] #joe column_b = @intent.slots['columnb']['value'] #label @@ -138,11 +138,11 @@ sql_string = "UPDATE db_#{table_name} SET #{column_a} = '#{value_a}' WHERE #{column_b} = '#{compare_value}'" result = "Db#{(table_name.capitalize.singularize)}".constantize.find_by_sql(sql_string) res = "I have updated the database where #{column_b} is equal to #{compare_value}" card = response_card res - ssml_response(speak(res), card, false) + ssml_response(speak(res), card, true) when 'destroy_row' table_name = @intent.slots['table']['value'] #people column = @intent.slots['column']['value'] #label compare_value = @intent.slots['comparevalue']['value'] #bob @@ -159,10 +159,10 @@ sql_string = "DELETE FROM db_#{table_name} where #{column} = '#{compare_value}'" "Db#{(table_name.capitalize.singularize)}".constantize.find_by_sql(sql_string) res = "I have destroyed rows from the database where #{column} is equal to #{compare_value}" card = response_card res - ssml_response(speak(res), card, false) + ssml_response(speak(res), card, true) else end when 'SessionEndedRequest' DbSession.detroy(@db_session.id.to_i)