How to make the bot utter a response using Java

Hi, I am trying to create a rasa bot using Java in Springboot application. One of the use cases is that if a user is able to log in successfully by giving a command like “login:username password” to the rasa chatbot then the bot should respond “Login successful” else “Invalid credentials”. To verify the credentials, I am calling an API in another service that returns if the login is successful or not. How do I make the bot respond according to the situation? Is there any API that I can use to make the bot utter a particular response? As far as I can see, this API has been deprecated. Do we have an alternative? Rasa & Rasa Pro Documentation

Eg code

        if(feignResponse.getStatusCode().value() == 200) {
                rasaClient.makeBotUtterance("Login successful");
            else {
                rasaClient.makeBotUtterance("Invalid credentials");

Which Rasa http api can I use inside makeBotUtterance?

You should try the REST endpoint and invoke a slash intent (/myintent) which executes the action and response you want.

You could also call the action server directly as described here.

1 Like

Hi @stephens , thank you for the response. For the above API, do I still need to create a custom action in the file and then use the above API to call that action from my Spring boot application?

I have one more question. Currently, I am sending a message to rasa like “login:username password” where username is my username and password is my password using API : http://localhost:5005/webhooks/rest/webhook and then using this API: getConversationTracker to get back the tracker for the message “login:username password” so that I can do further processing on the basis of intents that it was classified into and call any specific action. Is this the best way to do so or is there any better way?

I thought you were wanted to create a Rasa action server.

Normally, you would handle the login in your front end service and then pass a JWT token to the Rasa bot if it needs to invoke custom actions that need authentication.

Hi stephens,

No, I don’t want to create my own action server. I just want to understand if there’s a way to call actions/functions in file from Java and if that will be the same as calling those actions via rasa. I hope that makes some sense. I am not asking this specifically for just login but for any use case.

You’ll find the API spec for the action server here