在发送消息之前等待HeroCard映像加载

时间:2018-05-19 15:00:22

标签: botframework

如何在发送邮件之前确保加载图像?我目前正在使用setTimeout()功能提供更自然的聊天体验以及session.sendTyping()。这也有点确保在发送之前正确构建消息,但我仍然有时会遇到未加载的图像。

图像托管在Azure文件中,并通过HTTP使用SAS密钥进行访问。

image not yet loaded

如图所示,该消息返回带有空白图像的英雄卡。'

更新:一些代码供参考

// The function returns a message object with either a Hero Card or a text string 
function addImgToMsg(table) {
    let msg = new builder.Message(session);
    let mainCard = new builder.HeroCard(session);

    // Check if the given DB entry has an image link
    if (table.img) {
        mainCard.images([
            builder.CardImage.create(session, 'link_to_my_image')
        ]);
    }

    // Attach the Hero Card to the message if has gotten any content
    if (mainCard.data.content.images) {
        msg.attachmentLayout(builder.AttachmentLayout.carousel);
        msg.attachments([mainCard]);
    } else {
        msg.text('No was image provided.')
    }

    return msg;
}

0 个答案:

没有答案
相关问题