how do i connect my own api to a flow?

Hi! I’m trying to use Kore.ai to build an app. I have my own API that I’m trying to connect to, but it’s not working at all. My API is a bot; you send a text message, and then the bot performs its internal process (just like a RAG) and responds with confirmation information.

I tried creating a flow—please take a look at this picture.

This is what I’ve done

  • I created a flow in Kore.ai
  • I added a message prompt with the following message: “Please, write the action you want to perform (such as canceling an order)”
  • A script to capture the message variable that the user responds to the prompt message. From here, we have two options: a) on success, we go to a connect to API, b) on error, we go to a message prompt with the following text: “error on save var”
var userMessage = BotContext.getMessageInput();  // Captures the user's message
BotContext.setBotVariable("userMessage", userMessage);  // Stores the message in the 'userMessage' variable
  • A connect to API for when the first script succeeds
  • A prompt message for when the first script errors out

The problem is that it automatically returns this:

OLIVIA_TEST
12:38 pm, Today
Please, write the action you want to perform (such as canceling an order)
avatr img
OLIVIA_TEST
12:38 pm, Today
error on save var
avatr img
OLIVIA_TEST
12:38 pm, Today
error on save var

As you can see, the flow goes directly to the ‘error on save var.’ How can I solve this issue to make the chat work?