1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Working on speech rec

This commit is contained in:
Hillel Coren 2017-04-05 18:04:44 +03:00
parent 4abb5dd2c5
commit f8b5f179a8
13 changed files with 100 additions and 12 deletions

View File

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

View File

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

View File

@ -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';

View File

@ -0,0 +1,17 @@
<?php
namespace App\Ninja\Intents\WebApp;
use App\Ninja\Intents\BaseIntent;
class FindClientIntent extends BaseIntent
{
public function process()
{
$client = $this->requestClient();
$url = $client ? $client->present()->url : '/clients';
return redirect($url);
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace App\Ninja\Intents\WebApp;
use App\Ninja\Intents\InvoiceIntent;
class FindInvoiceIntent extends InvoiceIntent
{
public function process()
{
$invoice = $this->requestInvoice();
$url = $invoice ? $invoice->present()->url : '/invoices';
return redirect($url);
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace App\Ninja\Intents\WebApp;
use App\Ninja\Intents\InvoiceIntent;
class FindQuoteIntent extends InvoiceIntent
{
public function process()
{
$invoice = $this->requestInvoice();
$url = $invoice ? $invoice->present()->url : '/quotes';
return redirect($url);
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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