diff --git a/app/Constants.php b/app/Constants.php index c7d5ccd45a..07d1e750db 100644 --- a/app/Constants.php +++ b/app/Constants.php @@ -321,7 +321,7 @@ if (! defined('APP_NAME')) { define('FIREFOX_PDF_HELP_URL', 'https://support.mozilla.org/en-US/kb/view-pdf-files-firefox'); define('MSBOT_LOGIN_URL', 'https://login.microsoftonline.com/common/oauth2/v2.0/token'); - define('MSBOT_LUIS_URL', 'https://api.projectoxford.ai/luis/v1/application'); + define('MSBOT_LUIS_URL', 'https://westus.api.cognitive.microsoft.com/luis/v2.0/apps'); define('SKYPE_API_URL', 'https://apis.skype.com/v3'); define('MSBOT_STATE_URL', 'https://state.botframework.com/v3'); diff --git a/app/Http/Controllers/BotController.php b/app/Http/Controllers/BotController.php index 7596884192..1bd9be85bc 100644 --- a/app/Http/Controllers/BotController.php +++ b/app/Http/Controllers/BotController.php @@ -100,6 +100,7 @@ class BotController extends Controller public function handleCommand() { $data = $this->parseMessage(request()->command); + //dd($data); $intent = BaseIntent::createIntent(BOT_PLATFORM_WEB_APP, false, $data); return $intent->process(); } @@ -153,7 +154,8 @@ class BotController extends Controller $subKey = env('MSBOT_LUIS_SUBSCRIPTION_KEY'); $message = rawurlencode($message); - $url = sprintf('%s?id=%s&subscription-key=%s&q=%s', MSBOT_LUIS_URL, $appId, $subKey, $message); + $url = sprintf('%s/%s?subscription-key=%s&verbose=true&q=%s', MSBOT_LUIS_URL, $appId, $subKey, $message); + //$url = sprintf('%s?id=%s&subscription-key=%s&q=%s', MSBOT_LUIS_URL, $appId, $subKey, $message); $data = file_get_contents($url); $data = json_decode($data); diff --git a/app/Ninja/Intents/BaseIntent.php b/app/Ninja/Intents/BaseIntent.php index 7693627eb8..4c170bba73 100644 --- a/app/Ninja/Intents/BaseIntent.php +++ b/app/Ninja/Intents/BaseIntent.php @@ -51,7 +51,7 @@ class BaseIntent if ($state && ! $entityType) { $entityType = $state->current->entityType; } - + $entityType = $entityType ?: 'client'; $entityType = ucwords(strtolower($entityType)); if ($entityType == 'Recurring') { $entityType = 'RecurringInvoice'; diff --git a/app/Ninja/Intents/WebApp/FindClientIntent.php b/app/Ninja/Intents/WebApp/FindClientIntent.php new file mode 100644 index 0000000000..baa4381939 --- /dev/null +++ b/app/Ninja/Intents/WebApp/FindClientIntent.php @@ -0,0 +1,17 @@ +requestClient(); + + $url = $client ? $client->present()->url : '/clients'; + + return redirect($url); + } +} diff --git a/app/Ninja/Intents/WebApp/FindInvoiceIntent.php b/app/Ninja/Intents/WebApp/FindInvoiceIntent.php new file mode 100644 index 0000000000..158cdd0234 --- /dev/null +++ b/app/Ninja/Intents/WebApp/FindInvoiceIntent.php @@ -0,0 +1,17 @@ +requestInvoice(); + + $url = $invoice ? $invoice->present()->url : '/invoices'; + + return redirect($url); + } +} diff --git a/app/Ninja/Intents/WebApp/FindQuoteIntent.php b/app/Ninja/Intents/WebApp/FindQuoteIntent.php new file mode 100644 index 0000000000..0222c15ddd --- /dev/null +++ b/app/Ninja/Intents/WebApp/FindQuoteIntent.php @@ -0,0 +1,17 @@ +requestInvoice(); + + $url = $invoice ? $invoice->present()->url : '/quotes'; + + return redirect($url); + } +} diff --git a/app/Ninja/Intents/WebApp/ListCreditIntent.php b/app/Ninja/Intents/WebApp/ListCreditIntent.php index 0beb440e55..b4f9412cf3 100644 --- a/app/Ninja/Intents/WebApp/ListCreditIntent.php +++ b/app/Ninja/Intents/WebApp/ListCreditIntent.php @@ -8,6 +8,12 @@ class ListCreditIntent extends BaseIntent { public function process() { - return redirect('/credits'); + if ($client = $this->requestClient()) { + $url = $client->present()->url . '#credits'; + } else { + $url = '/credits'; + } + + return redirect($url); } } diff --git a/app/Ninja/Intents/WebApp/ListInvoiceIntent.php b/app/Ninja/Intents/WebApp/ListInvoiceIntent.php index 7cf31d3b4c..477258f94f 100644 --- a/app/Ninja/Intents/WebApp/ListInvoiceIntent.php +++ b/app/Ninja/Intents/WebApp/ListInvoiceIntent.php @@ -8,6 +8,12 @@ class ListInvoiceIntent extends InvoiceIntent { public function process() { - return redirect('/invoices'); + if ($client = $this->requestClient()) { + $url = $client->present()->url . '#invoices'; + } else { + $url = '/invoices'; + } + + return redirect($url); } } diff --git a/app/Ninja/Intents/WebApp/ListPaymentIntent.php b/app/Ninja/Intents/WebApp/ListPaymentIntent.php index 94456df19c..40f2f3688e 100644 --- a/app/Ninja/Intents/WebApp/ListPaymentIntent.php +++ b/app/Ninja/Intents/WebApp/ListPaymentIntent.php @@ -8,6 +8,12 @@ class ListPaymentIntent extends BaseIntent { public function process() { - return redirect('/payments'); + if ($client = $this->requestClient()) { + $url = $client->present()->url . '#payments'; + } else { + $url = '/payments'; + } + + return redirect($url); } } diff --git a/app/Ninja/Intents/WebApp/ListQuoteIntent.php b/app/Ninja/Intents/WebApp/ListQuoteIntent.php index 66887cf73b..76bae43d05 100644 --- a/app/Ninja/Intents/WebApp/ListQuoteIntent.php +++ b/app/Ninja/Intents/WebApp/ListQuoteIntent.php @@ -8,6 +8,12 @@ class ListQuotesIntent extends BaseIntent { public function process() { - return redirect('/quotes'); + if ($client = $this->requestClient()) { + $url = $client->present()->url . '#quotes'; + } else { + $url = '/quotes'; + } + + return redirect($url); } } diff --git a/app/Ninja/Intents/WebApp/ListRecurringInvoiceIntent.php b/app/Ninja/Intents/WebApp/ListRecurringInvoiceIntent.php index cf98df5ee6..d0233c6db7 100644 --- a/app/Ninja/Intents/WebApp/ListRecurringInvoiceIntent.php +++ b/app/Ninja/Intents/WebApp/ListRecurringInvoiceIntent.php @@ -8,6 +8,12 @@ class ListRecurringInvoiceIntent extends BaseIntent { public function process() { - return redirect('/recurring_invoices'); + if ($client = $this->requestClient()) { + $url = $client->present()->url . '#recurring_invoices'; + } else { + $url = '/recurring_invoices'; + } + + return redirect($url); } } diff --git a/app/Ninja/Intents/WebApp/ListTaskIntent.php b/app/Ninja/Intents/WebApp/ListTaskIntent.php index 41e1a4fc60..f8c68626cd 100644 --- a/app/Ninja/Intents/WebApp/ListTaskIntent.php +++ b/app/Ninja/Intents/WebApp/ListTaskIntent.php @@ -8,6 +8,12 @@ class ListTaskIntent extends BaseIntent { public function process() { - return redirect('/tasks'); + if ($client = $this->requestClient()) { + $url = $client->present()->url . '#tasks'; + } else { + $url = '/tasks'; + } + + return redirect($url); } } diff --git a/resources/views/partials/speech_recognition.blade.php b/resources/views/partials/speech_recognition.blade.php index cfb63f7b34..bc3ffeaca4 100644 --- a/resources/views/partials/speech_recognition.blade.php +++ b/resources/views/partials/speech_recognition.blade.php @@ -172,9 +172,8 @@ } function onMicrophoneClick() { - $('#search').val('new payment for invoice 1279'); - //$('#search').val('invoice for edgar'); - //$('#search').val('create a task for edgar'); + //$('#search').val("show me all of edgar's credits"); + $('#search').val("show me edgar's credits"); $('#search-form').submit(); return;