How get user input from the user if conversation is paused? How Can I stop bot and send messages from user to my rest api or socket?
def name(self):
return "action_talk_to_human"
def run(self, dispatcher, tracker, domain):
response = "Reaching out to a human agent [{}]...".format(tracker.sender_id)
dispatcher.utter_message(response)
"""
seems like rasa will stop listening once conversation
is paused, which means no actions are attempted, therefore
preventing triggering ConversationResumed() in a straightforward way.
"""
ConversationPaused()
message = ""
while message != "/unpause":
last_msg = tracker.latest_message.get('text');
url = "http://localhost:8001/api/test/from/rasa/{}/{}".format(tracker.sender_id, last_msg)
req = requests.get(url)
resp = json.loads(req.text)
if "error" in resp:
raise Exception("Error fetching message: " + repr(resp["error"]))
message = resp["message"]
if message != "/unpause":
dispatcher.utter_message("Human agent: {}".format(message))
ConversationResumed()