Skip to main content

This repository contains artifacts to help accelerate development of conversational interfaces using Rasa & Gip

Project description

Gupshup Conversation Helpers

  1. This repository contains artifacts to help accelerate development of conversational interfaces using Rasa & Gip
  2. Refer dialog-as-code.md document to get started with understanding.

Installation

  1. Use the command mentioned in the pypi.
  2. Pre Requisites of this package is rasa in a environment.
  3. python version below 3.8

Methods

Pre Handler

Pre Handler contain a method, get_context.

  1. get_context is used to set the gs_context from previous context and creates current_context dict.

  2. Get_context interanal sets few variables at the start of the conversion i.e active_menu,active_menu_state,menu_handled, live_dict

  3. These variables get refreshed each time accordingly.

     import gs_conv_help as helpers
     gs_context,current_context = helpers.get_context(dispatcher, tracker, domain)
    

Post handler

Post handler contain 2 methods, post_handle and get_events.

  1. post_handle is used to pass the response queue messages to the platform.

  2. get_events is used to set back the gs_context varible to slots of rasa.

     helpers.post_handle(dispatcher,gs_context,current_context)
    

Response cards

Response cards contain a method, show_response_card.

  1. show_response_card is used to convert a simple text or quick reply ot list into appropriate format.

  2. This method is used whenever there is a requirement of utter.

     helpers.show_response_card(gs_context,current_context,response_json)
    

Menu handler

Menu handler contain 2 methods, handle_active_menu and activate_menu.

  1. Menu, for any bot has to declared in domain.yml file of the bot.

  2. Whenevere a intent which triggers men is encountered then activate_menu is called with the intent name.

  3. activate_menu sets the menu_handled in gs_context to True which will help us to keep the conversation within menu.

  4. handle_active_menu method will be activated when menu_handled is true. this method will traverse through the menu options.

  5. In this current version, User entered text should exactly match with the options provided to traverse in the menu.

  6. Once all the options in the menu gets filled it will return current intent as "Menu_Completed" in current_context.

    Menu handler code is still in development

     helpers.activate_menu(gs_context,current_context,"clothes")
     helpers.handle_active_menu(gs_context,current_context)
    

DB handler

Menu handler is a class, which is initiated with database info.

  1. once the class object is created we can use few methods for opertions.
  2. methods are csv_to_db, get_document_for_key and set_document_for_key.

Sample Variables:

gs_context:

    {
    "sender_id": "03d362d4-aad9-4fc4-8ed0-84930852a38d_whatsapp:918217708911",
    "channel": "whatsapp",
    "active_menu": "clothes",
    "active_menu_state": ["clothes", "Women", "Custom Search"],
    "slots": {},
    "menu_handled": True,
    "past_conversation": "",
    "live_dict": { "Text Search": "", "Image Search": "" }
    }

Current context:

    {
    "current_intent": {
    "intent": "goodbye",
    "entities": {},
    "user_text": "Custom Search"
    },
    "domain": {
    "config": { "store_entities_as_slots": "True" },
    "session_config": {
    "session_expiration_time": 60,
    "carry_over_slots_to_new_session": "True"
    },
    "intents": [
    { "restart": { "use_entities": "True" } },
    { "greet": { "use_entities": "True" } },
    { "goodbye": { "use_entities": "True" } },
    { "clothes": { "use_entities": "True" } },
    { "support": { "use_entities": "True" } },
    { "nlu_fallback": { "use_entities": "True" } },
    { "main_menu": { "use_entities": "True" } },
    { "out_of_scope": { "use_entities": "True" } },
    { "check_human": { "use_entities": "True" } },
    { "affirm": { "use_entities": "True" } },
    { "deny": { "use_entities": "True" } },
    { "inform": { "use_entities": "True" } },
    { "welcome": { "use_entities": "True" } },
    { "later": { "use_entities": "True" } },
    { "gender": { "use_entities": "True" } },
    { "search": { "use_entities": "True" } },
    { "productsearch": { "use_entities": "True" } },
    { "faqs": { "use_entities": "True" } },
    { "help": { "use_entities": "True" } },
    { "thankyou": { "use_entities": "True" } },
    { "Feedback": { "use_entities": "True" } },
    { "product_menu": { "use_entities": "True" } }
    ],
    "entities": ["category", "gender_ent", "product", "main_menu"],
    "slots": {
    "gs_context": {
            "type": "rasa.shared.core.slots.TextSlot",
            "initial_value": "None",
            "auto_fill": "True",
            "influence_conversation": "True"
    }
    },
    "responses": {},
    "actions": ["action_custom_handler"],
    "forms": {},
    "e2e_actions": []
    },
    "response_queue": [
    {
    "type": "quick_reply",
    "content": {
            "type": "text",
            "header": "",
            "text": "Great🤓 now, please choose if you want to do a text search or Image Search \nPlease choose one from the below options",
            "caption": ""
    },
    "msgid": "qr1",
    "options": [
            { "type": "text", "title": "Text Search" },
            { "type": "text", "title": "Image Search" }
    ]
    }
    ]
    }

sample menu written in domain yml for a bot:

menus:
  clothes:
    Invalid-choice-message: That doesn't appear to be a valid choice
    prompt: Alright! I'm curious 🤩 as to what kind of outfits you're looking for, please choose one category.
    Card_Type: quick_reply
    Women:
      Invalid-choice-message: That doesn't appear to be a valid choice
      List_Header: Please choose from the following
      Card_Type: list
      List_category: select any one
      prompt: |-
        Awesome 🤩🤩 now you can customize your attire according to your preferred style, grab the best deals or search the best match. 
        Please choose one from the below options
      Custom Search:
        Invalid-choice-message: That doesn't appear to be a valid choice
        Card_Type: quick_reply
        prompt: |-
          Great🤓 now, please choose if you want to do a text search or Image Search 
          Please choose one from the below options
        Category:
          - Text Search
          - Image Search
      Create Whole Outfit:
        Invalid-choice-message: That doesn't appear to be a valid choice
        Card_Type: quick_reply
        prompt: |-
          We will help you create a unique, versatile wardrobe, so you never have to think about what to wear again. 
          Let's get to know your style with a few quick questions. 
          What kind of outfits you're looking for, please choose one category.
        Category:
          - Text Search
          - Image Search
      Style my outfit:
        Invalid-choice-message: That doesn't appear to be a valid choice
        Card_Type: quick_reply
        prompt: Now find effortless ways to become more fashionable. You can find matching apparel and accessory from head to toes.
        Clothes:
          - Top Wear
          - Bottom wear
        Accessories:
          - Top Wear
          - Bottom wear
        Shoes:
          - Top Wear
          - Bottom wear
      Offers:
        Invalid-choice-message: That doesn't appear to be a valid choice
        List_Header: Please choose from the following
        Card_Type: list
        List_category: select any one
        prompt: Check out the best offers and deals here. Please choose one from the options below😊
        Category:
          - x % off
          - best seller
          - fresh in stock
          - picked by celebrity
          - others 
    Men:
      Invalid-choice-message: That doesn't appear to be a valid choice
      List_Header: Please choose from the following
      Card_Type: list
      List_category: select any one
      prompt: |-
        Awesome 🤩🤩 now you can customize your attire according to your preferred style, grab the best deals or search the best match. 
        Please choose one from the below options
      Custom Search:
        Invalid-choice-message: That doesn't appear to be a valid choice
        Card_Type: quick_reply
        prompt: |-
          Great🤓 now, please choose if you want to do a text search or Image Search 
          Please choose one from the below options
        Category:
          - Text Search
          - Image Search
      Style my outfit:
        Invalid-choice-message: That doesn't appear to be a valid choice
        Card_Type: quick_reply
        prompt: Now find effortless ways to become more fashionable. You can find matching apparel and accessory from head to toes.
        Clothes:
          - Top Wear
          - Bottom wear
        Accessories:
          - Top Wear
          - Bottom wear
        Shoes:
          - Top Wear
          - Bottom wear
      Offers:
        Invalid-choice-message: That doesn't appear to be a valid choice
        List_Header: Please choose from the following
        Card_Type: list
        List_category: select any one
        prompt: Check out the best offers and deals here. Please choose one from the options below😊
        Category:
          - x % off
          - best seller
          - fresh in stock
          - picked by celebrity
          - others

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gs_conv_help-0.0.1.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gs_conv_help-0.0.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file gs_conv_help-0.0.1.tar.gz.

File metadata

  • Download URL: gs_conv_help-0.0.1.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.13

File hashes

Hashes for gs_conv_help-0.0.1.tar.gz
Algorithm Hash digest
SHA256 5a99846fb7a8886c063e8b01fe97df894e9df45c17261a7339a1bc0aef91a17e
MD5 c4c1d5e7a14c51a3dc452de9ec332fdb
BLAKE2b-256 8fef1c0f40ced69fade25dfc12010352aa195cd4e59384c2b3bcbb134dd1ce0a

See more details on using hashes here.

File details

Details for the file gs_conv_help-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: gs_conv_help-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.13

File hashes

Hashes for gs_conv_help-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0ab9e540597162309127a2b9c4cd58f13d9ea894e1043d7e5670f093871f9699
MD5 2b250ccd949ef23b75cdafb19b589938
BLAKE2b-256 378fb243dd046fe20071e2723d342aa32cab997801fe968f2b6fc3640754a401

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page