bottender-analytics
v0.5.0
Published
Analytics for Bottender
Downloads
7
Readme
bottender-analytics
CLI Mode
Install
Install globally
$ npm install -g bottender-analytics
Usage
$ bottender-analytics ./config.json
alias
$ ba ./config.json
Module
Install
$ npm install --save-dev bottender-analytics
Generic Message
{
id: STRING (uuid)
direction: STRING ('incoming' | 'outgoing')
type: STRING ('text' | 'quick_reply' | 'button' | ...)
platform: STRING ('messenger' | 'line' | 'universal' | ...)
text: STRING
postback: STRING
context: {
trigger: JSON
... extendibleFields
},
raw: JSON
... extendibleFields
}
Sample Config
{
"platform": "messenger",
"startDate": "2018-07-01",
"endDate": "2018-07-07",
"mongoURL": "mongodb://localhost:27017/my-bot",
"collectionName": {
"session": "sessions",
"log": "logs",
"unknown": "unknown"
},
"reportSetting": {
"format": "EXCEL",
"statistics": {
"fileName": "statistics",
"conversationSplitMinutes": 5,
"switchToHumanPayloads": {
"postback": ["__SWITCH_TO_HUMAN__"],
"quick_reply": ["__SWITCH_TO_HUMAN__", "__INTENT_轉接專人__"]
}
},
"dayHist": {
"fileName": "dayHist",
"columns": ["logs", "users", "conversations", "switchToHumans"],
"periodDays": 1
},
"minuteHist": {
"fileName": "minuteHist",
"columns": ["logs", "users", "conversations", "switchToHumans"],
"periodMinutes": 15
},
"topUsers": { "fileName": "topUsers", "numOfUsers": 20 },
"postback": { "fileName": "postback" },
"quickreply": { "fileName": "quickreply" },
"unknown": { "fileName": "unknown" },
"allUsers": { "fileName": "user" },
"userLogs": { "fileName": "userLog" }
},
"pageID": "000",
"exceptUsers": [
{
"name": "Calvin Lin",
"id": "123",
"remark": "優拓測試人員"
},
{
"name": "someone",
"id": "456",
"remark": "這個人來亂的"
}
],
"actionsMap": {
"主選單": "12345",
"使用教學": "54321"
}
}
SDK
const logger = new AnalyticsLogger({ knexClient, monkClient, logDbName });
logger.insertLog({ id, platform, platformChannelId, direction, event, triggers })
triggers:
{
intentId: "NLU INTENT ID",
intentName: "NLU INTENT NAME",
entityId: "NLU ENTITY ID",
entityName: "NLU ENTITY NAME",
regexp: "^REGEXP\$/g",
keyword: "KEYWORD",
displayName: "ACTION NAME WHEN TRIGGERED BY PAYLOAD OR UNKNOWN",
actionId: "ACTION ID WHEN TRIGGERED BY PAYLOAD OR UNKNOWN"
}
event:
rawEvent
direction:
- incoming
- outgoing