dialogflow-fulfillment-library and express, what t

2019-06-08 13:17发布

问题:

I'm trying to use the dialog-fulfillment-library with express, without firebase functions. I'm having trouble finding how to res on the agent though.

    const { WebhookClient, Card, Suggestion } = require('dialogflow-fulfillment');

    module.exports = function () {

      let self = {};

      self.create = function (req, res, next) {
        const agent = new WebhookClient({request: req, response: res});

        agent.add(new Suggestion(`Quick Reply`));
        agent.add(new Card({
            title: `Title: this is a card title`,
            imageUrl: 'https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png',
            text: `This is the body text of a card.  You can even use line\n  breaks and emoji!