diff --git a/bot/__init__.py b/bot/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bot/actions.py b/bot/actions.py index 32493ee..341e537 100644 --- a/bot/actions.py +++ b/bot/actions.py @@ -4,50 +4,24 @@ # See this guide on how to implement these action: # https://rasa.com/docs/rasa/core/actions/#custom-actions/ -from typing import Any, Text, Dict, List -from rasa_sdk import Action, Tracker -from rasa_sdk.executor import CollectingDispatcher -import spacy -# -# -nlp = spacy.load('en_core_web_sm') - - -class ActionSubjectCourses(Action): - def name(self) -> Text: - return "action_subject_courses" - - def run(self, dispatcher: CollectingDispatcher, - tracker: Tracker, - domain: Dict[Text, Any]) -> List[Dict[Text, Any]]: - print('running action_subject_courses') - dispatcher.utter_message(template="utter_fetching_data") - print(tracker.latest_message.get('entities')) - elements = [{"type":"subject_courses","entities":tracker.latest_message.get('entities'), "intent" : "subject_courses"}] - dispatcher.utter_message(json_message=elements) - #dispatcher.utter_custom_message(*elements) - #dispatcher.utter_custom_json(elements) - return [] - - -class FallbackAction(Action): - def name(self): - return "fallback_action" +# This is a simple example for a custom action which utters "Hello World!" - def run(self, dispatcher, tracker, domain): - intent_ranking = tracker.latest_message.get('intent_ranking', []) - doc = nlp(tracker.latest_message.get('text')) - nouns = [] - adjs = [] - for token in doc: - if token.pos_ == 'NOUN': - nouns.append(token.text) - if token.pos_ == 'ADJ': - adjs.append(token.text) - if len(intent_ranking) > 0 : - elements = [{"type":"low_confidence","entities":nouns, "adj":adjs, "intent" : "low_confidence"}] - dispatcher.utter_message(json_message=elements) - else : - elements = [{"type":"low_confidence","entities":nouns, "adj":adjs, "intent" : "low_confidence"}] - dispatcher.utter_message(json_message=elements) +# from typing import Any, Text, Dict, List +# +# from rasa_sdk import Action, Tracker +# from rasa_sdk.executor import CollectingDispatcher +# +# +# class ActionHelloWorld(Action): +# +# def name(self) -> Text: +# return "action_hello_world" +# +# def run(self, dispatcher: CollectingDispatcher, +# tracker: Tracker, +# domain: Dict[Text, Any]) -> List[Dict[Text, Any]]: +# +# dispatcher.utter_message(text="Hello World!") +# +# return [] diff --git a/bot/config.yml b/bot/config.yml index bf250c4..e22e49c 100644 --- a/bot/config.yml +++ b/bot/config.yml @@ -2,24 +2,25 @@ # https://rasa.com/docs/rasa/nlu/components/ language: en pipeline: -- name: "WhitespaceTokenizer" -- name: "RegexFeaturizer" -- name: "CRFEntityExtractor" -- name: "EntitySynonymMapper" -- name: "CountVectorsFeaturizer" -- name: "CountVectorsFeaturizer" - analyzer: "char_wb" - min_ngram: 1 - max_ngram: 4 -- name: "EmbeddingIntentClassifier" + - name: WhitespaceTokenizer + - name: RegexFeaturizer + - name: LexicalSyntacticFeaturizer + - name: CountVectorsFeaturizer + - name: CountVectorsFeaturizer + analyzer: "char_wb" + min_ngram: 1 + max_ngram: 4 + - name: DIETClassifier + epochs: 100 + - name: EntitySynonymMapper + - name: ResponseSelector + epochs: 100 # Configuration for Rasa Core. # https://rasa.com/docs/rasa/core/policies/ policies: - name: MemoizationPolicy - - name: KerasPolicy + - name: TEDPolicy + max_history: 5 + epochs: 100 - name: MappingPolicy - - name: FallbackPolicy - nlu_threshold: 0.7 - core_threshold: 0.5 - fallback_action_name: "fallback_action" diff --git a/bot/credentials.yml b/bot/credentials.yml index 952154f..58c3eec 100644 --- a/bot/credentials.yml +++ b/bot/credentials.yml @@ -23,10 +23,10 @@ rest: #mattermost: # url: "https:///api/v4" -# team: "" -# user: "" -# pw: "" +# token: "" # webhook_url: "" +# This entry is needed if you are using Rasa X. The entry represents credentials +# for the Rasa X "channel", i.e. Talk to your bot and Share with guest testers. rasa: url: "http://localhost:5002/api" diff --git a/bot/data/nlu.md b/bot/data/nlu.md index e3a48d7..5acacad 100644 --- a/bot/data/nlu.md +++ b/bot/data/nlu.md @@ -5,24 +5,48 @@ - good morning - good evening - hey there -- good after noon -- good evening -- hi there -- wassup -- what's up -- namaste -- vanakkam - -## intent:how_you -- how are you -- how you doing -- how do you do -- whats up -- how is it going -- how are you today -- How have you been? -- whassup -- What are you up to + +##intent: find_and_play_content +- find and play content +- Find and play content + +##intent: download_update_diska_app +- download update the DIKSHA mobile app +- Download/update the DIKSHA mobile app + +##intent: other_queries +- other queries +- Other Queries + +##intent: board_menu +- Board Menu +- board menu + +##intent: state_board_link +- tn +- kr +- gj +- up + +##intent: cbse +- CBSE +- cbse + +##intent: state_board +- State Board +- state board + +##intent: how_to_scan_using_qr_code +- how to scan using qr code +- How to scan using qr code + +##intent: not_able_to_login +- not able to login +- Not able to login + +##intent: other +- other +- Other ## intent:goodbye - bye @@ -30,118 +54,45 @@ - see you around - see you later +## intent:affirm +- yes +- indeed +- of course +- that sounds good +- correct + +## intent:deny +- no +- never +- I don't think so +- don't like that +- no way +- not really + +## intent:mood_great +- perfect +- very good +- great +- amazing +- wonderful +- I am feeling very good +- I am great +- I'm good + +## intent:mood_unhappy +- sad +- very sad +- unhappy +- bad +- very bad +- awful +- terrible +- not very good +- extremely sad +- so sad + ## intent:bot_challenge - are you a bot? - are you a human? - am I talking to a bot? - am I talking to a human? -- who are you? -- who am i talking to -- what is your name -- tell me your name -- who is this? -- tell me about yourself - -## intent:worksheet -- about worksheet -- tell me about worksheet for a course -- what does worksheet do -- What is a worksheet for -- What is a worksheet? -- what are worksheets for? -- i need to know about worksheet -- how can a worksheet help me? -- what can a worksheet do for me? -- Explain me about worksheet -- How does a worksheet work? - -## intent:course_mentor -- what is a course mentor? -- who is course mentor -- course mentor -- who is mentor -- tell me about mentor for a course -- what do course mentors do -- what is a mentor for -- what are mentors for? -- i need to know about mentors -- how can a course mentor help me? -- what can a mentor do for me? - -## intent:flag_reviewer -- what is a flag reviewer? -- who is flag reviewer -- flag reviewer -- who is flag reviewer -- tell me about reviewer for flag -- what do flag reviewer do -- what is a reviewer for -- what are flag reviewers for? -- i need to know about flag reviewers -- how can a flag reviewer help me? -- what can a flag reviewer do for me? - -## intent:language_support -- How many languages does Diksha support? -- Does Diksha support [hindi](medium)? -- Can I learn in [hindi](medium) language? -- I want to learn in [hindi](medium). Is it possible in this? -- is there content in [kannada](medium)? -- i want content in [english](medium) -- in which languages content is there -- what language do you support -- do you support [marathi](medium) language -- do you support [urdu](medium) medium - -## intent:content_customization -- Can we make the content specific to an organisation? -- Can we have private content for an organisation? -- Is there a way we can make the contents private for an organisation? -- can we customize the content for us? -- can we have customized content for our company? -- can we have our own content base? -- can we have separate content repository? -- i want to create content for my organisation -- i need content specific to our organisation -- i need content specific to our company -- can we get tailored content for us? -- customize content for us -- customized content - -## intent:author_credit -- How can I give credits to the authors? -- Can I see who are the authors? -- How can I add the names of authors in the content? -- Is there a way to give credits to the content authors? -- add author name to content -- add author credit -- how to add name to credits -- how can i add my name as author -- content author adding -- process to add name in credits as author -- process to add name in author credit -- i am author to book, how can i add my name in credit -- add author to material -- add name in credit of content - -## intent:content_suggestions -- I want to learn [CBSE](board) content -- I'm a student from [Maharashtra](board) and want to learn from home -- Do you have any content from [Karnataka](board) state board -- Show me class [one](grade) content from [Tamil Nadu](board) -- Please show [second](grade) standard content -- I want to do [maths](subject) revision -- I want to learn [fourth](grade) standard [physics](subject) - -## lookup:board -data/boards.txt - -## lookup:grade -data/grades.txt - -## lookup:subject -data/subjects.txt - -## lookup:medium -data/mediums.txt - diff --git a/bot/data/stories.md b/bot/data/stories.md index bda2995..9be1197 100644 --- a/bot/data/stories.md +++ b/bot/data/stories.md @@ -1,14 +1,45 @@ -## greet user +## menu 1 path * greet - utter_greet +* find_and_play_content + - utter_board +* cbse + - utter_cbse +* state_board + - utter_state_board +* state_board_link + - utter_state_board_link +* board_menu + - utter_board +* mood_great + - utter_happy + +## menu 2 path +* greet + - utter_greet +* download_update_diska_app + - utter_download_update_diska_app -## how_you -* how_you - - utter_how_you - -## get started -* get_started - - utter_get_started +## menu 3 path +* greet + - utter_greet +* other_queries + - utter_other_queries +* how_to_scan_using_qr_code + - utter_how_to_scan_using_qr_code +* not_able_to_login + - utter_not_able_to_login +* other + - utter_other + +## sad path 3 +* greet + - utter_greet +* mood_unhappy + - utter_cheer_up + - utter_did_that_help +* deny + - utter_goodbye ## say goodbye * goodbye @@ -17,31 +48,3 @@ ## bot challenge * bot_challenge - utter_iamabot - -# course_mentor -* course_mentor - - utter_course_mentor - -# flag_reviewer -* flag_reviewer - - utter_flag_reviewer - -# content_customization -* content_customization - - utter_content_customization - -# content_suggestions -* content_suggestions - - utter_content_suggestions - -# language_support -* language_support - - utter_language_support - -# author_credit -* author_credit - - utter_author_credit - -# worksheet -* worksheet - - utter_worksheet \ No newline at end of file diff --git a/bot/domain.yml b/bot/domain.yml index ca74cf6..cfeb40f 100644 --- a/bot/domain.yml +++ b/bot/domain.yml @@ -1,137 +1,98 @@ intents: - greet - goodbye + - affirm + - deny + - mood_great + - mood_unhappy - bot_challenge - - get_started - - how_you - - worksheet - - course_mentor - - flag_reviewer - - language_support - - content_customization - - author_credit - - find_content - - content_suggestions - -entities: - - board - - grade - - medium - - subject - -actions: -- utter_greet -- utter_goodbye -- utter_iamabot -- fallback_action -- utter_out_of_scope -- utter_how_you -- utter_low_confidence -- utter_course_mentor -- utter_flag_reviewer -- utter_content_customization -- utter_language_support -- utter_author_credit -- utter_worksheet -- utter_content_suggestions + - find_and_play_content + - download_update_diska_app + - other_queries + - how_to_scan_using_qr_code + - not_able_to_login + - other + - cbse + - state_board + - state_board_link + - board_menu responses: utter_greet: - - custom: - blocks: - - type: "response" - text: "Hi there! Please press 0 for menu." - intent: "greet" - - utter_how_you: - - custom: - blocks: - - type: "response" - text: "I am good, thanks for asking. Please press 0 for menu." - intent: "how_you" - - utter_get_started: - - custom: - blocks: - - type: "response" - text: "Hello!" - intent: "get_started" - - utter_iamabot: - - custom: - blocks: - - type: "response" - text: "I am bot, here to help you. Please press 0 for menu." - intent: "who_am_i" + - text: "Hi, I’m TARA, your DIKSHA assistant. How may I help you today? Select from one of the following options" + buttons: + - title: "Find and play content" + payload: "find and play content" + - title: "Download/update the DIKSHA mobile app" + payload: "download update the DIKSHA mobile app" + - title: "Other Queries" + payload: "other queries" + + utter_board: + - text: "Tell me which of the following board you belong to, so that I can assist you better:" + buttons: + - title: "CBSE" + payload: "cbse" + - title: "State Board" + payload: "state board" + - title: "Go Back to Menu" + payload: "main_menu" + + utter_download_update_diska_app: + - text: "To download/update the DIKSHA mobile app Please visit ( https://play.google.com/store/apps/details?id=in.gov.diksha.app&hl=en_IN​ ) Tip : Press 9 to go back to the previous menu or 0 to the main menu." + + utter_other_queries: + - text: "Please select from the following options" + buttons: + - title: "How to scan using qr code" + payload: "how to scan using qr code" + - title: "Not able to Login" + payload: "not able to login" + - title: "Other" + payload: "other" + + utter_how_to_scan_using_qr_code: + - text: "Please visit: https://diksha.gov.in/help/getting-started/diksha-mobile-app/understanding-qr-code.html​ . Press 9 to go back to the previous menu or 0 to the main" + + utter_not_able_to_login: + - text: "Please visit:https://diksha.gov.in/help/getting-started/sign-in/index.html​ . Press 9 to go back to the previous menu or 0 to the main menu." + + utter_other: + - text: "Please visit:https://diksha.gov.in/help/getting-started/explore-diksha/index.html​ . Press 9 to go back to the previous menu or 0 to the main menu." + + utter_cbse: + - text: "Please visit (diksha.gov.in/CBSE/explore) to access eResources, videos, PDFs and practice sheets from the topics in your syllabus. Press 9 to go back to the previous menu or 0 to the main menu" + + utter_state_board: + - text: "Which of the following state boards you belong to" + buttons: + - title: "Tamil Nadu" + payload: "tn" + - title: "Karnataka" + payload: "kr" + - title: "Gujarat" + payload: "gj" + - title: "Uttar Pradesh" + payload: "up" + + utter_state_board_link: + - text : "Please visit (link to state board) to access eResources, videos, PDFs and practice sheets from the topics in your syllabus. Press 9 to go back to the previous menu or 0 to the main menu" + + utter_cheer_up: + - text: "Here is something to cheer you up:" + image: "https://i.imgur.com/nGF1K8f.jpg" + + utter_did_that_help: + - text: "Did that help you?" + + utter_happy: + - text: "Great, carry on!" utter_goodbye: - - custom: - blocks: - - type: "response" - text: "See ya!" - intent: "goodbye" - - utter_low_confidence: - - custom: - blocks: - - type: "response" - text: "Can you rephrase that please? Press 0 for menu." - intent: "low_confidence" - - utter_out_of_scope: - - custom: - blocks: - - type: "response" - text: "Sorry, I could not understand you. Please press 0 for menu." - intent: "out_of_scope" - - utter_worksheet: - - custom: - blocks: - - type: "response" - text: "A set or questions or tasks put together to assess the understanding of any particular topic/unit/chapter. Worksheets can be created on DIKSHA using the inbuilt content editor." - intent: "worksheet" - - - utter_course_mentor: - - custom: - blocks: - - type: "response" - text: "A Course Mentor guides and instructs learners on how to undertake a course On DIKSHA, a course mentor creates batches of users to to enrol for and take a course. Mentors also ensure completion of a course within a stipulated time." - intent: "course_mentor" - - utter_language_support: - - custom: - blocks: - - type: "response" - text: "We support English, Hindi, Kannada, Bengali, Marathi, Tamil, Telugu, Urdu languages." - intent: "language_support" - - - utter_content_customization: - - custom: - blocks: - - type: "response" - text: "Yes, you can customize the content for your domain. Any field/screen on DISKHA can be customized to suit organization needs." - intent: "utter_content_customization" - - utter_content_suggestions: - - text: "Sure, here are a few content for {board} {medium} {grade} {subject}" - - utter_flag_reviewer: - - custom: - blocks: - - type: "response" - text: "A person who assesses flagged content. On DIKSHA the flag reviewer reviews the content and rejects if the content is inappropriate according to DIKSHA review guidelines. The flag is removed if the content fits the guidelines" - intent: "flag_reviewer" - - utter_author_credit: - - custom: - blocks: - - type: "response" - text: "An author can be credited by following these steps. Log in to the diksha portal -> Select Workspace -> Select Create -> click the Course tile. -> Click Edit Details to enter/ modify the course details -> Enter Creators -> Enter Contributors details -> Enter Original Author details -> Click Save to save the details" - intent: "author_credit" + - text: "Bye" + utter_iamabot: + - text: "I am a bot, powered by Rasa." session_config: session_expiration_time: 60 diff --git a/bot/endpoints.yml b/bot/endpoints.yml index a1cc7fa..2330d15 100644 --- a/bot/endpoints.yml +++ b/bot/endpoints.yml @@ -1,7 +1,7 @@ # This file contains the different endpoints your bot can use. # Server where the models are pulled from. -# https://rasa.com/docs/rasa/user-guide/running-the-server/#fetching-models-from-a-server/ +# https://rasa.com/docs/rasa/user-guide/configuring-http-api/#fetching-models-from-a-server/ #models: # url: http://my-server.com/models/default_core@latest @@ -10,22 +10,13 @@ # Server which runs your custom actions. # https://rasa.com/docs/rasa/core/actions/#custom-actions/ -action_endpoint: - url: "http://localhost:5056/webhook" +#action_endpoint: +# url: "http://localhost:5055/webhook" # Tracker store which is used to store the conversations. # By default the conversations are stored in memory. # https://rasa.com/docs/rasa/api/tracker-stores/ -#tracker_store: -# type: tracker.elasticStore.ElasticTrackerStore -# url: "" -# host: "" -# db: "" -# username: "" -# password: "" - - #tracker_store: # type: redis # url: diff --git a/bot/tests/conversation_tests.md b/bot/tests/conversation_tests.md new file mode 100644 index 0000000..d7bcbfc --- /dev/null +++ b/bot/tests/conversation_tests.md @@ -0,0 +1,51 @@ +#### This file contains tests to evaluate that your bot behaves as expected. +#### If you want to learn more, please see the docs: https://rasa.com/docs/rasa/user-guide/testing-your-assistant/ + +## happy path 1 +* greet: hello there! + - utter_greet +* mood_great: amazing + - utter_happy + +## happy path 2 +* greet: hello there! + - utter_greet +* mood_great: amazing + - utter_happy +* goodbye: bye-bye! + - utter_goodbye + +## sad path 1 +* greet: hello + - utter_greet +* mood_unhappy: not good + - utter_cheer_up + - utter_did_that_help +* affirm: yes + - utter_happy + +## sad path 2 +* greet: hello + - utter_greet +* mood_unhappy: not good + - utter_cheer_up + - utter_did_that_help +* deny: not really + - utter_goodbye + +## sad path 3 +* greet: hi + - utter_greet +* mood_unhappy: very terrible + - utter_cheer_up + - utter_did_that_help +* deny: no + - utter_goodbye + +## say goodbye +* goodbye: bye-bye! + - utter_goodbye + +## bot challenge +* bot_challenge: are you a bot? + - utter_iamabot