選擇專案後,Firebase 工具會啟動函式設定
會詢問你要使用哪種語言。使用方向鍵選取
按下 Enter 鍵即可繼續操作。
=== Functions Setup A functions directory will be created in your project with a Node.js
package pre-configured. Functions can be deployed with firebase deploy.
? What language would you like to use to write Cloud Functions? (Use arrow keys)
> JavaScript
TypeScript
選擇是否要使用 ESLint 找出潛在錯誤並強制執行樣式
輸入 Y 或 N:
? Do you want to use ESLint to catch probable bugs and enforce style? (Y/n)
在提示中輸入 Y,以取得專案依附元件:
? Do you want to install dependencies with npm now? (Y/n)
設定完成後,您會看到類似下方的輸出內容:
✔ Firebase initialization complete!
安裝 actions-on-google 依附元件:
cd <cloud_function_dir>/functions
npm install actions-on-google
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2024-09-10 (世界標準時間)。"],[[["This guide explains how to deploy your Action's webhook fulfillment to a production environment, primarily focusing on Cloud Functions for Firebase."],["You need Node.js and the Firebase CLI installed and authenticated to deploy your fulfillment function to Firebase."],["The deployment process involves initializing Firebase within your Action project, selecting the desired language and configuration options, installing necessary dependencies, and finally deploying the function."],["After successful deployment, you'll receive a Function URL which needs to be connected to your Action in Dialogflow or declared in your Action package for Actions SDK."],["For quicker development iterations, consider using tools like ngrok to expose your local fulfillment to the internet, but exercise caution as this can introduce security vulnerabilities."]]],["To deploy a webhook to production, set up a hosting environment like Cloud Functions for Firebase. First, install Node.js and the Firebase CLI, then authenticate and initialize Firebase in your project directory. Choose `Functions` and your preferred language (JavaScript or TypeScript). Install dependencies, including `actions-on-google`. Deploy using `firebase deploy --only functions`. Finally, connect the webhook to your Action: in Dialogflow, enable the webhook and input the Function URL; in Actions SDK, declare the fulfillment within the `conversations` object of your Action package.\n"]]