Skip to content

Commit

Permalink
Modified product&store info readme
Browse files Browse the repository at this point in the history
  • Loading branch information
nganphan123 committed Apr 14, 2022
1 parent 59cc695 commit b09408c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 103 deletions.
21 changes: 7 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -51,42 +51,35 @@ $env:secret=<Your Paypal 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=<Your key>
setclient_id=<Your Paypal client id>
setsecret=<Your Paypal secret>
setsecret=<Your Paypal client secret>
```

#### 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=<Your key>
export client_id=<Your Paypal client id>
export secret=<Your Paypal 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.

Expand Down
99 changes: 10 additions & 89 deletions app/products/README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit b09408c

Please sign in to comment.