New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@chatopera/sdk

Package Overview
Dependencies
Maintainers
3
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chatopera/sdk

低代码或无代码方式定制智能对话机器人,https://bot.chatopera.com

  • 2.5.9
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
96
increased by433.33%
Maintainers
3
Weekly downloads
 
Created
Source

Chatopera Node.js SDK


低代码或无代码方式定制智能对话机器人!

Chatopera 提供聊天机器人开发者平台,Chatopera SDK 用于在 Node.js 应用中集成聊天机器人服务

安装


npm install @chatopera/sdk --save

使用文档

快速开始,类接口定义和实例化文档等,参考 文档中心

https://docs.chatopera.com/products/chatbot-platform/integration/index.html

命令行工具

Chatopera Node.js SDK 包括一些常用的命令,辅助开发者实现对话机器人。

获得帮助

打印可用命令。

bot --help

配置

优先级: 命令行参数 > .env文件 > 环境变量

映射配置项命令行参数环境变量备注
clientId, 机器人 ID-c, --clientid [value]BOT_CLIENT_ID无默认值,必填
secret, 机器人密钥-u, --username [value]BOT_CLIENT_SECRET无默认值,必填
provider, Chatopera 机器人平台地址-p, --provider [value]BOT_PROVIDER默认值,https://bot.chatopera.com

其中, .env 文件例子如:

BOT_CLIENT_ID=xxx
BOT_CLIENT_SECRET=xxx
BOT_PROVIDER=https://bot.chatopera.com

.env 文件存储的也是环境变量值。bot 命令会沿当前执行命令的路径(pwd),寻找 .env 文件。

比如,在 /Users/chatopera/chatopera-nodejs-sdk下执行 bot 命令,那么,.env文件按照以下顺序进行查找,一旦查找到就加载为配置,并退出查找。

/Users/chatopera/chatopera-nodejs-sdk/.env
/Users/chatopera/.env
/Users/.env
/.env

连接聊天机器人

在命令行终端连接 BOT 并进行对话。

Usage: connect [options]

Options:
  -c, --clientid [value]      ClientId of the bot
  -s, --clientsecret [value]  Client Secret of the bot, optional, default null
  -u, --username [value]      Username to chat with bot, default: commandline
  -p, --provider [value]      Chatopera Bot Service URL, optional, default https://bot.chatopera.com
  -fb, --faq-best [value]     FAQ best reply threshold, optional, default 0.8
  -fs, --faq-sugg [value]     FAQ suggest reply threshold, optional, default 0.6

其中,clientidclientsecret从每个机器人的设置页面获取,username代表用户名,是一个不含空格或特殊符号的字符串,每个用户的唯一标识,providerChatopera 机器人平台地址,默认为 Chatopera 云服务

示例:

bot connect -c xxx -s xxx -u zhangsan

在对话中,可以使用快捷方式,快速输入。

快捷方式Mac OSX / Windows
回溯历史↑ 上箭头;↓ 下箭头
打印历史Shift + → 右箭头
使用索引输入历史,索引根据打印历史获得输入索引,然后 Ctrl + Shift + Shift + → 右箭头

上传多轮对话脚本

在命令行终端发布脚本文件到多轮对话中。

Usage: deploy [options]

Options:
  -c, --clientid [value]      ClientId of the bot
  -s, --clientsecret [value]  Client Secret of the bot, optional, default null.
  -p, --provider [value]      Chatopera Bot Service URL, optional, default https://bot.chatopera.com
  -b, --botarchive <value>    Conversation Bundle, *required.
  -h, --help                  display help for command

其中 botarchive机器人的话题文件目录xx.c66 文件,支持相对路径绝对路径

标准目录结构:

botarchive
├── index.json
├── plugin.js
└── zh_CN.greeting.ms

其中,index.json描述机器人多轮对话属性:

{
    "name": "大白",
    "primaryLanguage": "zh_CN",
    "version": "0.5.0",
    "conversations": [
        {
            "name": "greeting",
            "enabled": true
        }
    ],
    "config": // 环境变量Key-Value
    {
    }
}

plugin.js函数,参考说明文档

快速开始参考示例程序活动通知

打印聊天机器人日志

方便调试多轮对话脚本,实时跟踪服务器端日志,排查问题。

Usage: bot trace [options]

Options:
  -c, --clientid [value]      ClientId of the bot
  -s, --clientsecret [value]  Client Secret of the bot, optional, default null
  -p, --provider [value]      Chatopera Bot Service URL, optional, default https://bot.chatopera.com
  -l, --log-level [value]     Log level to follow, optional, [DEBUG|INFO|WARN|ERROR], default DEBUG
  -h, --help                  display help for command

语音识别

Usage: bot asr [options]

Options:
  -c, --clientid [value]      ClientId of the bot
  -u, --username [value]      Username to chat with bot
  -s, --clientsecret [value]  Client Secret of the bot, optional, default null
  -p, --provider [value]      Chatopera Bot Service URL, optional, default https://bot.chatopera.com
  -f, --file <value>          Target file to recognize, *required.
  -h, --help                  display help for command

示例:

bot asr -c xxx \
     -s xxxx \
     -u nodetest \
     -f ./test/fixtures/001.wav
{
 "rc": 0,
 "data": {
  "duration": 6250,
  "predicts": [
   {
    "confidence": 0.960783,
    "text": "上海 浦东机场 入境 房 输入 全 闭 环 管理"
   },
   {
    "confidence": 0.960767,
    "text": "上海 浦东机场 入境 防 输入 全 闭 环 管理"
   },
   {
    "confidence": 0.960736,
    "text": "上海 浦东机场 入境 坊 输入 全 闭 环 管理"
   }
  ]
 }
}

Support

技术支持: https://docs.chatopera.com/products/chatbot-platform/support.html

Contribute

打印调试日志

export DEBUG=chatopera*
cp sample.env .env # edit .env
npm run test

License

Apache 2.0

Copyright 2018-2021, 北京华夏春松科技有限公司. 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

Keywords

FAQs

Package last updated on 08 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc