Class Chatbot

java.lang.Object
com.chatopera.bot.sdk.Chatbot

public class Chatbot extends Object
Chatopera聊天机器人
  • Constructor Summary

    Constructors
    Constructor
    Description
    Chatbot(String clientId, String clientSecret)
    创建聊天机器人实例,登录 https://bot.chatopera.com 获得 clientId 和 clientSecret
    Chatbot(String clientId, String clientSecret, String baseUrl)
    创建聊天机器人实例,登录 https://bot.chatopera.com 获得 clientId 和 clientSecret
  • Method Summary

    Modifier and Type
    Method
    Description
    org.json.JSONObject
    chats(String userId, int page, int pageSize)
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    command(String method, String path)
    核心访问接口
    command(String method, String path, org.json.JSONObject payload)
    核心访问接口
    org.json.JSONObject
    conversation(String userId, String textMessage)
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    org.json.JSONObject
    conversation(String userId, String textMessage, double faqBestReplyThreshold, double faqSuggReplyThreshold)
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    org.json.JSONObject
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    boolean
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    org.json.JSONObject
    faq(String userId, String textMessage)
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    org.json.JSONObject
    faq(String userId, String textMessage, double faqBestReplyThreshold, double faqSuggReplyThreshold)
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    org.json.JSONObject
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    org.json.JSONObject
    faqcategorycreate(String label, String parentId)
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    org.json.JSONObject
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    org.json.JSONObject
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    org.json.JSONObject
    faqcreate(String post, String reply, boolean enabled, List<String> categories)
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    org.json.JSONObject
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    org.json.JSONObject
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    org.json.JSONObject
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    org.json.JSONObject
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    org.json.JSONObject
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    org.json.JSONObject
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    org.json.JSONObject
    faqextenddelete(String id, String extendId)
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    org.json.JSONObject
    faqextendupdate(String id, String extendId, String post)
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    org.json.JSONObject
    faqlist(String query, String category, int page, int pageSize)
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    org.json.JSONObject
    faqupdate(String id, String post, String reply, boolean enabled, List<String> categories)
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
     
     
    int
     
     
    org.json.JSONObject
    intent(String sessionId, String userId, String textMessage)
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    org.json.JSONObject
    intentsession(String sessionId)
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    org.json.JSONObject
    intentsession(String userId, String channel)
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    boolean
    ismute(String userId)
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    void
    mute(String userId)
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    void
    unmute(String userId)
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10
    org.json.JSONObject
    users(int page, int pageSize)
    Deprecated.
    use `Chatbot#command` API instead, removed in 2020-10

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • getSchema

      public String getSchema()
    • getHostname

      public String getHostname()
    • getPort

      public int getPort()
    • getBaseUrl

      public String getBaseUrl()
    • command

      public Response command(String method, String path, org.json.JSONObject payload) throws ChatbotException
      核心访问接口
      Parameters:
      method - PUT, POST, GET, DELETE, etc.
      path - /faq/xxx
      payload - JSONObject body
      Returns:
      Throws:
      ChatbotException
    • command

      public Response command(String method, String path) throws ChatbotException
      核心访问接口
      Parameters:
      method - PUT, POST, etc.
      path - /faq/xxxx
      Returns:
      Throws:
      ChatbotException
    • details

      public org.json.JSONObject details() throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      获取聊天机器人详情
      Returns:
      JSONObject
      Throws:
      ChatbotException
    • exists

      public boolean exists() throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      通过ChatbotID检查一个聊天机器人是否存在
      Returns:
      Throws:
      ChatbotException
    • conversation

      public org.json.JSONObject conversation(String userId, String textMessage) throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      和机器人对话
      Parameters:
      userId - 用户唯一标识
      textMessage - 文字消息
      Returns:
      Throws:
      ChatbotException
    • conversation

      public org.json.JSONObject conversation(String userId, String textMessage, double faqBestReplyThreshold, double faqSuggReplyThreshold) throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      和机器人对话
      Parameters:
      userId -
      textMessage -
      faqBestReplyThreshold -
      faqSuggReplyThreshold -
      Returns:
      Throws:
      ChatbotException
    • faq

      public org.json.JSONObject faq(String userId, String textMessage) throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      检索知识库
      Parameters:
      userId - 用户唯一标识
      textMessage - 文字消息
      Returns:
      Throws:
      ChatbotException
    • faq

      public org.json.JSONObject faq(String userId, String textMessage, double faqBestReplyThreshold, double faqSuggReplyThreshold) throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      检索知识库
      Parameters:
      userId -
      textMessage -
      faqBestReplyThreshold -
      faqSuggReplyThreshold -
      Returns:
      Throws:
      ChatbotException
    • faqlist

      public org.json.JSONObject faqlist(String query, String category, int page, int pageSize) throws ChatbotException, UnsupportedEncodingException, UnsupportedEncodingException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      查询知识库列表
      Parameters:
      query - 查询语句
      category - 分类,使用父分类会将子分类的内容同时检索出来
      page - 页码,默认为1
      pageSize - 每页数据条数,默认 30
      Returns:
      Throws:
      ChatbotException
      UnsupportedEncodingException
    • faqcreate

      public org.json.JSONObject faqcreate(String post, String reply, boolean enabled, List<String> categories) throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      创建知识库的问答对
      Parameters:
      post - 标准问的问题
      reply - 标准问的回答
      enabled - 是否启用,默认为 false
      categories - 类别,是分类标识的数组,并不支持分类名称,必须使用分类标识
      Returns:
      Throws:
      ChatbotException
    • faqdetail

      public org.json.JSONObject faqdetail(String id) throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      获得知识库一条记录的详情
      Parameters:
      id - 问答对唯一标识
      Returns:
      Throws:
      ChatbotException
    • faqupdate

      public org.json.JSONObject faqupdate(String id, String post, String reply, boolean enabled, List<String> categories) throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      更新知识库一条记录
      Parameters:
      id - 问答对唯一标识
      post - 问题
      reply - 回复
      enabled - 是否启用
      categories - 类别,是分类标识的数组,并不支持分类名称,必须使用分类标识
      Returns:
      JSONObject
      Throws:
      ChatbotException
    • faqdisable

      public org.json.JSONObject faqdisable(String id) throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      禁用知识库里一个问答对
      Parameters:
      id - 问答对唯一标识
      Returns:
      JSONObject
      Throws:
      ChatbotException
    • faqenable

      public org.json.JSONObject faqenable(String id) throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      启用知识库里一个问答对
      Parameters:
      id - 问答对唯一标识
      Returns:
      JSONObject
      Throws:
      ChatbotException
    • faqdelete

      public org.json.JSONObject faqdelete(String id) throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      删除知识库的一条记录,标准问和扩展问都被物理性删除
      Parameters:
      id - 问答对唯一标识
      Returns:
      Throws:
      ChatbotException
    • faqextend

      public org.json.JSONObject faqextend(String id) throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      查询知识库标准问的扩展问列表
      Parameters:
      id - 问答对唯一标识
      Returns:
      Throws:
      ChatbotException
    • faqextendcreate

      public org.json.JSONObject faqextendcreate(String id, String post) throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      创建知识库标准问的扩展问
      Parameters:
      id - 问答对唯一标识
      post - 扩展问
      Returns:
      JSONObject
      Throws:
      ChatbotException
    • faqextendupdate

      public org.json.JSONObject faqextendupdate(String id, String extendId, String post) throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      更新知识库标准问的扩展问
      Parameters:
      id - 问答对唯一标识
      post - 扩展问
      Returns:
      JSONObject
      Throws:
      ChatbotException
    • faqextenddelete

      public org.json.JSONObject faqextenddelete(String id, String extendId) throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      删除知识库标准问的扩展问
      Parameters:
      id - 问答对唯一标识
      extendId - 扩展问唯一标识
      Returns:
      Throws:
      ChatbotException
    • faqcategories

      public org.json.JSONObject faqcategories() throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      获得知识库分类信息
      Returns:
      Throws:
      ChatbotException
    • faqcategorycreate

      public org.json.JSONObject faqcategorycreate(String label, String parentId) throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      创建知识库分类
      Parameters:
      label - 分类名称
      parentId - 父节点的标识, 即上级分类的标识
      Returns:
      Throws:
      ChatbotException
    • faqcategoryupdate

      public org.json.JSONObject faqcategoryupdate(String value, String label) throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      更新知识库分类
      Parameters:
      value - 知识库分类的标识
      label - 知识库分类名称
      Returns:
      Throws:
      ChatbotException
    • faqcategorydelete

      public org.json.JSONObject faqcategorydelete(String value) throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      删除知识库分类
      Parameters:
      value - 知识库分类的标识
      Returns:
      Throws:
      ChatbotException
    • intentsession

      public org.json.JSONObject intentsession(String userId, String channel) throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      创建意图识别会话 此处支持请求生产版本
      Parameters:
      userId - 用户唯一标识
      channel - 渠道标识,代表不同渠道的唯一标识,比如QQ,公众号,开发者自定义
      Returns:
      Throws:
      ChatbotException
    • intentsession

      public org.json.JSONObject intentsession(String sessionId) throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      获得指定意图识别会话ID的详情
      Parameters:
      sessionId -
      Returns:
      Throws:
      ChatbotException
    • intent

      public org.json.JSONObject intent(String sessionId, String userId, String textMessage) throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      进行意图识别对话
      Parameters:
      sessionId - 会话ID
      userId - 用户唯一标识,需要和创建会话时保持一致,否则会话会错乱
      textMessage - 消息文本内容
      Returns:
      Throws:
      ChatbotException
    • users

      public org.json.JSONObject users(int page, int pageSize) throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      获得聊天机器人用户列表
      Parameters:
      page - 页面
      pageSize - 页面大小
      Returns:
      Throws:
      ChatbotException
    • chats

      public org.json.JSONObject chats(String userId, int page, int pageSize) throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      根据用户ID获得聊天历史
      Parameters:
      userId - 用户唯一标识
      page - 页面
      pageSize - 页面大小
      Returns:
      Throws:
      ChatbotException
    • mute

      public void mute(String userId) throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      根据用户ID屏蔽一个用户
      Parameters:
      userId - 用户唯一标识
      Throws:
      ChatbotException
    • unmute

      public void unmute(String userId) throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      根据用户ID取消屏蔽
      Parameters:
      userId - 用户唯一标识
      Throws:
      ChatbotException
    • ismute

      public boolean ismute(String userId) throws ChatbotException
      Deprecated.
      use `Chatbot#command` API instead, removed in 2020-10
      查看一个用户是否被屏蔽
      Parameters:
      userId - 用户唯一标识
      Returns:
      Throws:
      ChatbotException