创建项目和 Dialogflow 代理 (Dialogflow)
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
如需使用 Dialogflow 进行开发,您首先需要创建一个 Actions 项目和一个 Dialogflow 代理。创建项目后,您便可以访问开发者控制台以管理和分发您的 Action。Dialogflow 代理包含定义您的 Action 的所有 intent。
创建 Actions 项目和 Dialogflow 代理
- 转到 Actions 控制台。
- 点击 New project。
- 为你的项目输入名称,然后点击 Create Project。
- 向下滚动到更多选项部分,然后点击对话卡片。
- 点击顶部菜单中的 Develop,然后点击左侧菜单中的 Actions。
- 点击 Add Your First Action。
- 在自定义 intent 卡片上,点击构建。
- 此时将显示 Dialogflow 控制台,其中的信息自动填充到代理中。点击创建以保存代理。
Dialogflow 控制台
您现在应该会看到 Dialogflow 控制台和左侧的菜单面板。如果您使用的是小屏幕并且菜单处于隐藏状态,请点击左上角的 menu。
中央窗口显示代理的 intent 列表。默认情况下,Dialogflow 代理最初有两个意图。默认欢迎 intent 会问候用户。如果代理理解不了用户所说的内容,则会匹配“默认后备意图”。
Dialogflow 模拟器位于页面右侧。借助该模拟器,您可以说出或输入消息来试用代理。在 Dialogflow 模拟器中,点击 Try it now,输入任何内容,然后按 Enter 键。

图 1. 显示代理的 Dialogflow 控制台屏幕截图。
创建您的第一个 intent
Dialogflow 使用意图来对用户意图进行分类。意图具有训练短语,这些短语是用户可能对代理说出的内容示例。例如,如果用户想要知道代理的名称,可能会询问“您的姓名是什么?”,“你有名字吗?”或者直接说“姓名”。这些短语具有相同的最终目标:获取代理的名称。
如需创建用于处理这种情况的代理,请按以下步骤操作:
- 在导航菜单中,点击意图旁边的 add。
- 在意图名称 (Intent name) 文本字段中输入
Name
。
- 在训练短语 (Training 词组匹配) 部分中,点击添加训练短语 (Add Training 词组匹配)。
- 输入以下短语(在每个短语后按 Enter 键):
What is your name?
Do you have a name?
name
- 在响应 (Responses) 部分中,点击添加响应 (Add Response)。
- 在 Text Response 窗口中输入以下响应:
- 点击保存。
试试看

如需测试新的 Name intent,请在 Dialogflow 模拟器中输入“What's your name?”,然后按 Enter 键。
即使您提出的问题与训练短语并不完全相同,代理也可以正确回答您的问题(例如,“What's your name?”与“What is your name?”)。
Dialogflow 使用训练短语来训练机器学习模型,这有助于代理将用户话语与正确的意图相匹配。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):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."]]