1

Google Assistant 용 AWS Lambda에서 fullfilment를 설정하려고합니다. actions-on-google npm 패키지를 사용하고 있습니다. ApiAiApp({req,res}을 만들려면 http 요청 및 응답 개체가 필요합니다.AWS Lambda에서 ApiAi 노드 앱 실행

exports.handler = function(event, context, callback) { 
    const apiAiApp = new ApiAiApp({req:<REQUEST>, res:<RESPONSE>}); 
} 

어떻게 <REQUEST><RESPONSE>받는 event, context, callback 번역 않습니다

그러나, 람다 콜백은 다른 매개 변수 세트를 제공?

저도 같은 문제에 직면했다

+0

AoG 클라이언트 라이브러리는'express' Node.JS 객체를 사용합니다. 람다 (Lambda)를 사용하려면, 번역을위한 가이드를 찾아야 할 수도 있습니다. –

답변

1

(내가 여기 문맥을 필요 믿지 않는)은, 마침내 나는 간단한 프록시를 생성하는 몇 가지 코드를 제공하는 프로젝트 "claudia.js"를 통해 그것을 해결하는 AWS Lambda에서 특급 앱을 호스팅 할 수 있습니다. https://github.com/claudiajs/example-projects/tree/master/express-app-lambda

https://claudiajs.com/tutorials/serverless-express.html

힌트 : 당신은 두 개의 "애플 리케이션"와 끝까지, 예를 들어, Dialogflow에서 fullfillment의 firebase 예제를 사용하는 경우 충돌을 피하기 위해 Dialogflow의 이름을 바꿔야합니다.

'use strict'; 

const googleAssistantRequest = 'google'; // Constant to identify Google Assistant requests 
const express = require('express'); 
const app = express(); 
const DialogflowApp = require('actions-on-google').DialogflowApp; // Google Assistant helper library 
const bodyParser = require('body-parser'); 
var endpoint = "..."; // name of AWS endpoint aka as "Resource path" in API Gateway Trigger setup 

... 

const urlencodedParser = bodyParser.json({ extended: false }); 
app.post('/'+ endpoint, urlencodedParser, (request, response) => { 
    console.log('Request headers: ' + JSON.stringify(request.headers)); 
    console.log('Request body: ' + JSON.stringify(request.body)); 

    // An action is a string used to identify what needs to be done in fulfillment 
    let action = request.body.result.action; // https://dialogflow.com/docs/actions-and-parameters 


    ... 

    const appDialogFlow = new DialogflowApp({request: request, response: response}); 

    // Create handlers for Dialogflow actions as well as a 'default' handler 
    const actionHandlers = { 
     ... 
    }; 

    ... 
    // If undefined or unknown action use the default handler 
    if (!actionHandlers[action]) { 
     action = 'default'; 
    } 

    // Run the proper handler function to handle the request from Dialogflow 
    actionHandlers[action](); 

    ... some helper functions, etc ... 

}); 

//app.listen(3000) // <-- comment this line out from your app 
module.exports = app; // <-- link to the proxy that is created viy claudia.js