From 01701909edad54eea3f7bf94f4079a94ecee2d7c Mon Sep 17 00:00:00 2001 From: blopa Date: Sun, 10 Dec 2017 03:04:14 -0200 Subject: [PATCH 01/13] add translation --- Magento2/app/code/Werules/Chatbot/i18n/en_US.csv | 2 +- Magento2/app/code/Werules/Chatbot/i18n/es_ES.csv | 2 +- Magento2/app/code/Werules/Chatbot/i18n/pt_BR.csv | 2 +- .../app/code/Werules/Chatbot/i18n/zh_Hans_CN.csv | 2 +- .../app/code/Werules/Chatbot/i18n/zh_Hant_HK.csv | 2 +- .../app/code/Werules/Chatbot/i18n/zh_Hant_TW.csv | 2 +- .../view/frontend/layout/customer_account.xml | 2 +- .../view/frontend/web/image/messenger-icon.png | Bin 0 -> 6248 bytes 8 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 Magento2/app/code/Werules/Chatbot/view/frontend/web/image/messenger-icon.png diff --git a/Magento2/app/code/Werules/Chatbot/i18n/en_US.csv b/Magento2/app/code/Werules/Chatbot/i18n/en_US.csv index dcff767..b923d3b 100644 --- a/Magento2/app/code/Werules/Chatbot/i18n/en_US.csv +++ b/Magento2/app/code/Werules/Chatbot/i18n/en_US.csv @@ -1,3 +1,4 @@ +"Cancel","Cancel" "Sorry, no products found for this criteria.","Sorry, no products found for this criteria." "Sorry, no products found in this category.","Sorry, no products found in this category." "Please select a category.","Please select a category." @@ -22,7 +23,6 @@ "Track Order Status","Track Order Status" "Talk to Support","Talk to Support" "Send Email","Send Email" -"Cancel","Cancel" "Help","Help" "About","About" "Logout","Logout" diff --git a/Magento2/app/code/Werules/Chatbot/i18n/es_ES.csv b/Magento2/app/code/Werules/Chatbot/i18n/es_ES.csv index 6410f0d..c30a7e0 100644 --- a/Magento2/app/code/Werules/Chatbot/i18n/es_ES.csv +++ b/Magento2/app/code/Werules/Chatbot/i18n/es_ES.csv @@ -1 +1 @@ -"string","stringtranslated" \ No newline at end of file +"Cancel","Cancelar" \ No newline at end of file diff --git a/Magento2/app/code/Werules/Chatbot/i18n/pt_BR.csv b/Magento2/app/code/Werules/Chatbot/i18n/pt_BR.csv index 6410f0d..c30a7e0 100644 --- a/Magento2/app/code/Werules/Chatbot/i18n/pt_BR.csv +++ b/Magento2/app/code/Werules/Chatbot/i18n/pt_BR.csv @@ -1 +1 @@ -"string","stringtranslated" \ No newline at end of file +"Cancel","Cancelar" \ No newline at end of file diff --git a/Magento2/app/code/Werules/Chatbot/i18n/zh_Hans_CN.csv b/Magento2/app/code/Werules/Chatbot/i18n/zh_Hans_CN.csv index 6410f0d..01039ab 100644 --- a/Magento2/app/code/Werules/Chatbot/i18n/zh_Hans_CN.csv +++ b/Magento2/app/code/Werules/Chatbot/i18n/zh_Hans_CN.csv @@ -1 +1 @@ -"string","stringtranslated" \ No newline at end of file +"Cancel","取消。" \ No newline at end of file diff --git a/Magento2/app/code/Werules/Chatbot/i18n/zh_Hant_HK.csv b/Magento2/app/code/Werules/Chatbot/i18n/zh_Hant_HK.csv index 6410f0d..01039ab 100644 --- a/Magento2/app/code/Werules/Chatbot/i18n/zh_Hant_HK.csv +++ b/Magento2/app/code/Werules/Chatbot/i18n/zh_Hant_HK.csv @@ -1 +1 @@ -"string","stringtranslated" \ No newline at end of file +"Cancel","取消。" \ No newline at end of file diff --git a/Magento2/app/code/Werules/Chatbot/i18n/zh_Hant_TW.csv b/Magento2/app/code/Werules/Chatbot/i18n/zh_Hant_TW.csv index 6410f0d..01039ab 100644 --- a/Magento2/app/code/Werules/Chatbot/i18n/zh_Hant_TW.csv +++ b/Magento2/app/code/Werules/Chatbot/i18n/zh_Hant_TW.csv @@ -1 +1 @@ -"string","stringtranslated" \ No newline at end of file +"Cancel","取消。" \ No newline at end of file diff --git a/Magento2/app/code/Werules/Chatbot/view/frontend/layout/customer_account.xml b/Magento2/app/code/Werules/Chatbot/view/frontend/layout/customer_account.xml index 9d9227c..5c676a2 100644 --- a/Magento2/app/code/Werules/Chatbot/view/frontend/layout/customer_account.xml +++ b/Magento2/app/code/Werules/Chatbot/view/frontend/layout/customer_account.xml @@ -5,7 +5,7 @@ chatbot/customer - Chatbot + Chatbot Settings diff --git a/Magento2/app/code/Werules/Chatbot/view/frontend/web/image/messenger-icon.png b/Magento2/app/code/Werules/Chatbot/view/frontend/web/image/messenger-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..611e6d4c85e649b7745b5c980085d5ad1c1b20b8 GIT binary patch literal 6248 zcmds5`p?*YR*@NElxT?2Jp)9=_mCyftsJ3E}WHdd#A zAMXt&v-Nft#Q5I9dU5?~5TMGbNPN%uGmHa*XdE<@6^wm;ZO^{-rc$AY_6kSGL!BB0 zRTL0Diy<5s%%aS~(6{-Yq#D0|MGu;XgfbT@D!^z~59Awhl~s^(+Nmsr>nD%t7g3Q|}9ptc=GN77v|te=au- zmL7a`;|kqPib;PW{^#>}6|vfIMIiEA+RXCq%cW_$|F%ktgj4xWCt4VcX!Wwpq*(5y zHDZsh?}%SBl4z9;s_LRMv{QXX5^Ztiidn3hNSI5_j^up}$lt8n>Xf28YiqyM)qNq6 zrB0swPS{&q;P8!JJ=f_fgr`BZPwf4j^xuWP!!ye6t#ge0s2E;j0fy>|Vm49!js z5`QWhq**;Ep~bhes=2r@N{REt4Skvrl~-yJkt-VUw4{{R@GdjSYt|VsL!MpkqNN!t zEOQyEFHp)o60ZEG{j}=OD>l1GyA7C%f<3P$+w*W02fT+u!Jc+BxBcwK5^dB8#XZ&( zTc)ypTh;3%lzOf5YH7-wme4oNdA_!^v{6ho5u~p5C6`M%%?8Kg=3!A05zM0;eBuvJ zJe@;)sQw_lKh@?4$gbBrUpQoHs8}iZ>c38ic;^Iog4ia%-5DZP9Ol3rj?9yjIN%Wu zGL40b`TVY*L#`Kgr4#+;%vnfgbukmmL#|ThZA><`wi2An{43U1AM8`imI#)qm|%;Z zS5dxO>{e7maW4HxG8=VHxl!Y=OT#!tcmRzFG@Tjh&GPcnAv(t!8rz=+hi`?m#UUy4 zzHa_oaqlE~+MpvCCL1YB^(dB2k3y%gOzJ{ns8X7nq->A~I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i zk-WNv`nP#eiXg)_ylS5NaO5KjGV2S%_F@a12kb0xq&Syd8ST3e>%`rt3em5PuKSJ}8F_4qfu0~iml6esK;BTZbGNk9F)bqaGm#9;2Df1i}d zT0i2wKP0h+%A+IW^yXZBn=@8vbUfRMR4DFkZPGON$qQZa)hWS{ZIBsFHUG4)%*pgs z(mIKXK4k=-$Cv)nEPWqYnf3GQGqoJ*M|@wD0V@w2sXNdz80f|$*m`6)3lmCT^5rUI zXyWrItc?$ruFt*lap&TfGjH5HI}+FbSVUuSByZ611Pa|uM)5!UvHQ#4cQ(W$(pa#B z7XfZ5EC%QBYUs$l-su?B@%I+aM$k6Zx{Tqf;4;C?a@q*4yL#@5W)HX5y6x^$kxK-w zFTGviln_d7513EYh>z3#U23X&Bfp{Yb^NX0{8N8OWH%<8eTONj1qI+{_Y30iJ`~AC z9nD!93mef%kJefoIve==Fu^cGJoQ3&A0E=ouzz5wU^J;TDI}9DbZ%U;vQ%Bm_vVIX z;@h_B`=&a^3#<&wR1eROuS=EY+Ky+uD;`TRuFV%hlKkJMucY*aGYSRlzZYB1bbh~( zD7G$o+!}PXl~iWZu6VH(HY4_GQu3GHwJ8kCF7zaosko0W8XEemW6grY?KzVp`HTkL zAF%a{LS*wNd+8MaZ5ZLFfOJz^9GiG|k*UXGB#_?Xc=;I~CaVdz8%r<>p(XsE#Sh9_ zMNmLFFv#hIWjYzLi?tJtA%w^wa=G0c6Q7ac(TJzvkR5~`lr11$wmPC$MWAufa)WsL zYbGR|1ZW)8pR`07jN3!Ehy>j2&Xk-l+?+b2F#?P5eF+hQB6)}OtLud zUHyXoEgEMla7{tnSVM0SVqW=Bz5a~8QT~a!s=dh2SWKva2tpNB2tjunUHk8dMC{-E PaUl&AUFFY;sL=lblMGrF literal 0 HcmV?d00001 From 1aabf2eaf398b66a5a7eac553eea1993e11ca573 Mon Sep 17 00:00:00 2001 From: blopa Date: Sat, 16 Dec 2017 17:12:28 -0200 Subject: [PATCH 02/13] add support command --- .../app/code/Werules/Chatbot/Helper/Data.php | 24 +++++++++++++++++-- .../code/Werules/Chatbot/Helper/Define.php | 2 ++ .../Werules/Chatbot/Setup/UpgradeData.php | 2 +- .../Werules/Chatbot/etc/adminhtml/system.xml | 6 ++--- .../app/code/Werules/Chatbot/etc/module.xml | 2 +- .../app/code/Werules/Chatbot/i18n/en_US.csv | 1 + README.md | 3 ++- 7 files changed, 32 insertions(+), 8 deletions(-) diff --git a/Magento2/app/code/Werules/Chatbot/Helper/Data.php b/Magento2/app/code/Werules/Chatbot/Helper/Data.php index 909d031..8ad0ff4 100644 --- a/Magento2/app/code/Werules/Chatbot/Helper/Data.php +++ b/Magento2/app/code/Werules/Chatbot/Helper/Data.php @@ -317,6 +317,8 @@ public function processOutgoingMessage($outgoingMessage) $result = $chatbotAPI->sendReceiptList($outgoingMessage); else if ($outgoingMessage->getContentType() == $this->_define::TEXT_WITH_OPTIONS) // LIST_WITH_IMAGE $result = $chatbotAPI->sendMessageWithOptions($outgoingMessage); + else if ($outgoingMessage->getContentType() == $this->_define::NO_REPLY_MESSAGE) + $result = true; if ($result) { @@ -350,7 +352,8 @@ public function processOutgoingMessage($outgoingMessage) else $lastCommandParameter = null; - $chatbotAPI->setChatbotAPILastCommandDetails($lastCommandText, $lastListedQuantity, $lastConversationState, $lastCommandParameter); + if ($currentCommandDetails) + $chatbotAPI->setChatbotAPILastCommandDetails($lastCommandText, $lastListedQuantity, $lastConversationState, $lastCommandParameter); } if ($outgoingMessage->getStatus() != $this->_define::PROCESSED) @@ -605,6 +608,10 @@ private function handleConversationState($content, $senderId, $keyword = false) { $result = $this->listOrderDetailsFromOrderId($messageContent, $senderId); } + else if ($chatbotAPI->getConversationState() == $this->_define::CONVERSATION_SUPPORT) + { + $result = $this->getNoMessage(); + } // if ($result) // { @@ -1301,6 +1308,18 @@ private function setCurrentCommand($messageContent) } // GETS + private function getNoMessage() + { + $result = array(); + $responseMessage = array( + 'content_type' => $this->_define::NO_REPLY_MESSAGE, + 'content' => '', + 'current_command_details' => json_encode(array()) + ); + array_push($result, $responseMessage); + return $result; + } + private function getWelcomeMessage($message) { // $this->setHelperMessageAttributes($message); @@ -2356,8 +2375,9 @@ private function processSupportCommand() $result = array(); $responseMessage = array( 'content_type' => $this->_define::CONTENT_TEXT, - 'content' => 'The SUPPORT command is still under development', // TODO + 'content' => __("You're on support mode. In a few words, please explain what would you like help with. To cancel send '%1'.", $this->getCommandText($this->_define::CANCEL_COMMAND_ID)), 'current_command_details' => json_encode(array( + 'conversation_state' => $this->_define::CONVERSATION_SUPPORT, 'command_text' => $this->getCommandText($this->_define::SUPPORT_COMMAND_ID) )) ); diff --git a/Magento2/app/code/Werules/Chatbot/Helper/Define.php b/Magento2/app/code/Werules/Chatbot/Helper/Define.php index 91ac394..1011de5 100644 --- a/Magento2/app/code/Werules/Chatbot/Helper/Define.php +++ b/Magento2/app/code/Werules/Chatbot/Helper/Define.php @@ -80,6 +80,7 @@ class Define const RECEIPT_LAYOUT = 4; const LIST_WITH_IMAGE = 5; const TEXT_WITH_OPTIONS = 6; + const NO_REPLY_MESSAGE = 7; // conversation states const CONVERSATION_STARTED = 0; @@ -87,6 +88,7 @@ class Define const CONVERSATION_SEARCH = 2; const CONVERSATION_EMAIL = 3; const CONVERSATION_TRACK_ORDER = 4; + const CONVERSATION_SUPPORT = 5; // API const MAX_MESSAGE_ELEMENTS = 7; diff --git a/Magento2/app/code/Werules/Chatbot/Setup/UpgradeData.php b/Magento2/app/code/Werules/Chatbot/Setup/UpgradeData.php index f376e72..0dd61e3 100644 --- a/Magento2/app/code/Werules/Chatbot/Setup/UpgradeData.php +++ b/Magento2/app/code/Werules/Chatbot/Setup/UpgradeData.php @@ -36,7 +36,7 @@ public function upgrade( ModuleContextInterface $context ) { $setup->startSetup(); - if (version_compare($context->getVersion(), "1.0.3", "<")) { + if (version_compare($context->getVersion(), "1.0.4", "<")) { //Your upgrade script } $setup->endSetup(); diff --git a/Magento2/app/code/Werules/Chatbot/etc/adminhtml/system.xml b/Magento2/app/code/Werules/Chatbot/etc/adminhtml/system.xml index 0c6955d..ae71ada 100644 --- a/Magento2/app/code/Werules/Chatbot/etc/adminhtml/system.xml +++ b/Magento2/app/code/Werules/Chatbot/etc/adminhtml/system.xml @@ -11,7 +11,7 @@ Magento Chatbot v1.0.3 +

Magento Chatbot v1.0.4

To use this module you'll have to use SSL in your store.

]]>
@@ -67,7 +67,7 @@ Magento Chatbot v1.0.3 +

Magento Chatbot v1.0.4

To use this module you'll have to use SSL in your store.

]]>
@@ -227,7 +227,7 @@ Magento Chatbot v1.0.3 +

Magento Chatbot v1.0.4

To use this module you'll have to use SSL in your store.

You should only change settings here if you know what you're doing.