Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bottender-chatbase

Package Overview
Dependencies
Maintainers
3
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bottender-chatbase - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

koa.js

4

CHANGELOG.md

@@ -0,3 +1,7 @@

# 0.2.0 / 2017-12-07
* [new] Support koa middleware
# 0.1.0 / 2017-12-05
* [new] Support express middleware

27

lib/express.js

@@ -12,2 +12,6 @@ 'use strict';

var _setInterceptors = require('./setInterceptors');
var _setInterceptors2 = _interopRequireDefault(_setInterceptors);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -18,23 +22,10 @@

const { client } = bot.connector;
const axios = client.axios;
(0, _setInterceptors2.default)(bot, chatbase);
// Add a response interceptor
axios.interceptors.response.use(response => {
const { config } = response;
if (/graph\.facebook\.com.*\/me\/messages/.test(config.url)) {
const { recipient: { id }, message: { text } } = JSON.parse(config.data);
chatbase.newMessage().setAsTypeAgent().setUserId(id).setTimestamp(Date.now().toString()).setMessage(text).send().catch(e => console.error(e));
}
return response;
});
return (req, res, next) => {
const {
sender: { id },
message: { text }
} = req.body.entry[0].messaging[0];
req.body.entry.forEach(entry => {
const { sender: { id }, message: { text } } = entry.messaging[0];
chatbase.newMessage().setAsTypeUser().setUserId(id).setTimestamp(Date.now().toString()).setMessage(text).send().catch(e => console.error(e));
chatbase.newMessage().setAsTypeUser().setUserId(id).setTimestamp(Date.now().toString()).setMessage(text).send().catch(console.error);
});

@@ -41,0 +32,0 @@ next();

{
"name": "bottender-chatbase",
"version": "0.1.0",
"description": "Middleware for using Chatbase with Bottender.",
"main": "lib/index.js",
"keywords": [
"bottender",
"chatbase"
],
"license": "MIT",
"engines": {
"node": ">=7.6"
},
"repository": {

@@ -18,6 +9,8 @@ "type": "git",

},
"version": "0.2.0",
"main": "lib/index.js",
"files": [
"lib",
"express.js",
"koa.js",
"lib",
"micro.js",

@@ -29,6 +22,7 @@ "restify.js"

"clean": "rimraf lib",
"precommit": "lint-staged",
"lint": "eslint src",
"lint:fix": "npm run lint -- --fix",
"lint:staged": "lint-staged",
"precommit": "lint-staged",
"prepublish": "npm run build",
"test": "npm run lint:fix && npm run testonly",

@@ -38,5 +32,7 @@ "testonly": "jest",

"testonly:watch": "jest --watch",
"preversion": "npm test",
"prepublish": "npm run build"
"preversion": "npm test"
},
"dependencies": {
"@google/chatbase": "^1.0.0"
},
"devDependencies": {

@@ -58,4 +54,12 @@ "babel-cli": "^6.26.0",

"prettier": "^1.8.2",
"prettier-package-json": "^1.4.0",
"rimraf": "^2.6.2"
},
"keywords": [
"bottender",
"chatbase"
],
"engines": {
"node": ">=7.6"
},
"jest": {

@@ -68,2 +72,6 @@ "testEnvironment": "node",

"lint-staged": {
"package.json": [
"prettier-package-json --write",
"git add"
],
"*.js": [

@@ -73,6 +81,3 @@ "eslint --fix",

]
},
"dependencies": {
"@google/chatbase": "^1.0.0"
}
}

@@ -45,2 +45,21 @@ # Bottender Chatbase

## Server
Supported server:
1. express
2. koa
### [express](https://github.com/expressjs/express)
```js
const chatbaseMiddleware = require('bottender-chatbase/express');
```
### [koa](https://github.com/koajs/koa)
```js
const chatbaseMiddleware = require('bottender-chatbase/koa');
```
## Contributing

@@ -47,0 +66,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc