대화형 작업이 2023년 6월 13일에 지원 중단되었습니다. 자세한 내용은
대화 작업 지원 중단을 참고하세요.
세션 저장소
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
대화 내에서 특정 사용자의 매개변수 값을
세션 스토리지로 이동합니다 그러면 작업이 나중에 프롬프트에서 저장된 값을 사용할 수 있습니다.
웹훅 코드는 세션 스토리지의 값에 액세스하여
대화를 나눌 수 있습니다
대화 중에 유형을 사용하여 수집된 모든 데이터는 세션에 저장됩니다.
사용할 수 있습니다 웹훅 호출을 사용하여 세션 저장소의 데이터와 상호작용할 수도 있습니다.
웹훅 호출의 경우 세션 저장소의 상태가 app.handle()
에 전달됩니다.
session
객체에 저장됩니다.
세션 저장소에 저장된 데이터는 대화가 끝나면 만료됩니다.
세션 저장소에 데이터 읽기 및 쓰기
세션 스토리지에서 새 값을 업데이트하거나 설정하려면 값을
웹훅 호출에서 session
객체의 params
필드입니다. 다음 예를 참고하세요.
는 'exampleColor'를 설정합니다. '빨간색'으로 변경 세션 스토리지에서:
Node.js
// Assign color to session storage
app.handle('storeColor', conv => {
let color = 'red';
conv.session.params.exampleColor = color;
});
JSON
{
"responseJson": {
"session": {
"id": "12345678901234567890",
"params": {
"exampleColor": "red"
}
},
"prompt": {
"override": false
}
}
}
세션 저장소에 저장된 데이터에 액세스하려면 이를 웹훅의 변수에 할당하세요.
있습니다. 다음 예는 'exampleColor'에서 값을 검색합니다. 세션 중
저장용량:
Node.js
// Retrieve color from session storage
app.handle('getStoredColor', conv => {
let color = conv.session.params.exampleColor;
});
JSON
{
"responseJson": {
"session": {
"id": "12345678901234567890",
"params": {
"exampleColor": "red"
}
},
"prompt": {
"override": false
}
}
}
이전에 저장된 값을 지우려면 웹훅 호출에서 값을 null
로 설정합니다.
다음 예는 'exampleColor' 값을 지웁니다. 세션 스토리지에서:
Node.js
// Clear color from session storage
app.handle('clearStoredColor', conv => {
conv.session.params.exampleColor = null;
});
JSON
{
"responseJson": {
"session": {
"id": "12345678901234567890",
"params": {}
},
"prompt": {
"override": false
}
}
}
프롬프트 내에서 저장된 값 참조
프롬프트에서 세션 저장소에 저장된 값을 참조할 수 있습니다. 이
값에는 $session.params.PARAMETER_NAME
구문을 사용합니다. 여기서
PARAMETER_NAME
은 매개변수가
설정되어 있습니다.
예를 들어, 이전에 세션 저장소에 색상 값을
매개변수 exampleColor
프롬프트에서 해당 값에 액세스하려면
$session.params.exampleColor
를 사용하여 값을 찾을 수 있습니다.
JSON
{
"candidates": [{
"first_simple": {
"variants": [{
"speech": "Your favorite color is $session.params.exampleColor."
}]
}
}]
}
조건 내에서 저장된 값 참조
조건에서 세션 저장소에 저장된 값을 참조할 수도 있습니다. 받는사람
값을 참조하려면 session.params.PARAMETER_NAME
를 사용합니다.
구문으로, 여기서 PARAMETER_NAME
은
매개변수가 설정되었습니다.
예를 들어, 이전에 세션 저장소에 색상 값을
exampleColor
매개변수를 사용하고 이 매개변수를 'red' 값과 일치시키려고 합니다. 과녁을 맞히려는 화살의
있습니다. 조건에서 다음을 사용하여 저장된 값을 참조합니다.
session.params.exampleColor
그러면 조건 표현식이 다음과 같이 표시됩니다.
조건 문법
session.params.exampleColor == "red"
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
[null,null,["최종 업데이트: 2025-07-26(UTC)"],[[["\u003cp\u003eYou can utilize session storage to save user-specific parameter values during a conversation, enabling your Action to reuse them in prompts and conditions, and your webhook code to access them when needed.\u003c/p\u003e\n"],["\u003cp\u003eSession storage automatically stores data gathered using types during a conversation, and you can interact with this data via webhook calls using the \u003ccode\u003esession\u003c/code\u003e object.\u003c/p\u003e\n"],["\u003cp\u003eTo modify or add values in session storage, assign them to the \u003ccode\u003eparams\u003c/code\u003e field of the \u003ccode\u003esession\u003c/code\u003e object within a webhook call; to retrieve them, assign them to a variable within a webhook call.\u003c/p\u003e\n"],["\u003cp\u003eStored values in session storage can be referenced in prompts using the \u003ccode\u003e$session.params.<PARAMETER_NAME>\u003c/code\u003e syntax and in conditions using the \u003ccode\u003esession.params.<PARAMETER_NAME>\u003c/code\u003e syntax.\u003c/p\u003e\n"],["\u003cp\u003eData stored in session storage is ephemeral and automatically deleted when the conversation concludes.\u003c/p\u003e\n"]]],[],null,["# Session storage\n\nYou can store parameter values for a specific user within a conversation in\nsession storage. Your Action can then use those stored values later in prompts\nand conditions, and your webhook code can access values in session storage for\nthe conversation when necessary.\n\nDuring a conversation, any data collected using [types](/assistant/conversational/types) is stored in session\nstorage. You can also interact with data in session storage using webhook calls.\nFor webhook calls, the state of session storage is passed in an `app.handle()`\nrequest and is stored in the [`session`](/assistant/conversational/reference/rest/v1/TopLevel/fulfill#Session) object.\n\nData stored in session storage expires when a conversation ends.\n\nRead and write data to session storage\n--------------------------------------\n\nTo update or set a new value in session storage, assign the value to the\n`params` field of the `session` object in a webhook call. The following example\nsets \"exampleColor\" to \"red\" in session storage: \n\n### Node.js\n\n```javascript\n// Assign color to session storage\napp.handle('storeColor', conv =\u003e {\n let color = 'red';\n conv.session.params.exampleColor = color;\n});\n \n```\n\n### JSON\n\n```text\n{\n \"responseJson\": {\n \"session\": {\n \"id\": \"12345678901234567890\",\n \"params\": {\n \"exampleColor\": \"red\"\n }\n },\n \"prompt\": {\n \"override\": false\n }\n }\n}\n \n```\n\nTo access data stored in session storage, assign it to a variable in a webhook\ncall. The following example retrieves a value from \"exampleColor\" in session\nstorage: \n\n### Node.js\n\n```javascript\n// Retrieve color from session storage\napp.handle('getStoredColor', conv =\u003e {\n let color = conv.session.params.exampleColor;\n});\n \n```\n\n### JSON\n\n```text\n{\n \"responseJson\": {\n \"session\": {\n \"id\": \"12345678901234567890\",\n \"params\": {\n \"exampleColor\": \"red\"\n }\n },\n \"prompt\": {\n \"override\": false\n }\n }\n}\n \n```\n\nTo clear a previously saved value, set the value to `null` in a webhook call.\nThe following example clears the value of \"exampleColor\" in session storage: \n\n### Node.js\n\n```javascript\n// Clear color from session storage\napp.handle('clearStoredColor', conv =\u003e {\n conv.session.params.exampleColor = null;\n});\n \n```\n\n### JSON\n\n```text\n{\n \"responseJson\": {\n \"session\": {\n \"id\": \"12345678901234567890\",\n \"params\": {}\n },\n \"prompt\": {\n \"override\": false\n }\n }\n}\n \n```\n\nReference stored values within prompts\n--------------------------------------\n\nYou can reference values stored in session storage in a [prompt](/assistant/conversational/prompts). To reference the\nvalue, use `$session.params.`\u003cvar translate=\"no\"\u003ePARAMETER_NAME\u003c/var\u003e syntax, where\n\u003cvar translate=\"no\"\u003ePARAMETER_NAME\u003c/var\u003e is the name given in the webhook when the parameter\nwas set.\n\nFor example, you previously stored a color value in session storage as the\nparameter `exampleColor`. To access that value in a prompt, you reference that\nvalue using `$session.params.exampleColor`: \n\n### JSON\n\n```gdscript\n{\n \"candidates\": [{\n \"first_simple\": {\n \"variants\": [{\n \"speech\": \"Your favorite color is $session.params.exampleColor.\"\n }]\n }\n }]\n}\n \n```\n\nReference stored values within conditions\n-----------------------------------------\n\nYou can also reference values stored in session storage in [conditions](/assistant/conversational/conditions). To\nreference the value, use the `session.params.`\u003cvar translate=\"no\"\u003ePARAMETER_NAME\u003c/var\u003e\nsyntax, where \u003cvar translate=\"no\"\u003ePARAMETER_NAME\u003c/var\u003e is the name given in the webhook when\nthe parameter was set.\n\nFor example, you previously stored a color value in session storage as the\nparameter `exampleColor`, and you want to match it with the value \"red\" in a\ncondition. In your condition, you reference the stored value using\n`session.params.exampleColor`. Your condition expression then looks like this: \n\n### Condition syntax\n\n```text\nsession.params.exampleColor == \"red\"\n \n```"]]