【问题标题】:Is the Dialogflow Payload Class deprecated? Custom Payload in dialogflow is not responding for TelegramDialogflow 有效负载类是否已弃用?对话流中的自定义有效负载对 Telegram 没有响应
【发布时间】:2019-10-10 07:06:00
【问题描述】:

对于“测试意图”,我启用了Enable Webhook Call for this intent 我已正确设置 Telegram 与机器人的集成。

在完整的代码中,我使用了Payload对象的构造函数(https://dialogflow.com/docs/reference/fulfillment-library/rich-responses#new_payloadplatform_payload)and我已经指定了表示payload目标平台的字符串。请参见欢迎函数下面的代码:

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

    exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
    const agent = new WebhookClient({ request, response });

    function test(agent) {
      agent.add(new Payload(agent.TELEGRAM, {

        "text": "Please click on button below to share your number",
        "reply_markup": {
          "one_time_keyboard": true,
          "resize_keyboard": true,
          "keyboard": [
            [
              {
                "text": "Share my phone number",
                "callback_data": "phone",
                "request_contact": true
              }
            ],
            [
              {
                "text": "Cancel",
                "callback_data": "Cancel"
              }
            ]
          ]
        }
       }));
      }

      // Run the proper function handler based on the matched Dialogflow intent name
      let intentMap = new Map();
      intentMap.set('test Intent', test);
      agent.handleRequest(intentMap);
       });

Dialogflow 不会在调用意图时将履行代码中的有效负载响应返回给电报。 我查看了项目功能日志,但没有记录错误。 他们没有理由让我的代码不工作

对话流中是否已弃用有效负载类?

【问题讨论】:

    标签: dialogflow-es-fulfillment


    【解决方案1】:

    我今天遇到了同样的问题,现在正在运行

            var pl_tl = {
                "telegram": {
                    "text": "Please click on button below to share your number",
                    "reply_markup": {
                        "one_time_keyboard": true,
                        "resize_keyboard": true,
                        "keyboard": [
                            [
                                {
                                    "text": "Share my phone number",
                                    "callback_data": "phone",
                "request_contact": true
                                }
                            ],
                            [
                                {
                                    "text": "Cancel",
                                    "callback_data": "Cancel"
                                }
                            ]
                        ]
                    }
                }   
            }
    
    
            let pl = new Payload(agent.TELEGRAM, pl_tl, { sendAsMessage: true, rawPayload: true });
    

    【讨论】:

    • 履行响应返回此:{ "fulfillmentMessages": [], "outputContexts": [] }。它没有用。
    【解决方案2】:

    Dialogflow 实现 webhook 逻辑中使用的 dialogflow WebhookClient 返回 包含 send 方法的 Express HTTP 响应对象。我使用此方法将响应发送回 dialogflow 的 webhook 实现 API。请参阅下面的代码。

    function telegramIntegration(agent) {
    
      const ClientResponse=
      {
        "ClientResponse": [
          {
            "payload": {
              "telegram": 
              {
                "text": "Please share your contact",
                "reply_markup": {
                  "keyboard": [
                    [
                      {
                        "text": "Share my phone number",
                        "callback_data": "phone",
                        "request_contact": true
                      }
                    ],
                    [
                      {
                        "text": "Cancel",
                        "callback_data": "Cancel"
                      }
                    ]
                  ],
                  "one_time_keyboard": true,
                  "resize_keyboard": true
                }
              }
            }
          }
        ]
      };
    
      response.send(JSON.stringify(ClientResponse));
    }
    

    但是,此解决方法不能回答我的问题“Dialogflow Payload Class 已弃用吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多