【问题标题】:quickblox chat.connect is failed with 422 error - Unprocessable Entityquickblox chat.connect 失败,出现 422 错误 - 无法处理的实体
【发布时间】:2018-04-09 19:49:56
【问题描述】:

我正在使用以下代码使用聊天机器人节点 js 模块 quickbox chatbots 连接 quickblox。通过使用以下步骤

mkdir my_awesome_bot

cd my_awesome_bot

npm 初始化

npm install quickblox --save

触摸 index.js

然后打开 index.js 文件,编写如下代码:

'use strict';

const QB = require('quickblox');
const CONFIG = {
    "appId": "XX",
    "authKey": "XX",
    "authSecret": "XX",
    "botUser": {
        "id": "XX",
        "password": "XX",
        "fullname": "XX"
    }
};

// Initialise QuickBlox
QB.init(CONFIG.appId, CONFIG.authKey, CONFIG.authSecret);

// Connect to Real-Time Chat
QB.chat.connect({
    userId: CONFIG.botUser.id,
    password: CONFIG.botUser.password
  }, (chatConnectError) => {
    if (chatConnectError) {
        console.log('[QB] chat.connect is failed', JSON.stringify(chatConnectError));
        process.exit(1);
    }

    console.log('[QB] Bot is up and running');

    // Add chat messages listener
    QB.chat.onMessageListener = onMessageListener();
});

function onMessageListener(userId, msg) {

  if (msg.type == 'chat') {
    if(msg.body){
        let answerMessage = {
            type: 'chat',
            body: msg.body, // echo back original message
            extension: {
                save_to_history: 1
            }
        };

        QB.chat.send(userId, answerMessage);
    }
  }

}

process.on('exit', function () {
    console.log('Kill bot');
    QB.chat.disconnect();
}); 

但无法连接并低于结果..

chat.connect is failed {"code":422,"status":"error","detail":"Status.ERROR - An error has occurred","message":"Unprocessable Entity"}

【问题讨论】:

    标签: node.js quickblox


    【解决方案1】:

    你必须填写这个:

    const CONFIG = {
        "appId": "XX",
        "authKey": "XX",
        "authSecret": "XX",
        "botUser": {
            "id": "XX",
            "password": "XX",
            "fullname": "XX"
        }
    };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-29
      • 2014-12-24
      • 1970-01-01
      • 2018-03-01
      • 1970-01-01
      • 2023-03-22
      • 1970-01-01
      • 2021-02-17
      相关资源
      最近更新 更多