简体   繁体   English

Dialogflow:无法从内联编辑器发送自定义有效负载

[英]Dialogflow: Can't send Custom Payload from inline editor

I'm trying to send custom payload from inline editor, to be displayed at DialogFlow Messenger integration.我正在尝试从内联编辑器发送自定义有效负载,以在 DialogFlow Messenger 集成中显示。 Here's my code:这是我的代码:

 // 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');
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": {
                                "rawUrl": "https://img2.freepng.es/20180621/ewt/kisspng-trello-logo-slack-atlassian-trello-5b2bcdc85e4d36.2783338815295973843863.jpg"
                              }
                            }
                          }
                        ]
                      ]
                    }]};

    agent.add(new Payload(agent.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": "^6.0.0",
    "firebase-functions": "^2.0.2",
    "dialogflow": "^0.6.0",
    "dialogflow-fulfillment": "^0.5.0",
    "@google-cloud/common":"^0.25.3",
    "@google-cloud/projectify":"^0.3.1",
    "@google-cloud/promisify":"^0.3.1",
    "@google-cloud/translate":"^2.1.2",
    "@google-cloud/firestore": "^0.16.1"
  }
}

I'm not able to make this work.我无法完成这项工作。 I've been searching the net for hours and I can't find any solution.我已经在网上搜索了几个小时,但找不到任何解决方案。 I've also tried some solutions from stackoverflow, but they seem to be outdated, as Dialogflow keeps changing their environment.我也尝试过 stackoverflow 的一些解决方案,但它们似乎已经过时,因为 Dialogflow 不断改变他们的环境。 Any help would be really appreciated.任何帮助将非常感激。

Thanks in advance!提前致谢!

for me, change "dialogflow-fulfillment": "^0.5.0" , to "dialogflow-fulfillment": "^0.6.1" in package.json .对我来说,将package.json "dialogflow-fulfillment": "^0.5.0"更改为"dialogflow-fulfillment": "^0.6.1"

And in your test_accordion function need to return agent:并且在您的test_accordion函数中需要返回代理:

return agent;退货代理;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Dialogflow 中的自定义负载 - Custom payload in Dialogflow 对话流自定义有效负载 json - dialogflow custom payload json 您可以在dialogflow内联编辑器中实现两个不同的实现吗? - Can you have two different fulfillment's in the dialogflow inline editor? 我可以在 Inline Fulfillment Dialogflow 编辑器中跨对话存储计数器吗? - Can I store a counter across conversation in Inline Fulfillment Dialogflow editor? dialogflow 内联编辑器可以处理多个不同的功能吗? - Can dialogflow inline editor handle multiple different functions? 从 Node.js 为 Dialogflow 发送的默认响应负载是什么 - What is the default response payload to send from Node.js for Dialogflow 如何在嵌入式编辑器dialogflow中发出发布请求? - how to make post request in inline editor dialogflow? 是否可以在dialogflow内联编辑器中使用外部库? - Is it possible to use external libraries in the dialogflow inline editor? 如何通过Dialogflow中的内联编辑器将Dialogflow连接到Cloud Firestore? - How to connect Dialogflow to Cloud Firestore via the Inline Editor in Dialogflow? Dialogflow 自定义有效负载未在 facebook 信使中发布消息 - Dialogflow custom payload not posting message in facebook messenger
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM