更改WebChat中的头像

时间:2019-10-18 13:57:59

标签: twilio

我想更改网聊上的头像,尤其是在客户端上,而我似乎找不到任何文档。

这是我现在的代码,并且一切正常,除了聊天中的头像是默认头像,并且我想放置风俗头像。很抱歉,如果这真的很基础,并且在文档中已作了明确说明,我似乎还无法掌握React。

<script src="https://media.twiliocdn.com/sdk/js/flex-webchat/releases/2.1.2/twilio-flex-webchat.min.js"></script>

<script>
    function createFriendlyName(){
    let firstName = document.getElementById("first-name-input").value
    let lastName = document.getElementById("last-name-input").value.toUpperCase()
    let friendlyName = ""
    if (firstName || lastName){
        if (!firstName)
            friendlyName = lastName
        else if (!lastName)
            friendlyName = firstName
        else
            friendlyName = firstName + " " + lastName
    }
    return (friendlyName)
}

document.getElementById("render-button").addEventListener("click", function(event) {
    let friendlyName = createFriendlyName()
    if (friendlyName)
        appConfig.context = {
            friendlyName: friendlyName,
        }
    renderChat(event)
});

appConfig = {
    accountSid:"AC...",
    flexFlowSid:"FO...",
    context: {},
};
function renderChat(e)
{
    Twilio.FlexWebChat.renderWebChat(appConfig);
    e.target.style.display = "none"
}
</script>

0 个答案:

没有答案