Failed to retrevie rows from SQL in Action

Hi guys , i faced some challenge to retreive product from database using my sqlite

i’m not sure why in actions i am unable to retreive a row for specific product_name when my enitity value was extracted for e.g pants and shoes but it works for others(e.g basketball and shirt) to return price. I had tested to query using WHERE alias product_name = “shoes” , it is working fine i had a entity called product with value should be obtain based on the lookup table during training. Can anyone help me to out of this ? Thanks

nlu:
- intent: check_product_price

  examples: |

    - how much does the [shirt](product) cost 

    - what is the price for [shoes](product)

    - price for [pants]

    - [basketball](product) cost how much

    - the cost for [shirt](product) cost

- lookup: product

  examples: |

    - shirt

    - shoes

    - pants

    - basketball

action.py

class Action_Find_Product_Price(Action):

def name(self) -> Text:
    return "action_find_product_price"

def run(self, dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

    # connect to DB
    connection = sqlite3.connect("retailDB.db")
    cursor = connection.cursor()

    # get slots and save as tuple
    product_t = tracker.get_slot("product")

    product = [(product_t)]


    # place cursor on correct row based on search criteria
    cursor.execute("SELECT * FROM product WHERE product_name=? ", product)
    
    # retrieve sqlite row
    data_row = cursor.fetchone()

    # retreive from cursor save as variable 
    
    if data_row:
        product_name_r = data_row[0]
        product_price_r = data_row[1]
        # provide in stock message
        dispatcher.utter_message(template="utter_product_price", product_name=product_name_r ,product_price=product_price_r)
        connection.commit()
        connection.close()
        slots_to_reset = ["product"]
        return [SlotSet(slot, None) for slot in slots_to_reset]
        
    else:
        # provide out of stock message
        dispatcher.utter_message(template="utter_no_stock")
        connection.commit()
        connection.close()
        slots_to_reset = ["product"]
        # reset slot
        return [SlotSet(slot, None) for slot in slots_to_reset]

stories.yml

   - story: check product price
  steps:
  - intent: check_product_price
  - action: action_find_product_price

database

result :

@BELIEVEIT

- price for [pants](product)

give some more example for others

product_price=product_price_r

Should be

product_price_range=product_price_r

try

But you getting the the price of shirt :face_with_monocle:

@BELIEVEIT Try delete the old model and train again please.

1 Like

Thanks , i managed to solve to problem by giving more training example