Giter Club home page Giter Club logo

Comments (1)

mishushakov avatar mishushakov commented on May 27, 2024

Hey,
There are no lists in dialogflow-fulfillment, try to use Actions on Google package or send custom payload (that's how i did it). Here's the code for my fulfillment:

const functions = require('firebase-functions')
const {WebhookClient, Card, Suggestion, Image, Payload} = require('dialogflow-fulfillment')

process.env.DEBUG = 'dialogflow:debug'

exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
  const agent = new WebhookClient({ request, response })
  
  function welcome(agent) {
    agent.add(`It's webhook Demo Time now!`)
    agent.add(new Card({
      title: 'Im card title',
      text: 'Im card text',
      imageUrl: "https://developers.google.com/assistant/images/badges/XPM_BADGING_GoogleAssistant_VER.png",
      buttonText: 'This is a button',
      buttonUrl: 'https://assistant.google.com/'
    }))

    agent.add(new Suggestion('Im a suggestion'))
    agent.add(new Image('https://camo.githubusercontent.com/7bee509b607c0b359b2e00d3bdfd52085002f2cf/68747470733a2f2f692e696d6775722e636f6d2f4a3861544977742e706e67'))
  }

  function actions(agent){
    agent.requestSource = agent.ACTIONS_ON_GOOGLE
    agent.add(new Payload(agent.ACTIONS_ON_GOOGLE, {
      expectUserResponse: true,
      isSsml: false,
      noInputPrompts: [],
      systemIntent: {
        intent: "actions.intent.OPTION",
        data: {
          "@type": "type.googleapis.com/google.actions.v2.OptionValueSpec",
          carouselSelect: {
            items: [
              {
                optionInfo: {
                  key: "SELECTION_KEY_ONE",
                  synonyms: [
                    "synonym 1",
                    "synonym 2",
                    "synonym 3"
                  ]
                },
                description: "This is a description of a carousel item.",
                image: {
                  url: "https://via.placeholder.com/150",
                  accessibilityText: "Image alternate text"
                },
                title: "Title of First Carousel Item"
              },
              {
                optionInfo: {
                  key: "SELECTION_KEY_TWO",
                  synonyms: [
                    "synonym 1",
                    "synonym 2",
                    "synonym 3"
                  ]
                },
                description: "This is a description of a carousel item.",
                image: {
                  url: "https://via.placeholder.com/150",
                  accessibilityText: "Image alternate text"
                },
                title: "Title of Second Carousel Item"
              },
              {
                optionInfo: {
                  key: "SELECTION_KEY_THREE",
                  synonyms: [
                    "synonym 1",
                    "synonym 2",
                    "synonym 3"
                  ]
                },
                description: "This is a description of a carousel item.",
                image: {
                  url: "https://via.placeholder.com/150",
                  accessibilityText: "Image alternate text"
                },
                title: "Title of Third Carousel Item"
              }
            ]
          }
        }
      },
      richResponse: {
        items: [
        {
          simpleResponse: {
            textToSpeech: "This is Actions",
            displayText: "Simple Response"
          }
        },
        {
          basicCard: {
            title: "This is a title",
            subtitle: "This is a subtitle",
            formattedText: "This is a basic card.",
            image: {
              url: "https://via.placeholder.com/150",
              accessibilityText: "Image alternate text"
            },
            buttons: [
              {
                title: "This is a button",
                openUrlAction: {
                  "url": "https://assistant.google.com/"
                }
              }
            ],
            imageDisplayOptions: "CROPPED"
          }
        },
        {
          mediaResponse: {
            mediaType: "AUDIO",
            mediaObjects: [
              {
                contentUrl: "https://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3",
                description: "A funky Jazz tune",
                icon: {
                  url: "https://storage.googleapis.com/automotive-media/album_art.jpg",
                  accessibilityText: "Album cover of an ccean view"
                },
                name: "Jazz in Paris"
              }
            ]
          }
        },
        {
          tableCard: {
            title: "Table Title",
            subtitle: "Table Subtitle",
            image: {
              url: "https://developers.google.com/assistant/images/badges/XPM_BADGING_GoogleAssistant_VER.png",
              accessibilityText: "Alt Text"
            },
            rows: [
              {
                cells: [
                  {
                    text: "row 1 item 1"
                  },
                  {
                    text: "row 1 item 2"
                  },
                  {
                    text: "row 1 item 3"
                  }
                ],
                dividerAfter: false
              },
              {
                cells: [
                  {
                    text: "row 2 item 1"
                  },
                  {
                    text: "row 2 item 2"
                  },
                  {
                    text: "row 2 item 3"
                  }
                ],
                dividerAfter: true
              },
              {
                cells: [
                  {
                    text: "row 2 item 1"
                  },
                  {
                    text: "row 2 item 2"
                  },
                  {
                    text: "row 2 item 3"
                  }
                ]
              }
            ],
            columnProperties: [
              {
                header: "header 1",
                horizontalAlignment: "CENTER"
              },
              {
                header: "header 2",
                horizontalAlignment: "LEADING"
              },
              {
                header: "header 3",
                horizontalAlignment: "TRAILING"
              }
            ],
            buttons: [
              {
                title: "Button Text",
                openUrlAction: {
                  url: "https://assistant.google.com"
                }
              }
            ]
          }
        },
        {
          carouselBrowse: {
            items: [
              {
                title: "Title of item 1",
                openUrlAction: {
                  url: "https://via.placeholder.com/150"
                },
                description: "Description of item 1",
                footer: "Item 1 footer",
                image: {
                  url: "https://via.placeholder.com/150",
                  accessibilityText: "Image alternate text"
                }
              },
              {
                title: "Google Assistant",
                openUrlAction: {
                  url: "https://example.com"
                },
                description: "Google Assistant on Android and iOS",
                footer: "More information about the Google Assistant",
                image: {
                  url: "https://via.placeholder.com/150",
                  accessibilityText: "Image alternate text"
                }
              }
            ]
          }
        }],
        suggestions: [{title: "Suggestion"}],
        linkOutSuggestion: {
          destinationName: "Suggestion Link",
          url: "https://assistant.google.com/"
        }
      }
    }))
  }

  let intentMap = new Map()
  intentMap.set('Webhook Demo', welcome)
  intentMap.set('Actions Demo', actions)
  agent.handleRequest(intentMap)
})

from dialogflow-web-v2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.