Sending Custom Payload from inline editor

100 views
Skip to first unread message

dialog flow

unread,
Sep 21, 2020, 3:20:28 PM9/21/20
to Dialogflow Essentials Edition users
Hi,
I'm trying to send custom payload from inline editor, to be displayed at DialogFlow Messenger integration. Here's my code:

// for Dialogflow fulfillment library docs, samples, and to report issues
'use strict';
 
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
const {Payload} = require('dialogflow-fulfillment');
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
 
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
  const agent = new WebhookClient({ request, response });
  console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
  console.log('Dialogflow Request body: ' + JSON.stringify(request.body));

 function test_accordion  (agent) {
  const payload ={"messages": [{"richContent": [
                        [
                          {
                            "text": "Text to be displayed at accordion",
                            "type": "accordion",
                            "title": "Detalles:",
                            "image": {
                              "src": {
                              }
                            }
                          }
                        ]
                      ]
    }]};

agent.add(new Payload(agent.PLATFORM_UNSPECIFIED , payload, {rawPayload: true, sendAsMessage: true}));
 }
  
  let intentMap = new Map();
  intentMap.set('test_accordion',  test_accordion);
  agent.handleRequest(intentMap);
});


And here is my packages file:

{
  "name": "dialogflowFirebaseFulfillment",
  "description": "This is the default fulfillment for a Dialogflow agents using Cloud Functions for Firebase",
  "version": "0.0.1",
  "private": true,
  "license": "Apache Version 2.0",
  "author": "Google Inc.",
  "engines": {
    "node": "10"
  },
  "scripts": {
    "start": "firebase serve --only functions:dialogflowFirebaseFulfillment",
    "deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment"
  },
  "dependencies": {
    "actions-on-google": "^2.2.0",
    "firebase-admin": "^5.13.1",
    "firebase-functions": "^2.0.2",
    "dialogflow": "^0.6.0",
    "dialogflow-fulfillment": "^0.5.0"
  }
}

I'm not able to make this work. I've been searching the net for hours and I can't find any solution.
Any help would be really appreciated.

Thanks in advance!

Jun Lu

unread,
Oct 15, 2020, 5:28:13 PM10/15/20
to Dialogflow Essentials Edition users
Hey, 

It looks like there is a similar reported issue at [1] that you can take a look to try the suggestions and followup on the issue for your situation as Google Groups is meant for general product discussions only and not for reporting issues. 

Reply all
Reply to author
Forward
0 new messages