[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
This commit is contained in:
XavierDo
2018-08-17 13:06:43 +02:00
parent dc5462db51
commit f83c313631
10 changed files with 38 additions and 41 deletions
+1 -10
View File
@@ -15,17 +15,8 @@ class MailBot(models.AbstractModel):
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"
discuss_href = 'href="/web#action=mail.mail_channel_action_client_chat&active_id=%s"' % record.id
discuss_src = 'src="/mail_bot/static/img/odoobot_discuss.png"'
chatter_src = 'src="/mail_bot/static/img/odoobot_chatter.png"'
return _("Good, you can customize your canned responses in the live chat application. <br/><br/>") + \
_("There are 3 different ways in Odoo to interact with your colleagues: <br/>\
-via this chat window<br/>\
-via the <a href=%s>Discuss</a> application:<br/><img %s/><br/><br/>\
-or via the chatter:<br/><img %s/><br/><br/>\
Aaaaand that's it! Enjoy discovering Odoo!") % (discuss_href, discuss_src, chatter_src)
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)
Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

@@ -242,7 +242,7 @@ var MailManager = AbstractService.extend({
previewsChannel = self._sortPreviews(previewsChannel);
previewsInbox = self._sortPreviews(previewsInbox);
previewsFailure = self._sortPreviews(previewsFailure);
return _.union(previewsFailure, previewsInbox, previewsChannel, previewsStatic);
return _.union(previewsStatic, previewsFailure, previewsInbox, previewsChannel);
});
},
/**
@@ -832,9 +832,9 @@ var MailManager = AbstractService.extend({
) {
elems.push({
title: _t("Odoobot has a request for you"),
imageSRC: "/mail/static/src/img/smiley/odoobot.png",
imageSRC: "/mail/static/src/img/odoobot.png",
status: 'bot',
body: _t("Enable desktop notifications to stay up to date"),
body: _t("Enable desktop notifications to chat"),
id: 'request_notification',
});
}
+3
View File
@@ -16,6 +16,9 @@
'views/assets.xml',
'data/mailbot_data.xml',
],
'demo': [
'data/mailbot_demo.xml',
],
'qweb': [
'views/discuss.xml',
],
+9
View File
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- Disable odoobot on admin so that devs don't hate him -->
<record id="base.user_root" model="res.users">
<field name="odoobot_state">disabled</field>
</record>
</data>
</odoo>
+15 -21
View File
@@ -38,47 +38,41 @@ class MailBot(models.AbstractModel):
# main flow
if odoobot_state == 'onboarding_emoji' and self._body_contains_emoji(body):
self.env.user.odoobot_state = "onboarding_attachement"
return _("Great! :) Did you notice that you can also send attachments, like a picture of your cute dog? Try it!")
return _("Great! 👍<br/>Now, try to <b>send an attachment</b>, like a picture of your cute dog...")
elif odoobot_state == 'onboarding_attachement' and values.get("attachment_ids"):
self.env.user.odoobot_state = "onboarding_command"
return _("Not a cute dog, but you get it :) To access special features, start your sentence with '/' (e.g. /help).")
return _("Not a cute dog, but you get it 😊<br/>To access special features, <b>start your sentence with '/'</b>. Try to get help.")
elif odoobot_state == 'onboarding_command' and command == 'help':
self.env.user.odoobot_state = "onboarding_ping"
return _("Wow you are a natural! Ping someone to grab its attention with @nameoftheuser. Try to ping me with <b>@OdooBot</b>.")
return _("Wow you are a natural!<br/>Ping someone to grab its attention with @nameoftheuser. <b>Try to ping me using @OdooBot</b> in a sentence.")
elif odoobot_state == 'onboarding_ping' and self._is_bot_pinged(values):
self.env.user.odoobot_state = "idle"
discuss_href = 'href="/web#action=mail.mail_channel_action_client_chat&active_id=%s"' % record.id
discuss_src = 'src="/mail_bot/static/img/odoobot_discuss.png"'
chatter_src = 'src="/mail_bot/static/img/odoobot_chatter.png"'
return _("That's me! 🎉<br/>") + \
_("There are 3 different ways in Odoo to interact with your colleagues: <br/>\
-via this chat window<br/>\
-via the <a href=%s>Discuss</a> application:<br/><img %s/><br/><br/>\
-or via the chatter:<br/><img %s/><br/><br/>\
Aaaaand that's it! Enjoy discovering Odoo!") % (discuss_href, discuss_src, chatter_src)
return _("Yet, I am here! 🎉<br/>It's the end of this overview, enjoy discovering Odoo!")
# easter eggs
elif odoobot_state == "idle" and body in ['❤️', _('i love you'), _('love')]:
return _("Aaaaaw that's really cute but, you know, bots don't work that way. You're too human for me! Let's keep it professional ❤️")
elif odoobot_state == "idle" and body in [_('help'), _('help me'), _('i need help')]:
return _("I'm trying to help you, but I'm just a bot... :( You can also check <a href=\"https://www.odoo.com/page/docs\">our documentation</a>) for more information!")
elif odoobot_state == "idle" and (('help' in body) or _('help') in body):
return _("I'm just a bot... :( You can check <a href=\"https://www.odoo.com/page/docs\">our documentation</a>) for more information!")
elif odoobot_state == "idle" and _('fuck') in body or "fuck" in body:
return _("That's not a really nice thing to say, you know? I'm a bot but I have feelings, ok?! 💔")
return _("That's not nice! I'm a bot but I have feelings... 💔")
else:
#repeat question
if odoobot_state == 'onboarding_emoji':
return _("Not exactly. To send an emoji, type \":)\" and press enter.")
return _("Not exactly. To continue the tour, send an emoji, <b>type \":)\"</b> and press enter.")
elif odoobot_state == 'onboarding_attachement':
return _("I want you to send me an attachement, you should press the button next to the chat bar to select a file.")
return _("To <b>send an attachment</b>, click the 📎 icon on the right, and select a file.")
elif odoobot_state == 'onboarding_command':
return _("Not sure wat you are doing. Please press / and wait for the propositions. Select \"help\" and press enter")
elif odoobot_state == 'onboarding_ping':
return _("Please, ping me. Type and \"@\" and begin to type \"odoobot\". Select the proposition and press enter.")
return _("Sorry, I am not listening. To get someone's attention, <b>ping him</b>. Write \"@odoobot\" and select me.")
return random.choice([
_("I'm not smart enough to answer your question, sorry."),
_("I'm afraid I don't understand. Sorry!")
_("I'm not smart enough to answer your question."),
_("Ok, what about you?"),
_("I'm afraid I don't understand. Sorry!"),
_("Sorry I'm sleepy. Or not! Maybe I'm just trying to hide my unawareness of human language..."),
])
elif self._is_bot_pinged(values):
return random.choice([_("Yaaaay that's me!"), _("Odeyhoooo")])
return random.choice([_("Yep, Odoobot is in the place!"), _("Pong.")])
return False
def _body_contains_emoji(self, body):
+1 -1
View File
@@ -35,7 +35,7 @@ class Channel(models.Model):
'email_send': False,
'name': 'OdooBot'
})
message = _("Hello, I'm here to help you discover chat features. Try answering me with an emoji 😊")
message = _("Hello,<br/>I'm here to help you discover chat features. <b>Try sending me an emoji :)</b>")
channel.message_post(body=message, author_id=odoobot_id, message_type="comment", subtype="mail.mt_comment")
self.env.user.odoobot_state = 'onboarding_emoji'
return channel
Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

+6 -6
View File
@@ -33,7 +33,7 @@ class TestOdoobot(BaseFunctionalTest, MockEmails, TestRecipients):
self.assertNextMessage(
self.test_record_employe.with_context({'mail_post_autofollow': True}).message_post(**kwargs),
sender=self.odoobot,
answer=["Yaaaay that's me!"] # no the perfect idea to base a test on a random but it should work for test phase, better mock random choice?
answer=["Yep, Odoobot is in the place!"]
)
# Odoobot should not be a follower but user_employee and user_admin should
follower = self.test_record.message_follower_ids.mapped('partner_id')
@@ -50,14 +50,14 @@ class TestOdoobot(BaseFunctionalTest, MockEmails, TestRecipients):
self.assertNextMessage(
channel.message_post(**kwargs),
sender=self.odoobot,
answer="Great! :) Did you notice that you can also send attachments, like a picture of your cute dog? Try it!"
answer=("attachment",)
)
kwargs['body'] = ''
kwargs['attachment_ids'] = [1]
last_message = self.assertNextMessage(
channel.message_post(**kwargs),
sender=self.odoobot,
answer="Not a cute dog, but you get it :) To access special features, start your sentence with '/' (e.g. /help)."
answer=("help",)
)
kwargs['attachment_ids'] = []
@@ -65,7 +65,7 @@ class TestOdoobot(BaseFunctionalTest, MockEmails, TestRecipients):
self.assertNextMessage(
last_message, # no message will be post with command help, use last odoobot message instead
sender=self.odoobot,
answer="Wow you are a natural! Ping someone to grab its attention with @nameoftheuser. Try to ping me with <b>@OdooBot</b>."
answer=("@OdooBot",)
)
# we dont test the end of the flow since it will depends of the installed apps (livechat)
self.user_employee.odoobot_state = "idle"
@@ -74,13 +74,13 @@ class TestOdoobot(BaseFunctionalTest, MockEmails, TestRecipients):
self.assertNextMessage(
channel.message_post(**kwargs),
sender=self.odoobot,
answer="Aaaaaw that's really cute but, you know, bots don't work that way. You're too human for me! Let's keep it professional ❤️"
answer=("too human for me",)
)
kwargs['body'] = "Go fuck yourself"
self.assertNextMessage(
channel.message_post(**kwargs),
sender=self.odoobot,
answer="That's not a really nice thing to say, you know? I'm a bot but I have feelings, ok?! 💔"
answer=("I have feelings",)
)
@mute_logger('odoo.addons.mail.models.mail_mail')