Storage
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
为了更好地自定义用户的 Action 体验,您可以在两轮对话之间或与该用户的多个对话之间保存数据。保存的数据可以在单个对话中提供有用的重新提示、存储不同会话的游戏得分,或为用户记住小段信息。
数据可以在对话期间以多种方式存储。在单个对话中,您可以使用类型为意图中的训练短语添加注释,或在槽填充期间存储用户的信息。
您还可以通过以下存储方法使用网络钩子,让 Action 存储值:
您可以结合使用这些存储方法,以尽量符合您希望在 Action 调用之间或调用之间保留信息的方式。
会话存储空间
如果您希望保留单个对话的值,而不是在不同对话之间保留值,请使用会话存储。在对话期间,使用 types 收集的任何数据都会存储在会话存储空间中。
用户存储空间
如果要为单个已验证用户的跨会话保留值,请使用用户存储空间。例如,游戏可以将用户的最高得分保存在用户存储空间中,并在用户每次发起新对话时在欢迎消息中显示最高得分。
家庭存储空间
如果您想在单个家庭设备的各对话中保留某个值(基于 Home Graph),请使用“家庭存储空间”。住宅存储空间并非特定于任何特定用户,因此家庭中的任何用户都可以使用存储空间。使用家庭存储空间时,Google 还会向经过验证的用户以及访客用户每次调用时显示一次通知(每 10 分钟最多显示一次)。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eActions on Google can save data to customize user experiences, enabling features like reprompts and storing information across conversations.\u003c/p\u003e\n"],["\u003cp\u003eData can be saved within a single conversation using types or across conversations with session, user, or home storage, depending on the desired persistence.\u003c/p\u003e\n"],["\u003cp\u003eSession storage retains data for a single conversation, user storage saves data for a specific user across conversations, and home storage persists data for all users on devices in a household.\u003c/p\u003e\n"]]],["Data in user interactions can be saved within single or multiple conversations to enhance user experience. Data can be stored through types in intents or via webhook storage methods: session storage for single conversation data, user storage for data across conversations of a specific user, and home storage for data across conversations for all users in a household. These methods can be used in conjunction to manage how information persists.\n"],null,["# Storage\n\nTo better customize a user's experience with your Action, you can save data\nbetween turns of a conversation or across multiple conversations with that user.\nSaved data can provide helpful reprompts in a single conversation, store game\nscores across sessions, or remember small pieces of information for a user.\n\nData can be stored in multiple ways during a conversation. In a single\nconversation, you can use [types](/assistant/conversational/types) to annotate training phrases in intents or\nto store information from the user during slot filling.\n\nYou can also have your Action store values using your webhook with the following\nstorage methods:\n\n- Session storage\n- User storage\n- Home storage\n\nUse these storage methods in combination with each other to best match how you\nwant to persist information within or between invocations of your Action.\n\nSession storage\n---------------\n\nUse [session storage](/assistant/conversational/storage-session) when you want to persist a value for a single\nconversation, but not from one conversation to another. During a conversation,\nany data collected using [types](/assistant/conversational/types) is stored in session storage.\n\nUser storage\n------------\n\nUse [user storage](/assistant/conversational/storage-user) when you want to persist a value across conversations for a\nsingle verified user. For example, a game can save a user's high score in user\nstorage and present the high score in the welcome message each time the user\nstarts a new conversation.\n\nHome storage\n------------\n\nUse [home storage](/assistant/conversational/storage-home) when you want to persist a value across conversations for\ndevices in a single household (based on [Home Graph](/assistant/smarthome/concepts/homegraph)). Home storage isn't\nspecific to any particular user, so any user in the household can contribute\ntowards it. When using home storage, Google additionally presents a notification\nonce to verified users, and on each invocation by guest users (up to once per 10\nminutes)."]]