Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
3 Risposte
4628 Visualizzazioni

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
Abbandona
Autore

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);

}

},

Risposta migliore

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

Avatar
Abbandona
Autore

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

Risposta migliore

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
Abbandona
Autore Risposta migliore

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
gen 23
1718
1
nov 15
7147
0
nov 23
1184
3
dic 23
7354
0
dic 21
2398