Dialogflow에서 Firebase로 Webhook
9479 단어 webhFirebasedialogflow

전회의 「우선은 Dialogflow를 만져 본다」의 대답을 Firebase에 시키는 방법입니다. htps : // 이 m / 사의 h / ms / 에 fd99 엣 b 데에 294 아 7 베 b3
■ 전달 API에는 V1과 V2가 있다
최근 V2를 릴리스 했으므로, V2 사용해라고 하는 일이라고 생각합니다, 이번은 V1과 V2 양쪽을 씁니다.

■ V1 API의 경우
・설정에서 「V1 API」가 되어 있는 것을 확인하고 나서 「SAVE」를 누릅니다.

· Firebase 설정
「Fulfilment」로 다른 서버 설정을 할 수 있습니다.
이번에는 Firebase를 사용하므로 "Inline Editor"를 "ENABLED"하십시오.

``index.js'' 프로그램은 다음과 같이 하고 마지막 ``DEPLOY''를 누르십시오 (배포될 때까지 잠시 걸립니다)
index.js
'use strict';
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
function foodApp (agent) {
var params = request.body.result.parameters;
var rFoods = params['foods'];
var rFeel = params['feel'];
agent.add('私も' + rFoods + 'は' + rFeel + 'です');
}
let actionMap = new Map();
actionMap.set('食べ物の好み!', foodApp);
agent.handleRequest(actionMap);
});
· Intent 설정
마지막으로 「음식의 취향!」의 Intent 설정에서 「Fulfillment」의 「Enable webhook call this intent」를 On으로 해 「SAVE」하면 종료입니다.

■ V2 API의 경우
・설정에서 「V2 API」가 되어 있는 것을 확인하고 나서 「SAVE」를 누릅니다.

· Firebase 설정
「Fulfilment」로 다른 서버 설정을 할 수 있습니다.
이번에는 Firebase를 사용하므로 "Inline Editor"를 "ENABLED"하십시오.

``index.js'' 프로그램은 다음과 같이 하고 마지막 ``DEPLOY''를 누르십시오 (배포될 때까지 잠시 걸립니다)
index.js
'use strict';
const functions = require('firebase-functions');
const { dialogflow } = require('actions-on-google');
const app = dialogflow();
app.intent('食べ物の好み!', (conv, params, confirmationGranted) => {
var rFoods = params['foods'];
var rFeel = params['feel'];
conv.ask('私も' + rFoods + 'は' + rFeel + 'です');
});
exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);
· Intent 설정
마지막으로 「음식의 취향!」의 Intent 설정에서 「Fulfillment」의 「Enable webhook call this intent」를 On으로 해 「SAVE」하면 종료입니다.

■ 동작
V1, V2에서도 같은 동작이 됩니다만, 향후의 일을 생각하면 V2 쪽인가요!

(Bot의 경우, V1이 아니면 동작이 수상하므로 요주의군요)
Reference
이 문제에 관하여(Dialogflow에서 Firebase로 Webhook), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/sanoh/items/f383a95df5babe08e98b텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)