2024年如何创建Google Assistant简易“Hello World” Action?
核心背景说明
由于Google Assistant对话Actions(Conversational Actions)已于2023年6月13日停用,当前自定义交互Action需通过Actions Builder的Custom类型创建,而非旧教程中的Dialogflow或其他已弃用入口。以下是针对你遇到的"仅显示Smart home类型"问题的解决步骤:
具体操作步骤
进入正确的项目创建流程
打开Actions Console后,创建新项目(或打开空白项目),确保进入项目的Develop模块,点击左侧菜单栏的Actions选项进入Action创建页。找到Custom类型入口
点击Create action按钮后,若仅显示Smart home类型,需点击界面中的See more(或类似"查看更多类型"的选项),选择Custom类型,再选择Build using Actions Builder进入编辑器。创建触发Intent
在Actions Builder中,新建一个Intent(如命名为HelloIntent):- 在
Training phrases中添加触发语,例如hello、say hello、hi; - 确保Intent的触发条件设置为匹配这些短语。
- 在
配置回复逻辑
在Intent的Fulfillment部分,选择Inline code,输入以下极简回复代码:return { "session": { "id": request.session.id, "params": {} }, "prompt": { "firstSimple": { "speech": "Hello World! This is your first Google Assistant Action.", "text": "Hello World! This is your first Google Assistant Action." } }, "scene": { "name": "HelloScene", "next": { "name": "actions.scene.END_CONVERSATION" } } };设置Invocation名称
进入左侧菜单栏的Invocation页面,设置一个触发名称(如my hello action),用户可通过语音指令Hey Google, talk to my hello action触发你的Action。测试验证
点击右上角的Test按钮,在模拟器中输入或说出触发词,即可收到"Hello World"的回复。
额外注意事项
- 若仍无法找到Custom类型,建议新建一个全新项目尝试(旧项目可能因历史配置限制显示内容);
- 当前Google Assistant自定义交互仅支持Actions Builder或Actions SDK,Dialogflow已不再用于Assistant Action开发;
- 检查账号权限与所在区域,部分受限区域可能无法使用全部功能。
内容的提问来源于stack exchange,提问作者Sandro Henriques

