So I just started a server with rasa run
. I want to mimic behavior just like in Rasa Shell. However, reading through the Rasa HTTP API, it seems that I must:
- Add a message to a tracker Add Conversation Message
- From that message, add the intent Trigger Conversation Intent
However, having these two API calls seems like it is unnecessarily increasing our latency by a lot. Is there a smoother way of interacting with the HTTP API?
As a reference, here is my code:
conversation_id = input("Conversation ID: ")
url = f"my-server:5005/conversations/{conversation_id}/"
messages_url = url + "messages"
intents_url = url + "trigger_intent"
while True:
message = input("Input: ")
payload = {
"text": message,
"sender": "user",
}
messages_response = requests.post(messages_url, json=payload)
messages_data = json.loads(messages_response.text)
intent_name = messages_data['latest_message']['intent']['name']
payload = {
'name': intent_name,
}
intents_response = requests.post(intents_url, json=payload)
intents_data = json.loads(intents_response.text)
print (intents_data["messages"][0]["text"])
Also, how do you delete a conversation (and free up a conversation_id
and the memory)?
Thank you.