I am designing a bot where for a particular action , it would take some time to complete the action . Is it possible to come out of that action and respond when it is done in the UI so that in the mean time other actions can be done
Hi @hemamalini, do you mean within Rasa X and a custom action? Rasa already calls remote actions in an async way, so the server should be responsive when youâre waiting for your custom action to complete
Hi not with Rasa X. Using open source Rasa and custom ui. If some custom actions are taking time ,is it possible for the server to handle other queries and answer this when that custom action gets over
Yes, remote actions are called asynchronously, so this is already happening
Hi @ricwo
I am having the same problem : It seems that rasa actions server is executing the custom actions sequentially .
For reference, I am providing u the logs :
My rasa model server has these properties:
2020-08-26 17:39:46 DEBUG rasa.core.tracker_store - Attempting to connect to database via âsqlite://:***@/rasa_server.dbâ.
2020-08-26 17:39:46 DEBUG rasa.core.tracker_store - Connection to SQL database ârasa_server.dbâ successful.
2020-08-26 17:39:46 DEBUG rasa.core.tracker_store - Connected to SQLTrackerStore.
2020-08-26 17:39:46 DEBUG rasa.core.lock_store - Connected to lock store âInMemoryLockStoreâ.\
For two queries : i am giving you logs of rasa server and actions server.
Logs of rasa Model server -
Here u can see there are two users with sender_id {sbm.kumar , vi.kumar}
And two Queries - âFind Issuesâ and âPrediction Issuesâ
sbm.kumar request for âPrediction Issuesâ functionality which comes at 17:52:50
vi.kumar request for âFind Issuesâ functionality which comes at 17:52:53\
2020-08-26 17:52:50 DEBUG rasa.core.tracker_store - Recreating tracker from sender id âsbm.kumarâ
2020-08-26 17:52:50 DEBUG rasa.core.processor - Received user message â/ask_predict_issues_partâ
2020-08-26 17:52:50 DEBUG rasa.core.actions.action - Calling action endpoint to run action âaction_predict_issues_partâ.
2020-08-26 17:52:53 DEBUG rasa.core.tracker_store - Recreating tracker from sender id âvi.kumarâ
2020-08-26 17:52:53 DEBUG rasa.core.processor - Received user message â/ask_find_issues_partâ
2020-08-26 17:52:53 DEBUG rasa.core.actions.action - Calling action endpoint to run action âaction_find_issues_partâ.\
Logs of rasa actions server -
Here , at 17:52:39 - Preiction custom action runs and the actions server prints nothing until this action completes.
âapi for predicting issues is called.â this api takes time .
Until this api is completed there is no log of âFind Issuesâ custom action.
U can check this from timestamp.
Once âaction_predict_issues_partâ completes then at 17:53:52 âaction_find_issues_partâ starts
[2020-08-26 17:52:39] âPOST /webhook HTTP/1.1â 200 1842 0.019000
action_predict_issues_part
api for predicting issues is called.
action_completed\
[2020-08-26 17:53:52] âPOST /webhook HTTP/1.1â 200 12050 62.046102
action_find_issues_part
action_completed\
My Observations-
The behaviour of Rasa Model server is Async and Parallel ,
But behaviour of Rasa Actions server to execute custom actions is sequential\
Kindly tell me what i can do or am i missing anything to make you understand my query.\
Youâre right - the action server itself runs actions sequentially. The Rasa server however runs remote actions async
@ricwo Thanks for your response. But I want to make it async. If 100 users will use my RASA bot then the 100th user will get response too late Kindly help me to solve it
My bot is about to go in production phase , i am just stuck to this problem Kindly help
This is already the case.
For a given user, the actions will run sequentially. For incoming messages from different users, this does not happen. The /webhooks/rest/webhook
endpoint is an async endpoint.
Hi @ricwo
For different users also I am getting the same scenario - âSequential Processing of custom actionsâ .
This is what I am asking .
Kindly help me to solve it
If the execution of the custom action takes the same amount of time for all users, then they will most likely be processed sequentially. The ordering here is not guaranteed though
Hello I have recently faced the same problem and resolved it.
To make any custom rasa action asynchronous, you have to do following two things:
- declare the
run()
method of your custom action as async
class ActionMyCustomAction(Action):
def name(self):
return "action_my_custom_action"
async def run(self, dispatcher, tracker, domain):
'''
write your code here
'''
return []
- Make all the functions inside
run()
method as async.
- Example of making
time.sleep(5)
as async
await asyncio.sleep(5)
- Example of making api calls as asynchronous
import asyncio
from aiohttp import ClientSession
async with ClientSession(headers=headers) as session:
async with session.post(url=url, json={"message": "hello"}) as response:
response = await response.text()
You may also refer this link. https://knowledgesmack.blogspot.com/2022/09/creating-rasa-custom-actions.html
I hope it helps
"Hey, I am using the approach you provided for making function calls asynchronous. However, when I call the API, it takes around 2 to 3 minutes to fetch the data, but I am encountering the following error within 1 minute or even earlier: âERROR rasa_sdk.endpoint - Exception occurred during execution of request sanic.exceptions.ServiceUnavailable: Response Timeoutâ
Could you please provide a solution for this?"