diff --git a/README.md b/README.md index fa0c2cb..cec0f4a 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ The chatbot will do so by doing a basic check of the user input, and redirecting * [Windows](#windows-powershell) * [Unix](#unix-bash) * [Run Bot](#run) -* [Main Bot (input/output)](#main-bot) +* [Overall chat structure](#overall-chat-structure) * [Mini Bots (products & store information)](#product--store-mini-bots) * [Tests](#tests) * [All cases](#test-all-cases) @@ -38,9 +38,9 @@ Then import the dialogflow-agent.zip to your project. Refer to the first part of 4. Create a Paypal sandbox account and retrieve client_id and secret. Refer to this [blog](https://developer.paypal.com/api/rest/) 5. Set environment variables. -#### Windows (PowerShell) +### Environment variables +#### Windows -Creating virtual environment and install dependencies to run the bot: **Powershell** ```powershell python3 -m venv venv @@ -51,42 +51,35 @@ $env:secret= ``` **Command Prompt** -Setting up the environment variables for the bot (Google cloud key) in cmd: ```command prompt python3 -m venv venv venv\Scripts\activate setAPI_KEY= setclient_id= -setsecret= +setsecret= ``` #### Unix (Bash) -Creating virtual environment and install dependencies to run the bot: - ```bash ./install.sh -``` - -Setting up the environment variables for the bot (Google cloud key). -```bash export API_KEY= export client_id= export secret= ``` -## Run +### Run ```bash python3 index.py ``` ## Overall chat structure -Whenever user sends a message on Facebook messenger, a request containing the message will be sent to Dialogflow agent. Intent of the message is detected by the agent. If the intent is *Default Welcome intent* or *Default Fallback Intent*, Dialogflow will handle it itself and respond to Messenger app. Otherwise, Dialogflow sends another request to our webhook server to handle fullfilment. +Whenever user sends a message on Facebook messenger, a request containing the message will be sent to Dialogflow agent. Intent of the message is detected by the agent. If the intent is *Default Welcome intent* or *Default Fallback Intent*, Dialogflow will handle it itself and respond to Messenger app. Otherwise, Dialogflow sends another request to our web server to handle fullfilment. ![](https://research.aimultiple.com/wp-content/webp-express/webp-images/uploads/2020/05/dialogflow.png.webp) -## Product & Store Mini-bots +### Product & Store Mini-bots This mini-bot will handle any question related to product price, stock, and store information. The bot first determines what topic is of interest (product or store information) and breaks the user's message down into keywords. The bot then compares these words and checks them in order to create the most appropriate response, and returns the response to the main function. diff --git a/app/products/README.md b/app/products/README.md index 47ac302..7c9acf8 100644 --- a/app/products/README.md +++ b/app/products/README.md @@ -1,114 +1,35 @@ ## Products and Store info + This mini-bot will handle any question related to product price, stock, and store information. The bot first determines what topic is of interest (product or store information) and breaks the user's message down into keywords. The bot then compares these words and checks them in order to create the most appropriate response, and returns the response to the main bot. ------------------------- -------------------------- +### Method handle_store_info -### SuperClass BaseHandler -A superclass used to reperesent skeleton for a mini-bot to handle product/store queries. -```console -className = BaseHandler() -``` -###### Attributes: -runtime_mode: str -The environment that the bot is running in (i.e. DEV or PRODUCTION). -handler_map: dict -The mapping from sub-topic and corresponding handler. +A method reperesents a mini-bot to handle store queries. The entry point of the mini-bot. Main function will call this method to pass in the message to process. -------------------------- -### Methods -#### `__init__` -Construct all the necessary attributes for the ProductHandler object. -###### Parameters -None -###### Returns -None - -#### `dispose` (common method) -This method releases any resources with this minibot (i.e. database connection). -```console -BaseHandler().dispose() -``` -###### Parameters -None -###### Returns -None -#### `handle` (abstract) -The entry point of the mini-bot. Main bot will call this method to pass in the message to process. ```console -response = BaseHandler().handle(message) +handle_store_info(string) -> string ``` -###### Parameters -message: str -The message that the user sends to the bot. -###### Returns -response: str -The response string to the request message. -#### `parse` (abstract) -The entry point of the mini-bot. Main bot will call this method to pass in the message to process. ```console -response = BaseHandler().handle(message) -``` -###### Parameters -message: str -The message that the user sends to the bot. -###### Returns -response: str -The response string to the request message. - -------------------------- -------------------------- -### Class StoreInfoHandler -A class used to reperesent a mini-bot to handle store queries. Extension of BaseHandler. -```console -className = StoreInfoHandler() +response = StoreInfoHandler().handle(message) ``` -###### Attributes: -runtime_mode: str -The environment that the bot is running in (i.e. DEV or PRODUCTION). -handler_map: dict -The mapping from sub-topic and corresponding handler. -------------------------- -### Methods -#### `__init__` -Construct all the necessary attributes for the ProductHandler object. -###### Parameters -None -###### Returns -None +### Properties ###### Parameters message: str The message that the user sends to the bot. ###### Returns matched, "store_info", store_words: tuple The tuple consisting of whether the request relates to store info or not, the topic name, and a dictionary of the keywords. -#### `dispose` (common method) -This method releases any resources with this minibot (i.e. database connection). -```console -StoreInfoHandler().dispose() -``` -###### Parameters -None -###### Returns -None -#### `handle` (override) -The entry point of the mini-bot. Main bot will call this method to pass in the message to process. -```console -response = StoreInfoHandler().handle(message) -``` -###### Parameters -message: str -The message that the user sends to the bot. -###### Returns -response: str -The response string to the request message. -#### `parse` (override) + +#### `parse` Indicates whether the request is related to store information, and then breaks down the message into its keywords. + ```console store_words = StoreInfoHandler().parse(message) ``` + ###### Parameters message: str The message that the user sends to the bot.