2017-11-29 14 views
5

ダイアログフローからwebhookを呼び出そうとしていますが、webhookからレスポンスを得ようとしていません。意図を入れている。また、各インテントのWebhookを有効にし、firehill CLIから生成されたwebhook URLをフルフィルメントURLセクションに配置しました。 FirebaseのログとJSONレスポンスのスクリーンショットを添付しています。これはダイアログのフロー "show JSON"とindex.jsファイルにも表示されています。解決するのに2週間頑張っています。エラーが発生しましたwebhook URLにアクセス中に「アクションエラー:一致するインテントハンドラがありません:null」

'use strict'; 
 

 
process.env.DEBUG = 'actions-on-google:*'; 
 
const { DialogflowApp } = require('actions-on-google'); 
 
const functions = require('firebase-functions'); 
 
let express = require('express'); 
 
let bodyParser = require('body-parser'); 
 

 
// Constants for Dialogflow Agent Actions 
 
let app = express(); 
 
app.use(bodyParser.urlencoded({ extended: true })); 
 
app.use(bodyParser.json({type: 'application/json'})); 
 

 
const BYE_RESPONSE = 'input.search'; 
 
const WELCOME = 'input.welcome'; 
 

 
exports.helloAssistant = functions.https.onRequest((req, res) => { 
 
    console.log('Request headers: ' + JSON.stringify(req.headers)); 
 
    console.log('Request body: ' + JSON.stringify(req.body)); 
 
    const asst = new DialogflowApp({request: req, response: res}); 
 

 

 
    // Welcome 
 
    function welcome(asst) { 
 
    asst.ask('Want to search product or order history'); 
 
    asst.tell('hello Neeraj!'); 
 
    } 
 

 
    // Leave conversation with SimpleResponse 
 

 
    function byeResponse (asst) { 
 
    app.post('/',function (req, res) { 
 
     var myProduct = req.body.result.parameters["productParameter"]; 
 
     //let intent=asst.getIntent(); 
 
     var address ="https://ipadress/rest/v2/electronics/products/search"; 
 
     var address1="https://ipadress"; 
 
     switch(myProduct){ 
 
     case 'BYE_RESPONSE': 
 
      req.post(address); 
 
      break; 
 

 
     case 'WELCOME': 
 
      asst.tell('welcome!'); 
 
      break; 
 

 
     default: 
 
      req.post(address1); 
 
      break; 
 
     } 
 

 
     asst.tell('We swear to serve the master of the Precious.'); 
 
    }); 
 
    } 
 

 
    const actionMap = new Map(); 
 
    actionMap.set(WELCOME, welcome); 
 

 
    actionMap.set(BYE_RESPONSE, byeResponse); 
 
    actionMap.set(WELCOME, welcome); 
 
    asst.handleRequest(actionMap); 
 
});

json response in dialogflow

firebase log

+0

input.searchのスクリーンショットを追加できますか?Intentとinput.welcome Dialogflowからのインテント? – Prisoner

+0

ここに私の意図の画像URLです –

+0

ここにはDialogflowからの私の意図の画像URLです。 1. https://imgur.com/a/NcM4z 2. https://imgur.com/a/NcM4z 3.https://imgur.com/a/NcM4z 4. https://imgur.com/a/NcM4z –

答えて

0

は、すべてのエージェントの場合、NULLなど不測の事態を処理するためのunknownテントハンドラがあることが必要など

'input.unknown':() => { 
    // The default fallback intent has been matched, try to recover. 
    // Define the response users will hear 
    responseJson.speech = 'I\'m having trouble, can you try that again?'; 
    // Define the response users will see 
    responseJson.displayText = 'I\'m having trouble :-/ can you try that again?'; 
    // Send the response to API.AI 
    // response.json(responseJson); 
    callback(null, responseJson); 
} 
+1

スクリプトに「input.unknown」を追加しましたが、同じエラーが発生しません。 –

4

私は置くことを忘れてしまったので、私はちょうどこれと同じエラーに遭遇し、それが発生しましたActionsセクションのEnter action nameフィールドに私の意図の名前。

したがって、指定しなかったので、nullをインテント名として渡していました。

私は再読み込みhttps://developers.google.com/actions/dialogflow/first-app非常に慎重にによってそれを考え出しました。

+1

ご返信ありがとうございますが、私はアクションセクションにアクション名を記入しています。ここに私の意図のスクリーンショットのリンクがあります。 imgur.com/a/NcM4z –

1

あなたの貴重なご回答ありがとうございます。何とか、私はこのnullエラーを修正することができます。実際には、エージェントのAPIバージョンセクションで "Dialogflow V2 API"を有効にしました。今、私はそれを無効にして、それは私のために働く。

関連する問題