【问题标题】:My gupshup Bot is not responding to normal text messages, does anyone know why?我的 gupshup Bot 没有回复正常的短信,有人知道为什么吗?
【发布时间】:2022-07-21 22:14:21
【问题描述】:

干杯,我正在按照 gupshup 文档在 java 中测试示例 gupshup bot:https://www.gupshup.io/developer/docs/bot-platform/guide/gupshup-bot-library-for-java

我在文档的第 6 步中遇到了问题。当我发送图像、文件或建立连接时(使用“proxy myBotName”命令时),机器人会响应我,但当我向它发送像“你好”这样的普通消息时,它不会响应我(这个是我的问题)。 这是加载项目原型时生成的类,与文档中看到的相同:

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());
    }
}

我留下了与机器人的聊天记录,可以看到它响应连接(检测事件)和图像,但不响应正常消息

capture chat bot

【问题讨论】:

    标签: java gupshup


    【解决方案1】:

    原因是 io.gupshup.developer.util.Constants 类,

    public static final String TYPE_MSG = "text";
    

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

    以前是 msg ,如果我们改成 "text" 就可以了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-13
      • 1970-01-01
      • 2020-08-04
      • 1970-01-01
      • 1970-01-01
      • 2017-01-02
      • 2019-07-30
      • 1970-01-01
      相关资源
      最近更新 更多