Files
odoo_source/addons/im_livechat_mail_bot/models/mail_bot.py
T
XavierDo f83c313631 [IMP] mail_bot: improve answers, initialisation and others
1. Odoobot shouldn't talk to admin when demo data are installed
Odoobot will talk to a user on it's first connection, meaning that
a dev will see this chat window a lot. The state disabled is not a
real state but is explicit, the odoobot wont be initialized in this
case. It is still possible to test odoobot flow with demo user.

2. remove old odoobot image and update link

3. small improvements in odoobot answers
2018-08-17 13:06:43 +02:00

23 lines
1.2 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models, _
class MailBot(models.AbstractModel):
_inherit = 'mail.bot'
def _get_answer(self, record, body, values, command):
odoobot_state = self.env.user.odoobot_state
if self._is_bot_in_private_channel(record):
if odoobot_state == "onboarding_ping" and self._is_bot_pinged(values):
self.env.user.odoobot_state = "onboarding_canned"
return _("That's me! 🎉<br/>Try to type \":\" to use canned responses.")
elif odoobot_state == "onboarding_canned" and values.get("canned_response_ids"):
self.env.user.odoobot_state = "idle"
return _("Good, you can customize canned responses in the live chat application.<br/><br/><b>It's the end of this overview</b>, enjoy discovering Odoo!")
#repeat question if needed
elif odoobot_state == 'onboarding_canned':
return _("Not sure wat you are doing. Please press : and wait for the propositions. Select one of them and press enter.")
return super(MailBot, self)._get_answer(record, body, values, command)