npm 安装
npm install @laiye-ai/sdk-core -S
yarn 安装
yarn add @laiye-ai/sdk-core -S
Node.js >= 8.x
"use strict";
const WuLaiClient = require("@laiye-ai/sdk-core");
// 初始化 client,pubkey 和 secret 必传
const client = new WuLaiClient({
pubkey: "your pubkey",
secret: "your secret"
});
client
.getBotResponse({
msg_body: {
text: {
content: "谢谢"
}
},
user_id: "created user_id",
extra: "extra info"
})
.then(res => {
console.log(res);
});
new WulaiClient([, options])
new WulaiClient({
pubkey: "string", // 机器人 pubkey,required
secret: "string", // 机器人 secret,required
endpoint: "string", // base url,optional
apiVersion: "v2", // 版本,optional
debug: "boolean", // 是否开启调试模式,开启后 sdk 将对所有请求进行日志输出,默认为 stdout 输出模式
options: { // optional
timeout: 6000, // 超时时间,单位ms,默认 6000ms,optional
agent: "<Http Agent>", // http or https 连接池,optional
compression: "boolean", // 服务端返回数据是否压缩,optional
maxRetry: "number", // 网络请求异常,重试次数,默认 3 次,设置 1 为取消,optional
headers: "object" // 请求头,optional
}
});
This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information.