简体   繁体   English

如何使用nodejs在dialogflow的卡片响应中添加多个按钮?

[英]How to add more than one button in card resoponse in dialogflow using nodejs?

I am trying to add more than one button in facebook messenger card response using dialogflow nodejs.我正在尝试使用 dialogflow nodejs 在 facebook 信使卡响应中添加多个按钮。 I am able to do that from dialogflow console but not with the code我可以从 dialogflow 控制台执行此操作,但不能使用代码执行此操作

const welcome = (agent) => { agent.add(`Welcome to my Khoon hazir. It is an online blood bank. How may i help you?`);
    agent.add(new Card({
        title: `Khoon hazir`,
        imageUrl: 'https://images.pexels.com/photos/355296/pexels-photo-355296.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500',
        text: `This is an online Blood bank, aim to save lives`,
        buttonText: 'Need Blood',
        buttonUrl: 'https://www.facebook.com/khoon.hazir/'
    }));        
}

According to this https://github.com/dialogflow/dialogflow-fulfillment-nodejs/blob/master/src/rich-responses/card-response.js .根据这个https://github.com/dialogflow/dialogflow-fulfillment-nodejs/blob/master/src/rich-responses/card-response.js You cannot do that directly.你不能直接这样做。 You have to edit the library code to do that.您必须编辑库代码才能做到这一点。 Just edit the code between line numbers 274 and 279 to support the multiple buttons.只需编辑行号 274 和 279 之间的代码即可支持多个按钮。

I created this unofficial fork that support multi buttons: https://github.com/fabio-C/dialogflow-fulfillment-nodejs我创建了这个支持多按钮的非官方分支: https : //github.com/fabio-C/dialogflow-fulfillment-nodejs

Tested Only of Facebook/Messanger Platform.仅测试 Facebook/Messanger 平台。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM