Slots for querying from a database

My aim is to query a given database for bill amount of a customer. I will query it using the customer number which the user gives, use pandas to get the bill amount for that customer number, and then the chatbot should return the bill amount.

How do I accomplish this using slots? Exactly how should my domain.yml and files look like? And how should I modify my file to include the pandas querying bit?

If someone could answer these questions using a brief example, then great! Thank you.

Why do you want to use pandas when you can directly extract the details(e.g. bill amount) from the query result and dispatch it the user as a message.

Directly extract as in? I need pandas to traverse the csv file in which some records are stored, to find the applicant number that the user mentioned in his message, and then get the bill amount. This pandas bit is done anyway.

I’m trying to understand how to use slots.

If pandas part is over, then you can dispatch the bill amount to user. What is your exact requirement with slots?

Yes, that is what I’m doing right now. Directly dispatching. The problem is that this only works on the console, since I’m doing the pandas bit in the file in rasa/core/channels. I am currently working on a Rasa UI using Angular, and the problem is that I am not able to find the python file to add the pandas bit, like I did in . Which is why I thought I would use slots.

Can you help me find the python file instead? Would be much easier…

I think is not the right place to do such calculations. You can invoke a custom action and write your pandas logic there. Action class has a dispatcher that will enable you to dispatch the message to user.

For integration with Angular you can use the webhook REST API. i.e. POST /webhooks/rest/webhook

Okay, and the pandas bit I’ve written in should be called from where?

It will be invoked from the story you will write. The intent of user message will invoke the particular story and your custom action will be invoked as a consequence.

   ## pandas story
    * ask_bill_amount
      - action_calculate_bill_amount

Even to access slots you need the tracker object in the run method of action class. To set the slot, you can return the event SlotSet("slot_name", "slot_value") from the custom action.

I tried this. It asked to update endpoints.yml file and domain.yml file also, which I did. Now it keeps saying Requested URL not found or Couldn’t connect to the server. This is what I uncommented out in endpoints.yml:

action_endpoint: url: “http://localhost:5055/webhook

Yes looks good to me. Now from angular, you can hit the REST API http://localhost:5055/webhooks/rest/webhook with your messages in the following format:

  "sender": "Sanjay",
  "message": "Hi there!"

Thanks a lot for the help, man. Appreciate it!