2017-11-29 6 views
5

대화 흐름에서 webhook을 호출하려고하는데 webhook에서 응답을받지 못하고 있습니다. 응답 섹션에서 응답을 얻고 있습니다. 의도를 넣었다. 필자는 또한 각 인 텐트에 대해 webhook을 활성화했으며 firehill CLI에서 충족 URL 섹션에 생성 된 webhook 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

내가 넣어 깜빡 때문에 난 그냥이 동일한 오류로 실행하고 발생 된 내 의도는 Enter action name 필드의 Actions 섹션에 있습니다.

따라서 지정하지 않았으므로 null을 의도 이름으로 전달했습니다.

나는 매우 조심스럽게 https://developers.google.com/actions/dialogflow/first-app를 다시 읽어 하여 알아 냈어.

+1

답장을 보내 주셔서 감사합니다.하지만 작업 섹션에 작업 이름을 입력했습니다. 다음은 내 의도의 스크린 샷 링크입니다. imgur.com/a/NcM4z –

1

귀하의 소중한 답변에 감사드립니다. 어쨌든,이 null 오류를 수정할 수 있습니다. 사실, 저는 Agent의 API 버전 섹션에서 "Dialogflow V2 API"를 활성화 시켰습니다. 지금, 나는 그것을 무능하게했고 그것은 나를 위해 일한다.