對話動作已於 2023 年 6 月 13 日淘汰。詳情請參閱「
對話動作已淘汰」。
建立專案和 Dialogflow 代理程式 (Dialogflow)
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
如要透過 Dialogflow 進行開發,您必須先建立 Actions 專案和 Dialogflow 代理程式。擁有專案後,您就能存取開發人員控制台以管理及發布動作。Dialogflow 代理程式包含用來定義動作的所有意圖。
建立 Actions 專案和 Dialogflow 代理程式
- 前往動作控制台。
- 按一下 [新專案]。
- 輸入專案名稱,然後按一下「Create Project」(建立專案)。
- 向下捲動至「更多選項」部分,然後按一下「對話」資訊卡。
- 按一下頂端選單中的「開發」,然後點選左選單中的「動作」。
- 按一下「Add Your First Action」(新增第一個動作)。
- 在「自訂意圖」資訊卡上,按一下「建構」。
- Dialogflow 主控台會顯示自動填入的資訊。按一下「Create」(建立) 以儲存代理程式。
Dialogflow 主控台
您現在應該會看到 Dialogflow 控制台和左側的選單面板。如果您使用的螢幕較小,且選單已隱藏,請按一下左上角的 menu。
中間視窗會顯示代理程式的意圖清單。根據預設,Dialogflow 代理程式一開始會使用兩個意圖。預設歡迎意圖會歡迎使用者。如果代理程式無法理解使用者說的內容,系統就會比對「Default Fallback Intent」(預設備用意圖)。
Dialogflow 模擬工具位於頁面右側,您可以藉由語音或輸入訊息的方式試用代理程式。在 Dialogflow 模擬工具中,按一下「Try it now」(立即試用) 並輸入任何內容,然後按下 Enter 鍵。

圖 1. 顯示代理程式的 Dialogflow 控制台螢幕截圖。
建立您的第一個意圖
Dialogflow 會使用意圖將使用者意圖分類。意圖包含訓練詞組,這是使用者可能會向代理程式說的內容範例。舉例來說,如果使用者想知道代理程式的名稱,可能會問:「What is your name?」(你叫什麼名字?)「你是否有名稱?」,或說「名字」這些詞組具有相同的最終目標:取得代理程式的名稱。
如要建立處理這個案例的代理程式,請按照下列步驟操作:
- 在導覽選單中,按一下「Intents」(意圖) 旁的 add。
- 在「Intent name」(意圖名稱) 文字欄位中輸入
Name
。
- 在「訓練詞組」部分,按一下「新增訓練詞組」。
- 輸入下列詞組 (每輸入一個詞組後就按下 Enter 鍵):
What is your name?
Do you have a name?
name
- 在「回應」部分,按一下「新增回應」。
- 在「Text Response」視窗中輸入以下回應:
- 點按「儲存」。
立即體驗

如要測試新的「Name」意圖,請在 Dialogflow 模擬工具中輸入「What's your name?」,然後按下 Enter 鍵。
即使您提出的問題與訓練詞組不同 (例如「您的姓名是什麼?」和「您的姓名是什麼?」),代理程式仍可正確回應問題。
Dialogflow 使用訓練詞組訓練機器學習模型,這有助於代理程式將使用者語音和正確的意圖進行比對。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[[["\u003cp\u003eTo begin developing with Dialogflow, you need to set up an Actions project and a Dialogflow agent using the Actions console.\u003c/p\u003e\n"],["\u003cp\u003eDialogflow utilizes intents, containing training phrases and responses, to understand and respond to user requests.\u003c/p\u003e\n"],["\u003cp\u003eYou can test your Dialogflow agent using the built-in simulator by typing or speaking messages.\u003c/p\u003e\n"],["\u003cp\u003eDialogflow employs machine learning to match user input to the appropriate intents, even if the phrasing differs slightly from training phrases.\u003c/p\u003e\n"]]],[],null,["# Create a project and Dialogflow agent (Dialogflow)\n\nTo develop with Dialogflow, you first need to create an Actions project and a\nDialogflow agent. Having a project allows you to access the developer console to\nmanage and distribute your Action. The Dialogflow agent contains all the intents\nthat define your Action.\n| **Note:** When creating a new project, Actions on Google enables [Firebase](//firebase.google.com/), Google's developer platform that provides a number of services for app developers. Relative terms of service information can be found in the [Actions on Google Terms Explanation](/assistant/console/policies/terms-explanation).\n\nCreate an Actions project and Dialogflow agent\n----------------------------------------------\n\n1. Go to the [Actions console](//console.actions.google.com/).\n2. Click **New project**.\n3. Enter a name for your project and click **Create Project** .\n4. Scroll down to the **More options** section and click on the **Conversational** card.\n5. Click **Develop** in the top menu, then click **Actions** in the left menu.\n6. Click **Add Your First Action**.\n7. On the **Custom intent** card, click **Build**.\n8. The Dialogflow console appears with the information automatically populated in an agent. Click **Create** to save the agent.\n\nThe Dialogflow console\n----------------------\n\nYou should now see the Dialogflow console and the menu panel on the left. If\nyou're on a small screen and the menu is hidden, click\n*menu* in the upper left corner.\n\nThe center window shows the list of intents for the agent. By default,\nDialogflow agents start with two intents. The *Default Welcome Intent* greets\nyour users. Your agent matches the *Default Fallback Intent* when it doesn't\nunderstand what the users say.\n\nThe Dialogflow simulator is on the right side of the page. The simulator lets\nyou try out your agent by speaking or typing messages. In the Dialogflow\nsimulator, click **Try it now**, type anything, and press enter.\n\n**Figure 1**. A screenshot of the Dialogflow console showing an agent.\n\nCreate your first intent\n------------------------\n\nDialogflow uses intents to categorize a user's intentions. Intents have\n*Training Phrases*, which are examples of what a user might say to your agent.\nFor instance, a user who wants to know your agent's name might ask, \"What is\nyour name?\", \"Do you have a name?\", or simply say \"name\". These phrases have the\nsame end goal: to get the name of your agent.\n\nTo create an agent that handles this case, follow these steps:\n\n1. Click *add* next to **Intents** in the navigation menu.\n2. Enter `Name` in the **Intent name** text field.\n3. In the **Training Phrases** section, click **Add Training Phrases**.\n4. Enter the following phrases (press enter after each phrase):\n - `What is your name?`\n - `Do you have a name?`\n - `name`\n5. In the **Responses** section, click **Add Response**.\n6. Enter the following response in the **Text Response** window:\n - `My name is Dialogflow!`\n7. Click **Save**.\n\nTry it out\n----------\n\nTo test your new *Name* intent, in the Dialogflow simulator, type \"What's\nyour name?\" and press enter.\n\nYour agent can respond to your question correctly even when you ask questions\nthat aren't exactly the same as the training phrases (for example, \"What's your\nname?\" versus \"What is your name?\").\n\nDialogflow uses training phrases to train a machine learning model, which helps\nthe agent match user utterances to the correct intents."]]