【问题标题】:Gupshup - multiple messages delay feature not workingGupshup - 多条消息延迟功能不起作用
【发布时间】:2017-10-18 14:10:13
【问题描述】:

我尝试在我的机器人上实现延迟功能,以便一个接一个地显示多条消息。延迟功能显示在我的 Flow Bot Builder 图表中,但是当我在对话测试器和 Messenger 上的代理机器人中进行测试时,延迟实际上并没有发生 - 所有消息都会同时显示。

我已将IDE中的延迟代码添加到default.scr文件中:

[main]
   label_dych:Hi! I'm delay-bot and I'm here to help you with any questions you have.:continue
     ((delay 2000))
       label_gthk:I'll never need to take any personal or financial information from you, so as we chat please don't tell me any!:continue
         ((delay 1000))
           label_ylbn:{"name":"quickreply","type":"quick_reply","alias":"What can I help you with?","msgid":"117af569-5188-ff7e-9b48-8c553c2f36cb","content":{"type":"text","text":"What can I help you with?"},"options":[{"type":"text","title":"My Page","iconurl":"","id":"ac49ad32-c9bc-469f-2152-c7c842bad8ea","isDuplicate":false,"name":"user"},{"type":"text","title":"Team Spaces","iconurl":"","id":"8a2017ac-2fc3-0901-be8d-1fad5a2dba12","isDuplicate":false,"name":"user"},{"type":"text","title":"Offline Support","iconurl":"","id":"70861407-e706-17a3-207b-c43958fde83e","isDuplicate":false,"name":"user"},{"type":"text","title":"Something else","iconurl":"","id":"d3f7b6b4-e70a-098d-dde9-1da3e8cc08dc","isDuplicate":false,"name":"user"}]}

我还按照此处的说明将 options.apikey 代码行添加到 index.js 文件中:https://www.gupshup.io/developer/docs/bot-platform/guide/sending-multiple-messages-botscript

function ScriptHandler(context, event){
    var options = Object.assign({}, scr_config);
    options.current_dir = __dirname;
    //options.default_message = "Sorry Some Error Occurred.";
    // You can add any start point by just mentioning the 
<script_file_name>.<section_name>
    // options.start_section = "default.main";
    options.success = function(opm){
        context.sendResponse(JSON.stringify(opm));
    };
    options.error = function(err) {
        console.log(err.stack);
        context.sendResponse(options.default_message);
    };
    botScriptExecutor.execute(options, event, context);
    options.apikey = "1mbccef47ab24dacad3f99557cb35643";
}

延迟效果在消息之间不起作用有什么明显的原因吗?当我点击右上角的徽标时,我使用了为我的 gupshup 帐户显示的 apikey。

【问题讨论】:

    标签: gupshup


    【解决方案1】:

    您在调用脚本工具执行函数后放置了 API 密钥。将 API Key 放在 botScriptExecutor.execute 之前的任何位置,延迟应该会起作用。

    另外,延迟的时间以毫秒为单位。

    示例:

    function ScriptHandler(context, event){
    var options = Object.assign({}, scr_config);
    options.current_dir = __dirname;
    //options.default_message = "Sorry Some Error Occurred.";
    options.apikey = "1mbccef47ab24dacad3f99557cb35643";
    // You can add any start point by just mentioning the 
    <script_file_name>.<section_name>
    // options.start_section = "default.main";
    options.success = function(opm){
        context.sendResponse(JSON.stringify(opm));
    };
    options.error = function(err) {
        console.log(err.stack);
        context.sendResponse(options.default_message);
    };
    botScriptExecutor.execute(options, event, context);
    

    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-01-05
      • 1970-01-01
      • 1970-01-01
      • 2018-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多