I tried this solution. Its working for two message if has more, its show
TimeoutError
and Circuit breaker tripped
my action.py
from typing import Any, Text, Dict, List
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.events import FollowupAction,BotUttered,UserUtteranceReverted,ReminderScheduled,ActionExecuted
import time
class ActionDelayMsg1(Action):
current_msg_number = 0
def name(self) -> Text:
return "action_delay_msg1"
async def run(
self, dispatcher, tracker: Tracker, domain: Dict[Text, Any]
) -> List[Dict[Text, Any]]:
msgs = ["teste1","teste2","teste3"]
if(self.current_msg_number > 5):
self.current_msg_number = 0
return []
self.current_msg_number +=1
return [FollowupAction('action_delay_msg2')]
class ActionDelayMsg2(Action):
def name(self) -> Text:
return "action_delay_msg2"
async def run(
self, dispatcher, tracker: Tracker, domain: Dict[Text, Any]
) -> List[Dict[Text, Any]]:
time.sleep(3)
dispatcher.utter_message("teste")
return [FollowupAction('action_delay_msg1')]
Console output
Your input -> hi
teste
teste
2022-04-19 17:59:25 ERROR asyncio - Task exception was never retrieved
future: <Task finished name='Task-3' coro=<configure_app.<locals>.run_cmdline_io() done, defined at /Users/johnguimaraes/miniforge3/envs/rasa3/lib/python3.8/site-packages/rasa/core/run.py:130> exception=TimeoutError()>
Traceback (most recent call last):
File "/Users/johnguimaraes/miniforge3/envs/rasa3/lib/python3.8/site-packages/rasa/core/run.py", line 134, in run_cmdline_io
await console.record_messages(
File "/Users/johnguimaraes/miniforge3/envs/rasa3/lib/python3.8/site-packages/rasa/core/channels/console.py", line 185, in record_messages
async for response in bot_responses:
File "/Users/johnguimaraes/miniforge3/envs/rasa3/lib/python3.8/site-packages/rasa/core/channels/console.py", line 140, in _send_message_receive_stream
async for line in resp.content:
File "/Users/johnguimaraes/miniforge3/envs/rasa3/lib/python3.8/site-packages/aiohttp/streams.py", line 35, in __anext__
rv = await self.read_func()
File "/Users/johnguimaraes/miniforge3/envs/rasa3/lib/python3.8/site-packages/aiohttp/streams.py", line 311, in readline
return await self.readuntil()
File "/Users/johnguimaraes/miniforge3/envs/rasa3/lib/python3.8/site-packages/aiohttp/streams.py", line 343, in readuntil
await self._wait("readuntil")
File "/Users/johnguimaraes/miniforge3/envs/rasa3/lib/python3.8/site-packages/aiohttp/streams.py", line 304, in _wait
await waiter
File "/Users/johnguimaraes/miniforge3/envs/rasa3/lib/python3.8/site-packages/aiohttp/helpers.py", line 721, in __exit__
raise asyncio.TimeoutError from None
asyncio.exceptions.TimeoutError
2022-04-19 17:59:27 WARNING rasa.core.processor - Circuit breaker tripped. Stopped predicting more actions for sender 'bae92dd506394cc2a6209257ea47b3a9'.