new HSBOT(topicList, topics)

A collection of HSBOT functions for talk with bot and analyze data. Supply template and your bot is ready.

Source:
Parameters:
Name Type Description
topicList Array

A collection of JSON object.

topics Array

A collection of JSON object.

Example
var topicList = require('../db/data/topicList.json'); // Your file path as per defined template.
var topics = require('../db/data/topics.json'); // Your file path as per defined template.
const HSBot = require('hsbot');
const hsBot = new HSBot(topicList, topics);


transformAndReply(userId, userName, pattern) → {callback}

This method is responsible to reply.

Source:
Parameters:
Name Type Description
userId String

User's ID.

userName String

User name.

pattern String

A human text or user query.

Returns:
Type:
callback

error-first callback, bot result based on user query.

Example
var topicList = require('../db/data/topicList.json'); // Your file path as per defined template.
var topics = require('../db/data/topics.json'); // Your file path as per defined template.
const HSBot = require('hsbot');
const hsBot = new HSBot(topicList, topics);
var userId = "aQ11zyTr4u7I";
var userName;

hsBot.transformAndReply(userId, userName, human_text, function(err, data){
  console.log("HSBot:", data);
});


getUserAnalysis(userId) → {JSON}

This method will generate user analysis based on him activities.

Source:
Parameters:
Name Type Description
userId String

User's ID.

Returns:
Type:
JSON

Analysis of aggregate of user activities

Example
var topicList = require('../db/data/topicList.json'); // Your file path as per defined template.
var topics = require('../db/data/topics.json'); // Your file path as per defined template.
const HSBot = require('hsbot');
const hsBot = new HSBot(topicList, topics);
var userId = "aQ11zyTr4u7I";

hsBot.getUserAnalysis(userId);
Output
{
  "timeSpent": "100261",
  "frequentBotText": "Thank you for contacting us. you can call me by typing @hs anytime for further help.",
  "frequentUserText": "@hs"
}


getChatHistory(userId) → {JSON}

This method is responsible to get user details based on userId.

Source:
Parameters:
Name Type Description
userId String

User's ID.

Returns:
Type:
JSON

user object.

Example
var topicList = require('../db/data/topicList.json'); // Your file path as per defined template.
var topics = require('../db/data/topics.json'); // Your file path as per defined template.
const HSBot = require('hsbot');
const hsBot = new HSBot(topicList, topics);
var userId = "aQ11zyTr4u7I";

hsBot.getChatHistory(userId);
Output
{
  userName: "Hardik Shah",
  userId: "aQ11zyTr4u7I",
  loggedIn: 1235637,
  activities: [
    {
      pattern: null,
      preQ: "What is your name?",
      ut: 12345688,
      topic: "call1"
    },
    {
      pattern: "Hardik Shah",
      preQ: "Welcome Hardik Shah, How can I assist you?",
      ut: 12345999,
      topic: "call1"
    }
  ]
}


getAllUserChatHistory() → {Array}

This method is responsible to get all user details.

Source:
Returns:
Type:
Array

Array of all user details.

Example
var topicList = require('../db/data/topicList.json'); // Your file path as per defined template.
var topics = require('../db/data/topics.json'); // Your file path as per defined template.
const HSBot = require('hsbot');
const hsBot = new HSBot(topicList, topics);
var userId = "aQ11zyTr4u7I";

hsBot.getChatHistory(userId);
Output
[
  {
    userName: "Hardik Shah",
    userId: "aQ11zyTr4u7I",
    loggedIn: 1235637,
    activities: [
      {
        pattern: null,
        preQ: "What is your name?",
        ut: 12345688,
        topic: "call1"
      },
      {
        pattern: "Hardik Shah",
        preQ: "Welcome Hardik Shah, How can I assist you?",
        ut: 12345999,
        topic: "call1"
      }
    ]
  },
  {
    userName: "Kartik Shah",
    userId: "aQ11zyTr4u22",
    loggedIn: 1235637,
    activities: [
      {
        pattern: null,
        preQ: "What is your name?",
        ut: 12345688,
        topic: "call1"
      },
      {
        pattern: "Kartik Shah",
        preQ: "Welcome Kartik Shah, How can I assist you?",
        ut: 12345999,
        topic: "call1"
      }
    ]
  }
]