0

i got a problem with 1 line of code in the console of dialogflow ES.

Here's my code (it's located in the fulfillment section, inline editor):

// See https://github.com/dialogflow/dialogflow-fulfillment-nodejs
// 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');
 
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
 
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
  const agent = new WebhookClient({ request, response });
  
//test
  function menutest(agent) {
    
    const dfMessenger = document.querySelector('df-messenger');
    const payload = [
      {
      "richContent": [
        [
          {
            "type": "chips",
            "options": [
              {
                "text": "Schedule"
              },
              {
                "text": "Programmes"
              },
              {
                "text": "Inscriptionâś…"
              },
              {
                "text": "Services"
              },
              {
                "text": "Contact team"
              }
            ]
          }
        ]
      ]
      }];

    dfMessenger.renderCustomCard(payload);

  }


  // Run the proper function handler based on the matched Dialogflow intent name
  let intentMap = new Map();
  intentMap.set('menu principal-fftest', menutest);
  agent.handleRequest(intentMap);
});

The line : const dfMessenger = document.querySelector('df-messenger'); has a problem with the word "document", it is obvioulsy not defined. But in the documentation of google cloud, they use that without initialize it and i was wondering what do i have to put there instead of the word document.

this is a screenshot of the documentation : https://i.stack.imgur.com/adwzv.png

Thank you guys for helping me !

1 Answers1

0
const dfMessenger = document.querySelector('df-messenger');

This is a piece of front end code, you can not use it in the back end function.

Raj
  • 51
  • 1
  • 6