2017-11-03 6 views
1

私はアクションSDNで遊んでいましたが、それは私の主な目的のためだけに機能するようです。私は2番目の意図を追加し、それは決して誘発しません。ここでGoogleのアシスタントで2回目の操作を開始できません

は私action.jsonです:

{ 
    "actions": [ 
    { 
     "description": "Default Welcome Intent", 
     "name": "MAIN", 
     "fulfillment": { 
     "conversationName": "conversation_1" 
     }, 
     "intent": { 
     "name": "actions.intent.MAIN" 
     } 
    }, 
    { 
     "name": "add", 
     "intent": { 
     "name": "myintent.ADD", 
     "parameters": [ 
      { 
      "name": "somenumber", 
      "type": "SchemaOrg_Number" 
      } 
     ], 
     "trigger": { 
      "queryPatterns": [ 
      "add $SchemaOrg_Number:somenumber", 
      "add" 
      ] 
     } 
     }, 
     "fulfillment": { 
     "conversationName": "add" 
     } 
    } 
    ], 
    "conversations": { 
    "conversation_1": { 
     "name": "conversation_1", 
     "url": "https://myaddress/sayNumber", 
     "fulfillmentApiVersion": 2 
    }, 
    "add": { 
     "name": "add", 
     "url": "https://myaddress/sayNumber", 
     "fulfillmentApiVersion": 2 
    } 
    } 
} 

そして、ここでは私のindex.jsです:

'use strict'; 

process.env.DEBUG = 'actions-on-google:*'; 

const ActionsSdkApp = require('actions-on-google').ActionsSdkApp; 
const functions = require('firebase-functions'); 

const NO_INPUTS = [ 
    'I didn\'t hear that.', 
    'If you\'re still there, say that again.', 
    'We can stop here. See you soon.' 
]; 

exports.sayNumber = functions.https.onRequest((request, response) => { 
    const app = new ActionsSdkApp({request, response}); 

    function mainIntent (app) { 
    console.log('mainIntent'); 
    let inputPrompt = app.buildInputPrompt(true, '<speak>Hi! <break time="1"/> ' + 
     'I can read out an ordinal like ' + 
     '<say-as interpret-as="ordinal">123</say-as>. Say a number.</speak>', NO_INPUTS); 
    app.ask(inputPrompt); 
    } 
function addIntent (app) { 
    console.log('addIntent'); 
    let inputPrompt = app.buildInputPrompt(true, '<speak>Hi! <break time="1"/> ' + 
     'I can add.</speak>', NO_INPUTS); 
    app.ask(inputPrompt); 
    } 
    function rawInput (app) { 
    console.log('rawInput'); 
    if (app.getRawInput() === 'bye') { 
     app.tell('Goodbye!'); 
    } else { 
     let inputPrompt = app.buildInputPrompt(true, '<speak>You said, <say-as interpret-as="ordinal">' + 
     app.getRawInput() + '</say-as>'+app.getIntent()+'</speak>', NO_INPUTS); 
     app.ask(inputPrompt); 
    } 
    } 

    let actionMap = new Map(); 
    actionMap.set(app.StandardIntents.MAIN, mainIntent); 
    actionMap.set(app.StandardIntents.TEXT, rawInput); 
    actionMap.set("myintent.ADD", addIntent); 

    app.handleRequest(actionMap); 
}); 

私はその後、私が言うすべてをしても、生の入力として扱われます、その後talk to my action nameを言うことができaddのキーワードを使用すると私は間違って何をしていますか?

答えて

1

これは間違いありません。 actions.jsonパッケージは、ユーザーがあなたの行動にどのようにstart a conversationできるかを定義します。 Once the conversation has started、あなたはTEXT(またはOPTION)インテントを渡され、自然言語処理を処理することが期待されます。追加のインテントはspeech biasingに使用できますが、レスポンスの解析には使用されません。

これは、他の音声エージェントが言語解析を処理する方法とは異なります。アクションSDKは、あなた自身のNLPを既に持っている場合に、主に意図されています。

そうでない場合は、DialogflowやConverse.AIなどを使用する方がよいでしょう。

+1

この情報はありがとうございます。私はDialogflowを探していますが、これは私がやりたいことのより良い一致のようです。 – casolorz

関連する問題