Skip to content

Ui improvement #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
!/log/.keep

/tmp/*
/pdfs/*
/csvs/result.csv
/assets/images/profile_images

Expand Down
11 changes: 6 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ end
gem 'aasm', '~> 4.12', '>= 4.12.3'

gem 'record_tag_helper', '~> 1.0'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.4'
# writing and deploying cron jobs.
# gem 'whenever', :require => false

Expand Down Expand Up @@ -64,11 +65,8 @@ gem 'awesome_print'
# Authentication solution
gem 'devise'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.1'

# Use Puma as the app server
gem 'puma', '~> 3.7'
gem 'puma', '~> 3.10.0'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
Expand Down Expand Up @@ -124,7 +122,9 @@ group :development, :test do
gem 'selenium-webdriver'
# Use sqlite3 as the database for Active Record
#gem 'sqlite3'
# <<<<<<< HEAD =======
gem 'pg', '0.20.0'
# >>>>>>> c11d02a27049a1f80b4ce61492ed6e5159830aa5
gem 'railroady'
end

Expand All @@ -150,6 +150,7 @@ group :development do
# For call-stack profiling flamegraphs (requires Ruby MRI 2.0.0+)
gem 'flamegraph'
gem 'stackprof' # For Ruby MRI 2.1+
gem 'pg', '0.20.0'
end

group :production do
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,10 @@ DEPENDENCIES
pg (= 0.20.0)
polling
prawn (~> 2.2, >= 2.2.2)
puma (~> 3.7)
puma (~> 3.10.0)
rack-mini-profiler
railroady
rails (~> 5.1.1)
rails (~> 5.1.4)
rails-assets-eq.js
rails-assets-jquery
rails-assets-mdl-selectfield
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,15 @@ rails s
email: [email protected]
password: 12345678
```
* Search `@CoachAIBot` on [Telegram](https://web.telegram.org/#/login)
* Search `@CoachAIBot` on [Telegram](https://web.telegram.org/#/login)



* In case of server issues, as: "A server is already running. When restarting"

Try this:

- bin/bundle exec pumactl start -P tmp/pids/server.pid
- Wait for app to boot
- touch tmp/restart.txt
- App reboots just fine
3 changes: 3 additions & 0 deletions app/controllers/webhooks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ def callback
ap 'Rescued from:'
ap e
ap e.backtrace
<<<<<<< HEAD
=======
GeneralActions.new(@user,nil).send_reply 'Forse non ho capito bene cosa intendevi, potresti ripetere per favore?'
>>>>>>> c11d02a27049a1f80b4ce61492ed6e5159830aa5
end
render json: nil, status: :ok
end
Expand Down
3 changes: 2 additions & 1 deletion config/secrets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
# Environmental secrets are only available for that specific environment.

development:
# old_bot_token: 474840015:AAEWUooE8EecBDjYQmskZhLqdI0kaILf5Rg
dev_bot_token: 294560170:AAFaB9cQ-hCzQEfYNr6z30gD2K7FeDZ1gVQ
bot_token: 474840015:AAEWUooE8EecBDjYQmskZhLqdI0kaILf5Rg
bot_token: 509838469:AAFGZo_8SgNaV2NnRiH0KKDW2smkgbK-vpc
api_ai_token: 22dbf938bd724c8ebec6e0736bcf155e
secret_key_base: b76119aa5db9eff7c8478773bb365ec1b87d2d5fb5412d0f7ee85517ff123facdc64d5d713267b61dfa5f443dd2b524822226772b76d33a7efee8e130ca95706

Expand Down
1 change: 1 addition & 0 deletions csvs/features.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Id,Insert your age,How would you rate your overall health?,Does your work requir
8,23,4,Mostly sitting (Involves movement less than 30 minutes per week),1-2 times a week,Medium
2,23,4,Mostly moving (Involves movement more than 3days per week),> 3 times a week,Low
3,23,2,Mostly moving (Involves movement more than 3days per week),1-2 times a week,Low
4,30,4,Mostly moving (Involves movement more than 3days per week),1-2 times a week,High
1 change: 1 addition & 0 deletions csvs/result.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
1,8,23,4,Mostly sitting (Involves movement less than 30 minutes per week),1-2 times a week,Medium,LOW,LOW
2,2,23,4,Mostly moving (Involves movement more than 3days per week),> 3 times a week,Low,HIGH,HIGH
3,3,23,2,Mostly moving (Involves movement more than 3days per week),1-2 times a week,Low,HIGH,HIGH
4,4,30,4,Mostly moving (Involves movement more than 3days per week),1-2 times a week,High,HIGH,HIGH
92 changes: 63 additions & 29 deletions lib/bot_v2/dispatcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,147 +5,181 @@

class Dispatcher
attr_reader :message, :user

def initialize(message, user)
@message = message
@user = user
end

# process the user state
def process

if @user.nil?
# user needs to log in
LoginManager.new(@message, @user).manage
else

# dispatch in function of user state and text input
aasm_state = @user.aasm_state
ap "CURRENT USER: #{@user.id} STATE: #{aasm_state}"

case aasm_state
when 'idle'
manage_idle_state(text)

when 'activities'
manage_activities_state(text)

when 'messages'
manage_messages_state(text)

when 'feedback_plans'
manage_feedback_plans_state(text)

when 'feedback_activities'
manage_feedback_activities_state(text)

when 'feedbacking'
manage_feedbacking_state(text)

when 'questionnaires'
manage_questionnaires_state(text)
<<<<<<< HEAD

else # 'responding'
manage_responding_state(text)


=======

when 'responding'
manage_responding_state(text)

else
GeneralActions.new(@user,nil).send_reply 'Penso di non aver capito, potresti ripetere per favore?'
>>>>>>> c11d02a27049a1f80b4ce61492ed6e5159830aa5
end

end
end
<<<<<<< HEAD

def text
@message[:message][:text]
end

def back_strings
['Indietro', 'indietro', 'basta', 'Torna Indietro', 'Basta', 'back', 'Torna al Menu', 'Rispondi piu\' tardi/Torna al Menu']
end

def tell_me_more_strings
['Dimmi di piu', 'ulteriori dettagli', 'dettagli', 'di piu', 'Ulteriori Dettagli']
end

=======

>>>>>>> c11d02a27049a1f80b4ce61492ed6e5159830aa5
def manage_idle_state(text)
case text
# Activities & Plans
when *activities_strings #/(\w|\s|.)*(([Aa]+[Tt]+[Ii]+[Vv]+[Ii]*[Tt]+[AaÀà]*)|([Pp]+[Ii]+[Aa]+[Nn]+([Ii]+|[Oo]+)))+(\w|\s|.)*/
ap "---------CHECKING ACTIVITIES FOR USER: #{@user.id} ----------"
@user.get_activities!

# Feedbacks
when *feedback_strings #/(\w|\s|.)*([Ff]+[Ee]+[Dd]+[Bb]+[Aa]*([Cc]+|[Kk]+))+(\w|\s|.)*/
ap "---------CHECKING FOR FEEDBACK USER: #{@user.id}---------"
@user.show_plans_to_feedback!

# Messages
when *messages_strings #/(\w|\s|.)*([Mm]+[Ee]+[Ss]+[Aa]+[Gg]*[Ii])+(\w|\s|.)*/
ap "---------CHECKING MESSAGES FOR USER: #{@user.id}---------"
@user.get_messages!

# Questionnaires
when *questionnaires_strings #/(\w|\s|.)*([Qq]+[Uu]+[Ee]+[Ss]+[Tt]+[Ii]*[Oo]+[Nn]+[Aa]*[Rr]+[Ii]*)+(\w|\s|.)*/
ap "---------CHECKING QUESTIONNAIRES FOR USER: #{@user.id}---------"
@user.start_questionnaires!

else
<<<<<<< HEAD
ApiAIRedirector.new(text, @user).redirect
#GeneralActions.new(@user, nil).send_reply("Hey there")
=======
#ApiAIRedirector.new(text, @user).redirect
GeneralActions.new(@user,nil).send_reply 'Non ho capito! Usa i bottoni per interagire per favore!'

>>>>>>> c11d02a27049a1f80b4ce61492ed6e5159830aa5
end
end

def manage_activities_state(text)
ap "---------INFORMING ABOUT ACTIVITIES USER: #{@user.id}---------"
case text
when *back_strings
@user.cancel!
<<<<<<< HEAD

else # when 'Ulteriori Dettagli'
=======

when *tell_me_more_strings
>>>>>>> c11d02a27049a1f80b4ce61492ed6e5159830aa5
@user.get_details!

else
GeneralActions.new(@user,nil).send_reply 'Non ho capito! Usa i bottoni per interagire per favore!'
end
end

def manage_messages_state(text)
case text
# Respond Later
when *back_strings
ap "---------USER #{@user.id} CANCELLED MESSAGES RESPONDING ACTION---------"
@user.cancel!

else
ap "---------RECEIVING RESPONSE FOR COACH MESSAGE BY USER: #{@user.id}---------"
@user.respond!(text)
end
end


def manage_feedback_plans_state(text)
case text
when *tell_me_more_strings
@user.get_details!

when *back_strings
@user.cancel!

else
@user.show_activities_to_feedback!(text)
end
end

def manage_feedback_activities_state(text)
case text
when *back_strings
@user.cancel!

else
@user.start_feedbacking!(text)
end
end

def manage_feedbacking_state(text)
case text
when *back_strings
@user.cancel!

else
@user.feedback!(text)
end
end


def manage_questionnaires_state(text)
case text
when *back_strings
Expand All @@ -154,7 +188,7 @@ def manage_questionnaires_state(text)
@user.start_responding!(text)
end
end

def manage_responding_state(text)
case text
when *back_strings
Expand Down
Binary file added pdfs/10- Di'GangiMattia-plans.pdf
Binary file not shown.
Binary file added pdfs/12-PedronWerther-plans.pdf
Binary file not shown.
Binary file added pdfs/14-ConsoliAndrea-plans.pdf
Binary file not shown.
Binary file added pdfs/15-DoniniClaudia-plans.pdf
Binary file not shown.
Binary file added pdfs/17-SchiavoGianluca-plans.pdf
Binary file not shown.
Binary file added pdfs/2-CiaghiAaron-plans.pdf
Binary file not shown.
Binary file added pdfs/21-PalazziniFederico-plans.pdf
Binary file not shown.
Binary file added pdfs/3-MoliniPietro-plans.pdf
Binary file not shown.
Binary file added pdfs/4-FadhilAhmed -feedbacks.pdf
Binary file not shown.
Binary file added pdfs/4-FadhilAhmed -plans.pdf
Binary file not shown.
Binary file added pdfs/5-DiaconuMarian-plans.pdf
Binary file not shown.
Binary file added pdfs/6-Stoffie Damiano-plans.pdf
Binary file not shown.
Binary file added pdfs/7-PallaoroGabriele-feedbacks.pdf
Binary file not shown.
Binary file added pdfs/7-PallaoroGabriele-plans.pdf
Binary file not shown.
8 changes: 7 additions & 1 deletion telegram_webhook_req
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
https://api.telegram.org/bot474840015:AAEWUooE8EecBDjYQmskZhLqdI0kaILf5Rg/setWebhook?url=https://910ca535.ngrok.io/webhooks/telegram_vbc43edbf1614a075954dvd4bfab34l1
<<<<<<< HEAD
curl https://api.telegram.org/bot294560170:AAFaB9cQ-hCzQEfYNr6z30gD2K7FeDZ1gVQ/setWebhook?url=https://76875f2c.ngrok.io/webhooks/telegram_vbc43edbf1614a075954dvd4bfab34l1

curl https://api.telegram.org/bot509838469:AAFGZo_8SgNaV2NnRiH0KKDW2smkgbK-vpc/setWebhook?url=https://76875f2c.ngrok.io/webhooks/telegram_vbc43edbf1614a075954dvd4bfab34l1
=======
https://api.telegram.org/bot294560170:AAFaB9cQ-hCzQEfYNr6z30gD2K7FeDZ1gVQ/setWebhook?url=https://5521d08d.ngrok.io/webhooks/telegram_vbc43edbf1614a075954dvd4bfab34l1
>>>>>>> c11d02a27049a1f80b4ce61492ed6e5159830aa5