0.0.2 • Published 6 years ago

tmallbot v0.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

tmallbot

天猫精灵Node库

Travis

Installation

$ npm i tmallbot

Use with Connect/Express

let tmallbot = require('tmallbot');

let config = {};

app.use(express.query());
app.use('/tmallbot', tmallbot(config, function (req, res, next) {
  var data = req.body;
  if (data.utterance === '你好!') {
    res.reply('你也好');
  } else if (data.utterance === '我想听音乐') {
    res.reply('你想听谁的音乐?', 'ASK_INFO');
  } else {
    res.reply({
      "returnCode": 0,
      "returnErrorSolution": "",
      "returnMessage": "",
      "returnValue": {
        "reply": "Hello World!!!",
        "resultType": "RESULT",
        "actions": [],
        "properties": {},
        "executeCode": "SUCCESS",
        "msgInfo": ""
      }
    });
  }
}));