Workflow using rasa api

I’m new to rasa trying to setup the communication between a nodejs backend and rasa.

There are some things I’m not sure about:

when a new message is sent I am using the

/conversations/${conversation._id}/messages

to post data such as:

 {
   text: values.message,
   sender: "user",
 }

then in this step I’m sure I’m afraid I’m doing something wrong. First I post another request to predict the next step:

 axios.post(`http://localhost:5005/conversations/${patient._id}/predict`)

I take the response with the highest score and send it to trigger_intent:

 .then(res=>{
 const resType = res.data.scores[0].action
 const data = {
     name: resType.slice(6)
}

I finally post the data to trigger_intent.

I assume, because I’m slicing the part utter_ from utter_greet, that I am doing something stupidly wrong in the whole process.

What would be the correct way to implement a new message - new reply flow using the api?

thanks a lot!