So basically I have been working on creating a rasa chatbot that can book a doctor’s appointment, and for now I have made it so you can tell the chatbot a specific date and time and it just sends a response saying your appointment has been booked for so and so date and time.
I now want to introduce a database of sorts where it can store the date and time mentioned by the user in some text file.
The next user that asks the chatbot to book an appointment on that exact date and time should receive a message saying the date and time is unavailable and maybe provide the closest next slot that is available by checking the text file.
With Rasa you are able to build a conversational AI system where you can add certain integrations.
In your example, you can build a conversation in Rasa, using Rules and Forms and provide integrations using custom action,
In order to know the next available slots, you can potentially create a custom action that you can integrate in your rules(when the custom action must be called) to check in the DB, when must the appointment in possible, the algorithm to check slot availability can be written in the custom action.
with Rasa you can capture notable information from the patient such as when is the desired appointment needed and the name of the patient etc.
Hey thanks a lot for the response. As you have mentioned, I have created a custom actions file, but I have basically asked it from chat_gpt as i am not very experienced with coding with python.
But I am not able to run it due to some issues while running it
If you don’t mind would you please have a look at it ?
This is the error I am getting
Traceback (most recent call last):
File “c:\users\work.pyenv\pyenv-win\versions\3.8.4\lib\site-packages\rasa\core\actions\action.py”, line 780, in run
response: Any = await self.action_endpoint.request(
File “c:\users\work.pyenv\pyenv-win\versions\3.8.4\lib\site-packages\rasa\utils\endpoints.py”, line 184, in request
raise ClientResponseError(
rasa.utils.endpoints.ClientResponseError: 404, Not Found, body=‘b’{“error”:“No registered action found for name 'check_availability'.”,“action_name”:“check_availability”}‘’
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File “c:\users\work.pyenv\pyenv-win\versions\3.8.4\lib\site-packages\rasa\core\processor.py”, line 982, in _run_action
events = await action.run(
File “c:\users\work.pyenv\pyenv-win\versions\3.8.4\lib\site-packages\rasa\core\actions\action.py”, line 810, in run
raise RasaException(
rasa.shared.exceptions.RasaException: Failed to execute custom action ‘check_availability’
from typing import Any, Text, Dict, List
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
def check_availability(requested_slot):
with open(‘booked_slots.txt’, ‘r’) as file:
booked_slots = [line.strip() for line in file]
if requested_slot in booked_slots:
response = f"Sorry, the requested slot is booked. Available slots are: "
else:
response = "Booking confirmed for the requested slot."
return response
you need to run rasa run actions --action path-to-your-actions-folder so it can find the actions.
also best if you can add an empty __init__.py in the actions folder
Thanks for the response. But it still does not seem to be working.
To make sure I am not making a silly error, this is exactly what I am typing in the terminal:
rasa run actions --action C:\Users\WORK\Desktop\chatbot\actions
As you have suggested I have also created an empty __init__.py folder
The error message I am currently getting is
SANIC_VERSION = LooseVersion(sanic_version)
2024-02-16 20:05:42 INFO rasa_sdk.endpoint - Starting action endpoint server...
2024-02-16 20:05:42 ERROR rasa_sdk.executor - Failed to register package 'C:\Users\WORK\Desktop\chatbot\actions'.
Traceback (most recent call last):
File "c:\users\work\.pyenv\pyenv-win\versions\3.8.4\lib\site-packages\rasa_sdk\executor.py", line 263, in register_package
self._import_submodules(package)
File "c:\users\work\.pyenv\pyenv-win\versions\3.8.4\lib\site-packages\rasa_sdk\executor.py", line 219, in _import_submodules
package = self._import_module(package)
File "c:\users\work\.pyenv\pyenv-win\versions\3.8.4\lib\site-packages\rasa_sdk\executor.py", line 240, in _import_module
module = importlib.import_module(name)
File "c:\users\work\.pyenv\pyenv-win\versions\3.8.4\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'C:\\Users\\WORK\\Desktop\\chatbot\\actions'
2024-02-20 18:20:57 ERROR rasa_sdk.executor - Failed to register package 'C:\Users\WORK\Desktop\chatbot\actions\'.
Traceback (most recent call last):
File "c:\users\work\.pyenv\pyenv-win\versions\3.8.4\lib\site-packages\rasa_sdk\executor.py", line 263, in register_package
self._import_submodules(package)
File "c:\users\work\.pyenv\pyenv-win\versions\3.8.4\lib\site-packages\rasa_sdk\executor.py", line 219, in _import_submodules
package = self._import_module(package)
File "c:\users\work\.pyenv\pyenv-win\versions\3.8.4\lib\site-packages\rasa_sdk\executor.py", line 240, in _import_module
module = importlib.import_module(name)
File "c:\users\work\.pyenv\pyenv-win\versions\3.8.4\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'C:\\Users\\WORK\\Desktop\\chatbot\\actions\\'
Hey I did try what you mentioned earlier and there seems to be no change. Getting the same error I believe