I have tried to query data from firestore and use the data to create carousel payload to response the line message.
But nothing occur on line even if it's in the intent.
This's how the data looks like. It's know the designed looks suck. I'm new with it.
I have tried to query data from firestore and use the data to create carousel payload to response the line message. But nothing occur on line even if it's in the intent.
This's how the data looks like. It's know the designed looks suck. I'm new with it.
This occur when the flow goes in the intent.
And this is the code. ` 'use strict';
const functions = require('firebase-functions'); const { WebhookClient, Payload } = require('dialogflow-fulfillment'); const { Card, Suggestion } = require('dialogflow-fulfillment');
const admin = require("firebase-admin"); admin.initializeApp({ credential: admin.credential.applicationDefault(), databaseURL: 'https://.firebaseio.com'
});
const db = admin.firestore();
db.settings({ timestampsInSnapshots: true });
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(agent) { let pproduct = String(request.body.queryResult.parameters.search);
} function carousel(bubble0, bubble1, bubble2, bubble3, bubble4) { const payloadJson = { "type": "flex", "altText": "Flex Message", "contents": { "type": "carousel", "contents": [bubble0, bubble1, bubble2, bubble3, bubble4] } }; return payloadJson; } function bubble(img0, price0, brand0, product0, link0) { let color = '#7fbe26'; if (brand0 == 'Tesco') { color = "#2B51CC"; } else if(brand0=='BigC'){ color = '#7fbe26'; }else{ color= '#5dbcd2'; } const bubb = { "type": "bubble", "direction": "ltr", "header": { "type": "box", "layout": "vertical", "contents": [ { "type": "text", "text": brand0, "size": "xl", "color": color, "align": "center", "weight": "bold" } ] }, "hero": { "type": "image", "url": img0, "size": "full", "aspectRatio": "1.51:1", "aspectMode": "fit", "action": { "type": "uri", "uri": link0 } }, "body": { "type": "box", "layout": "vertical", "contents": [ { "type": "text", "text": product0, "size": "xl", "align": "center", "weight": "bold" }, { "type": "text", "text": 'ราคา'+' '+price0 +' '+'บาท', "align": "center" } ] } }; return bubb; } let intentMap = new Map(); intentMap.set('pricesearch', test); agent.handleRequest(intentMap); }); `