0

Cheers, I was testing the example gupshup bot in java following gupshup documentation: https://www.gupshup.io/developer/docs/bot-platform/guide/gupshup-bot-library-for-java

I had a problem in step 6 of the documentation. The bot responds to me when I send images, files or when the connection is established (when using the 'proxy myBotName' command) but it does not respond to me when I send it a normal message like 'hello' (this is my problem). This is the class that is generated when loading the project archetype, it is the same as the one seen in the documentation:

import io.gupshup.developer.annotations.OnEvent;
import io.gupshup.developer.annotations.OnFile;
import io.gupshup.developer.annotations.OnHttpEndPointRequest;
import io.gupshup.developer.annotations.OnImage;
import io.gupshup.developer.annotations.OnMessage;
import io.gupshup.developer.bot.context.BotContext;
import io.gupshup.developer.bot.input.EventInput;
import io.gupshup.developer.bot.input.FileInput;
import io.gupshup.developer.bot.input.HttpEndPointRequestInput;
import io.gupshup.developer.bot.input.ImageInput;
import io.gupshup.developer.bot.input.MessageInput;

/**
 * @author Abhishek Nama
 */
public class Bot {
    @OnMessage
    public void msgHandler(MessageInput input, BotContext context) {
    context.logger.log("In message handler - " + input.getMessage());
    context.sendResponse(input.getMessage());
    }

    @OnEvent
    public void eventHandler(EventInput input, BotContext context) {
    context.logger.log("In event handler - " + input.getMessage());
    context.sendResponse(input.getMessage());
    }

    @OnImage
    public void imgHandler(ImageInput input, BotContext context) {
    context.logger.log("In image handler - " + input.getMessage());
    context.sendResponse(input.getMessage());
    }

    @OnFile
    public void fileHandler(FileInput input, BotContext context) {
    context.logger.log("In file handler - " + input.getMessage());
    context.sendResponse(input.getMessage());
    }

    @OnHttpEndPointRequest
    public void httpEndPointRequestHandler(HttpEndPointRequestInput input, BotContext context) {
    context.logger.log("In http end point request handler - " + input.params.toString());
    context.sendResponse(input.params.toString());
    }
}

and I leave a capture of the chat with the bot where it is seen that it responds to the connection (detecting an event) and the image but does not respond to normal messages

capture chat bot

carlos
  • 1

1 Answers1

0

The reason is its not responding to normal message is because of the io.gupshup.developer.util.Constants class:

    public static final String TYPE_MSG = "text";
   // public static final String TYPE_MSG = "msg";

Previously it was assigned the value msg. If we change that to text it should work fine.

flyingfishcattle
  • 1,817
  • 3
  • 14
  • 25
Jyothi
  • 1