dialogflow-fulfillment-v2-middleware

1.0.0 • Public • Published

Dialogflow Fulfillment V2 Middleware

Actions on Google NodeJS is only support Dialogflow V1 API. But Dialogflow Enterprise Edition only use V2 API.

This middleware convert V1/V2 json format both request and response if use V2 API on dialogflow.

Usage

const { DialogflowApp } = require('actions-on-google');
const connect = require('connect');
const dialogflowV2 = require('./dialogflow-fulfillment-v2-middleware');
 
const actionMap = new Map();
actionMap.set('input.welcome', welcome);
 
const app = connect();
app.use(dialogflowV2.v2to1());
app.use((req, res) => {
   const dialogflow = new DialogflowApp({request: req, response: res});
   dialogflow.handleRequest(actionMap);
});
 
app(request, dialogflowV2.v1to2(response));

connect is convinience usefull middleware layer without server.

TODO

  • Unit Test
  • CI

Package Sidebar

Install

npm i dialogflow-fulfillment-v2-middleware

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • sizuhiko