我直接解擇這個架構好了
- serverless.yml 這個就serverless 的設定,得配合我開在AWS 上的 mongo cluster ,才能讓 aws lambda 存取。http://wolke-codes.blogspot.tw/2018/01/serverless-aws-lambda-aws-mongodb.html
- bot/bot.ts bot 的流程... 可以參考我在IT鐵人的不負責任教學:https://ithelp.ithome.com.tw/users/20046160/ironman/1510
- handler.js :這個是serverless 的預設的 function 定義的地方。
'use strict'; var config = require("./conf");//讀取你的設定 var bot_dailog = require("./bot/bot")//將bot 流程 require 進來。 var botbuilder_linebot_connector_1 = require("botbuilder-linebot-connector"); var botbuilder_mongodb_storage_1 = require("botbuilder-mongodb-storage"); var builder = require('botbuilder'); var connector = new botbuilder_linebot_connector_1.LineConnector({ hasPushApi: false, // your line channelId: process.env.channelId || config.channelId, channelSecret: process.env.channelSecret || config.channelSecret, channelAccessToken: process.env.channelAccessToken || config.channelAccessToken });//產生connector
const response = { statusCode: 200, body: JSON.stringify({ message: 'Go Serverless v1.0! Your function executed successfully!', input: event, }), }; callback(null, response); // Use this code if you don't use the http event with the LAMBDA-PROXY integration // callback(null, { message: 'Go Serverless v1.0! Your function executed successfully!', event }); };
沒有留言:
張貼留言