【问题标题】:How to add chat bot v4 avatar icon in web chat?如何在网络聊天中添加聊天机器人 v4 头像图标?
【发布时间】:2019-07-17 10:10:42
【问题描述】:

我必须在机器人响应中添加一个头像,但我找不到这样做的方法。

我已经尝试过使用 botAvatarInitials 和 userAvatarInitials Change the avatar of the bot within the dialog box ,但这并不是我想要的。

    window.WebChat.renderWebChat({
        directLine: botConnection,
        styleOptions: styleOptions,
        botAvatarInitials: 'BOT',
        userAvatarInitials: 'YOU'
    }, document.getElementById('webchat'));

有办法使用图片吗?或者至少改变头像气泡的颜色?

【问题讨论】:

    标签: javascript html azure botframework chatbot


    【解决方案1】:

    是的,您可以使用this sample 中所述的botAvatarImage 属性设置图像。

    它看起来像这样:

    const styleOptions = {
        botAvatarImage: 'https://docs.microsoft.com/en-us/azure/bot-service/v4sdk/media/logo_bot.svg?view=azure-bot-service-4.0',
        botAvatarInitials: 'BF',
        userAvatarImage: 'https://github.com/compulim.png?size=64',
        userAvatarInitials: 'WC'
    };
    
    window.WebChat.renderWebChat({
        directLine: botConnection,
        styleOptions
     }, document.getElementById('webchat'));
    

    要设置头像气泡的背景,您可以执行以下操作:

    const styleOptions = {
        bubbleBackground: 'rgba(0, 0, 255, .1)',
        bubbleFromUserBackground: 'rgba(0, 255, 0, .1)'
    };
    
    window.WebChat.renderWebChat({
        directLine: botConnection,
        styleOptions
    }, document.getElementById('webchat'));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-18
      • 1970-01-01
      相关资源
      最近更新 更多