具有大型数据库集成的聊天机器人

Chatbot with large DB integration

我们想构建一个机器人,它会向用户提问,然后 将记录他们的反应。此问答将根据用户的回答智能完成。

目前我们的初始问题很少;

  1. 有很多 API 可用于创建机器人,例如 api.ai、wit.ai、botkit、IBM Watson、Microsoft Bot 框架。 Java 或 Node.Js 或 Python 从开发的角度来看哪个最好。此外,从控制数据和完整流程的角度来看。

  2. 我们想向我们的 Bot 提供来自某些 DB[RDBMS 或 NOSQL] 的问题,因为它将来会很大,api 最好。

  3. 我们想用userid存储用户对数据库的响应。

  4. 根据存储在数据库中的用户响应,我们希望对机器人提出的问题进行分析。

能否请您提出建议,是否可以使用任何一种 Bot API 来完成,并且应该首选哪一种。

谢谢, 阿米特

你这4个条件,都可以用IBM Watson搞定。

1: 使用 Conversation Service 创建聊天机器人,您可以使用 context 变量保存所有用户输入。

IBM Watson 在Python, Node JS and Java SDK 中提供了一些示例,只需单击某种编程语言即可查看示例和所有代码。

2: 此示例使用来自 Conversation Simple Node.js link 的 Cloudant DB (nosql),但您可以使用其他。

function log(input, output) {
  if ( logs ) {
    // If the logs db is set, then we want to record all input and responses
    var id = uuid.v4();
    logs.insert( {'_id': id, 'request': input, 'response': output, 'time': new Date()} );
  }
}

if ( cloudantUrl ) {
  // If logging has been enabled (as signalled by the presence of the cloudantUrl) then the
  // app developer must also specify a LOG_USER and LOG_PASS env vars.
  if ( !process.env.LOG_USER || !process.env.LOG_PASS ) {
    throw new Error( 'LOG_USER OR LOG_PASS not defined, both required to enable logging!' );
  }
  // add basic auth to the endpoints to retrieve the logs!
  var auth = basicAuth( process.env.LOG_USER, process.env.LOG_PASS );
  // If the cloudantUrl has been configured then we will want to set up a nano client
  var nano = require( 'nano' )( cloudantUrl );
  // add a new API which allows us to retrieve the logs (note this is not secure)
  nano.db.get( 'car_logs', function(err) {
    if ( err ) {
      console.error( err );
      nano.db.create( 'car_logs', function(errCreate) {
        console.error( errCreate );
        logs = nano.db.use( 'car_logs' );
      } );
    } else {
      logs = nano.db.use( 'car_logs' );
    }
  } );

3: 所有通话对话都有一些 ID,您可以使用 context 变量访问它。示例(与 IBM Watson 对话:

context.conversation_id

4: 您可以为此使用 IBM Watson 的其他服务,但我建议:AlchemyAPI 或 Discovery,取决于您真正要做什么。但是请看一下我确定他们为您提供帮助的两者。