I’m using rasa. I have the following scenario:
-user open webpage with chat(bot),
-user writes with both:
example:
u: hello,
b: hello, how can I help you?
u. I need something....
b. ...
u. I want talk to human
b-> redirect to human assistant (slot)
I read about helpdesk assistant, financial assistant GitHub - RasaHQ/helpdesk-assistant I created story. I created websocket using Java + Spring boot ws://localhost:5006/socket. Still not receiving messages on 5006/socket.
import pathlib
from typing import Dict, Text, Any, List
import ruamel.yaml
from rasa_sdk import Tracker, Action
from rasa_sdk.events import EventType
from rasa_sdk.executor import CollectingDispatcher
here = pathlib.Path(__file__).parent.absolute()
handoff_config = (
ruamel.yaml.safe_load(open(f"{here}/handoff_config.yml", "r")) or {}
).get("handoff_hosts", {})
class ActionHandoffOptions(Action):
def name(self) -> Text:
return "action_handoff_options"
async def run(
self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> List[EventType]:
if not any(
[config.get("url") for bot, config in handoff_config.items()]
):
dispatcher.utter_message(template="utter_no_handoff")
else:
buttons = [
{
"title": config.get("title"),
"payload": f'/trigger_handoff{{"handoff_to":"{bot}"}}',
}
for bot, config in handoff_config.items()
]
dispatcher.utter_message(
text="I can't transfer you to a human, \
but I can transfer you to one of these bots",
buttons=buttons,
)
return []
class ActionHandoff(Action):
def name(self) -> Text:
return "action_handoff"
async def run(
self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> List[EventType]:
dispatcher.utter_message(template="utter_handoff")
handoff_to = tracker.get_slot("handoff_to")
handoff_bot = handoff_config.get(handoff_to, {})
url = handoff_bot.get("url")
if url:
if tracker.get_latest_input_channel() == "rest":
dispatcher.utter_message(
json_message={
"handoff_host": url,
"title": handoff_bot.get("title"),
}
)
else:
dispatcher.utter_message(
template="utter_wouldve_handed_off", handoffhost=url
)
else:
dispatcher.utter_message(template="utter_no_handoff")
return []
handoff_hosts:
financial_demo:
title: "Financial Assistant"
url: "ws://localhost:5006/socket"
## you can add more handoff hosts to this list e.g.
# moodbot:
# title: "MoodBot"
# url: "http://localhost:5007"


The chatroom-feature does not work anymore. It looks like too many dependencies are deprecated.