Skip to Content
Menú
This question has been flagged
3 Respostes
4569 Vistes

Hello, is there any way to change the name of the operator in live chat box?

If yes, do you know some articles on how to do it?

Your help is greatly appreciated. Thanks :)

Avatar
Descartar
Autor

I tried to override the methods but it returns the operator name and visitor the same display name. Any idea?

im_livechat_channel.py

@api.model

def get_livechat_info(self, channel_id, username='Visitor'):

info = super(ImLivechatChannel, self).get_livechat_info(channel_id, username)

info['options']['chat_author_nickname'] = self.env.user.nickname

return info

im_livechat.js

add_message: function (data, options) {

var msg = {

id: data.id,

attachment_ids: data.attachment_ids,

author_id: data.author_id,

body: data.body,

date: moment(time.str_to_datetime(data.date)),

is_needaction: false,

is_note: data.is_note,

customer_email_data: []

};

// Compute displayed author name or email

// msg.displayed_author = msg.author_id && msg.author_id[1] ||

// this.options.default_username;

if (msg.author_id && msg.author_id[1]) {

msg.displayed_author = this.options.chat_author_nickname;

}

else {

msg.displayed_author = this.options.default_username;

}

// Compute the avatar_url

msg.avatar_src = this.server_url;

if (msg.author_id && msg.author_id[0]) {

msg.avatar_src += "/web/image/res.partner/" + msg.author_id[0] + "/image_small";

} else {

msg.avatar_src += "/mail/static/src/img/smiley/avatar.jpg";

}

if (options && options.prepend) {

this.messages.unshift(msg);

} else {

this.messages.push(msg);

}

},

Best Answer

Not sure but maybe this app may help you to change the name of the operator in live chat.

Avatar
Descartar
Autor

thanks for your help but I am looking for an answer/articles which helps me to do my code.

Best Answer

There now is an option in your Odoo profile to input a preferred name in the "Online Chat Name" field on your profile (top right of Odoo screen).
select My Profile > Preferences > Online Chat Name

Avatar
Descartar
Autor Best Answer

Rewriting the code.


python

class ImLivechatChannel(models.Model):
    _inherit = "im_livechat.channel"
    @api.model
    def get_livechat_info(self, channel_id, username='Visitor'):
        info = super(ImLivechatChannel, self).get_livechat_info(channel_id, username)
        info['options']['chat_author_nickname'] = self.env.user.nickname
        return info




js

add_message: function (data, options) {
        var msg = {
            id: data.id,
            attachment_ids: data.attachment_ids,
            author_id: data.author_id,
            body: data.body,
            date: moment(time.str_to_datetime(data.date)),
            is_needaction: false,
            is_note: data.is_note,
            customer_email_data: []
        };
        
        // Compute displayed author name or email
        // msg.displayed_author = msg.author_id && msg.author_id[1] ||
        //                        this.options.default_username;
        if (msg.author_id && msg.author_id[1]) {
           msg.displayed_author = this.options.chat_author_nickname;
        }
        else {
           msg.displayed_author = this.options.default_username;
        }
        // Compute the avatar_url
        msg.avatar_src = this.server_url;
        if (msg.author_id && msg.author_id[0]) {
            msg.avatar_src += "/web/image/res.partner/" + msg.author_id[0] + "/image_small";
        } else {
            msg.avatar_src += "/mail/static/src/img/smiley/avatar.jpg";
        }
        if (options && options.prepend) {
            this.messages.unshift(msg);
        } else {
            this.messages.push(msg);
        }
    },
Avatar
Descartar
Related Posts Respostes Vistes Activitat
1
de gen. 23
1701
1
de nov. 15
7134
0
de nov. 23
1165
3
de des. 23
7332
0
de des. 21
2365