### Dialogflow Card Response Implementation (Node.js) Source: https://wiki.aisensy.com/en/articles/11489891-how-to-setup-fulfillment-response-in-dialogflow This code example shows how to send a card response from Dialogflow fulfillment. It utilizes the 'dialogflow-fulfillment' library and allows for customization of title, image URL, and text content for the card. The image URL requires a specific format including the media type. ```javascript const { WebhookClient, Card, Payload } = require('dialogflow-fulfillment'); const agent = new WebhookClient({request: req, response: res}); let intentMap = new Map(); intentMap.set(agent.intent, ()=>{ agent.add(new Card({ title: "Card Title", imageUrl: 'IMAGE;;' + "URL of media", text: "Card Text", buttonText: '', buttonUrl: '' })); }) agent.handleRequest(intentMap) ``` -------------------------------- ### Dialogflow Text Response Implementation (Node.js) Source: https://wiki.aisensy.com/en/articles/11489891-how-to-setup-fulfillment-response-in-dialogflow This snippet demonstrates how to set up a basic text response using Dialogflow's fulfillment service. It requires the 'dialogflow-fulfillment' library and is designed to be integrated into a backend system handling webhook requests from Dialogflow. ```javascript const { WebhookClient } = require('dialogflow-fulfillment'); const agent = new WebhookClient({request: req, response: res}); let intentMap = new Map(); intentMap.set(agent.intent, ()=>{ agent.add("Hi, This is Fulfillment Service responding"); }) agent.handleRequest(intentMap) ``` -------------------------------- ### Dialogflow Carousel Response Implementation (Node.js) Source: https://wiki.aisensy.com/en/articles/11489891-how-to-setup-fulfillment-response-in-dialogflow This implementation shows how to send a carousel response using a custom payload in Dialogflow fulfillment. It's useful for displaying multiple items, such as products, with media and descriptions. The carousel structure is defined within a 'payload' object. ```javascript const { WebhookClient, Card, Payload } = require('dialogflow-fulfillment'); const agent = new WebhookClient({request: req, response: res}); let intentMap = new Map(); const payload = { type: "carousel", items: [ { title: "Title of card", body: "Card text", mediaType: "IMAGE", mediaUri: "Media URL" } ] } intentMap.set(agent.intent, ()=>{ agent.add(new Payload(agent.UNSPECIFIED, payload, {rawPayload: true, sendAsMessage: true})); }) agent.handleRequest(intentMap) ```