Git Product home page Git Product logo

chatopera-sample-java's Introduction

Chatopera开发者平台:809987971, 点击链接加入群聊

chatopera-sample-java

企业聊天机器人-Java端示例程序

本教程介绍如何使用Chatopera机器人开发者平台的Java SDK与机器人进行集成,阅读本教程需要20分钟时间。

获取源码

安装

创建机器人

执行程序

开发者文档

更多SDK

开源许可协议

获取源码

git clone https://github.com/chatopera/chatopera-sample-java.git

安装

cd chatopera-sample-java/app
mvn install

登录Chatopera聊天机器人平台

创建机器人

点击“立即使用”

第一登录输入“邮箱”和“密码”,点击“回车键”,完成账户创建。

创建聊天机器人

点击“创建机器人”,并填入下面各项:

项目 描述
机器人名称 小松 机器人的名字
描述 机器人示例 机器人的描述
语言 zh_CN 机器人的语言,目前支持中文(zh_CN)和英文(en_US)

【提示】其它项如兜底回复,问候语可以在创建后,设置页面修改。

下载知识库文件

下载知识库示例文件保全作业中常见问题.xlsx,保存文件名为保全作业中常见问题.xlsx

导入知识库

上传知识库文件

选择保全作业中常见问题.xlsx,这时,会显示问答对列表,点击“提交”,在进度条完成后,知识库导入成功。

测试知识库

知识库测试窗口

输入: 保全作业中常见问题

确认得到回复。

获取ClientIdSecret

集成机器人服务的方式是通过SDK,每个机器人实例需要通过ClientIdSecret初始化,完成认证和授权。打开机器人【设置】页面,拷贝ClientIdSecret

显示Secret

执行程序

在完成如上步骤后,修改程序的配置文件,使用文本编辑器打开src/main/resources/sample.properties,并设置如下内容:

chatbot.clientId=机器人的ClientId
chatbot.secret=机器人的Secret

然后执行命令

cd chatopera-sample-java/app
mvn clean compile exec:java -Dexec.mainClass="com.chatopera.bot.sample.App"

得到返回结果为

{
  "rc": 0,
  "data": [
    {
      "score": 1,
      "post": " 保全作业中常见问题",
      "id": "AWbnZqarlisN5CGJnl0M",
      "reply": " 按照条款第18条规定:“合同有效期内可申请增加保额”。因此\n隔论年金是否给付,客户均可申请办理加保,同时公司从风险防范的角度出发,又对该保全项目做了如下规定:1、   申请加保时仍在主险缴费期内;2、  加保次数不限,但需相\n  2年以上;3、  每次加保的保额不得超过申请时保险金额的20%;4、  危险保额必须符合投保规则,加保需经本公司审核同意;5、  必须征得被保人同意。"
    },
    {
      "score": 0.36363636363636365,
      "post": " 为何一次保全作业形成两个内容相同的批文?",
      "id": "AWbnZqzilisN5CGJnl0X",
      "reply": " 主要是电脑软件性能问题,需要报总公司查询出错原因。"
    }]
}

以上。

开发者文档

关于项目配置,机器人的Java接口等更多细节,请参考开发者文档

更多SDK

集成面板

Trouble Shooting

  1. mvn install抛出异常,SunCertPathBuilderException
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

解决方案

  1. 运行程序,得到如下返回结果
clientId foo
secret bar
{"rc":1,"error":"invalid appId."}

这是因为clientIdsecret配置不正确。请确保该值是写入src/main/resources/sample.properties的有效的聊天机器人配置。

开源许可协议

Copyright (2018) 北京华夏春松科技有限公司

Apache License Version 2.0

Copyright 2017-2018, 北京华夏春松科技有限公司. All rights reserved. This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited.

chatoper banner

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.