Я использую обработчик тестирования для вызова намерения 'test' для тестирования полного заполнения webhook.
'use strict';
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
function welcome(agent) {
agent.add(`Welcome to my agent!`);
}
function testing(agent){
agent.add(`testing works`);
}
function fallback(agent) {
agent.add(`I didn't understand`);
agent.add(`I'm sorry, can you try again?`);
}
// Run the proper function handler based on the matched Dialogflow intent name
let intentMap = new Map();
intentMap.set('Default Welcome Intent', welcome);
intentMap.set('Default Fallback Intent', fallback);
intentMap.set('test',testing); //testing handler
// intentMap.set('your intent name here', googleAssistantHandler);
agent.handleRequest(intentMap);
});
Но при развертывании я получил эту ошибку
Webhook call failed. Error: UNKNOWN
Ответ
{
"responseId": "5dd7232c-e92e-4039-bbc6-9e9bf826bb3e-b4ef8d5f",
"queryResult": {
"queryText": "hey i am testing",
"parameters": {},
"allRequiredParamsPresent": true,
"fulfillmentMessages": [
{
"text": {
"text": [
""
]
}
}
],
"outputContexts": [
{
"name": "projects/smart-library-55e4d/agent/sessions/4bd5533e-0465-02e4-45d3-1bd3383b21d5/contexts/__system_counters__",
"parameters": {
"no-input": 0,
"no-match": 0
}
}
],
"intent": {
"name": "projects/smart-library-55e4d/agent/intents/0eadac8a-c487-4f7e-92ce-18e64f113e3c",
"displayName": "test"
},
"intentDetectionConfidence": 1,
"languageCode": "en"
},
"originalDetectIntentRequest": {
"payload": {}
},
"session": "projects/smart-library-55e4d/agent/sessions/4bd5533e-0465-02e4-45d3-1bd3383b21d5"
}