Recastai 不是函数

Recastai is not a function

我正在按照本教程使用 Recast AI 制作 FB 聊天机器人。尝试将我的机器人与令牌连接但出现以下错误:

var client = new recastai(config.recast);
         ^
TypeError: recastai is not a function
    at Object.<anonymous> (/home/ubuntu/workspace/app/pokebot.js:5:14)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:139:18)
    at node.js:990:3

这是我的代码:

const config = require("./config.js");
const restify = require("restify");
const builder = require("botbuilder");
var recastai = require('recastai');
var client = new recastai(config.recast);

const connector = new builder.ChatConnector({
    appId: config.appId,
    appPassword: config.appPassword
});

bot.dialog("/", (session) => {
    client.textRequest(session.message.text)
    .then(res => console.log(res))
    .catch(() => session.send('I need some some sleep right now.. Talk to me 
 later!'));
});

const server = restify.createServer();
server.listen(8080);
server.post("/", connector.listen());

谁能帮帮我?谢谢!

如果我没记错的话应该是var client = new recast.Client(config.recast)

我不得不将我的 Node 版本从 6 降级到 v4.7.3,现在可以了。 var client = new recast.Client(config.recast) 对我没用,谢谢你的帮助!

我从 Recast starter repo (github.com:RecastAI/starter-NodeJS.git) 开始。

SDK是这样导入的。这个对我有用。

const recastai = require('recastai').default
const client = new recastai(process.env.REQUEST_TOKEN)
client.connect.handleMessage({ body }, response, replyMessage)