-
Notifications
You must be signed in to change notification settings - Fork 16
/
ConversationState.yml
253 lines (216 loc) · 8.14 KB
/
ConversationState.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
### YamlMime:TSType
name: ConversationState
uid: botbuilder-core.ConversationState
package: botbuilder-core
summary: Reads and writes conversation state for your bot to storage.
fullName: ConversationState
remarks: >-
Each conversation your bot has with a user or group will have its own isolated
storage object
that can be used to persist conversation tracking information between turns of
the conversation.
This state information can be reset at any point by calling [clear()](#clear).
```JavaScript
const { ConversationState, MemoryStorage } = require('botbuilder');
const conversationState = new ConversationState(new MemoryStorage());
```
isPreview: false
isDeprecated: false
type: class
constructors:
- name: 'ConversationState(Storage, string)'
uid: botbuilder-core.ConversationState.constructor
package: botbuilder-core
summary: Creates a new ConversationState instance.
remarks: ''
isPreview: false
isDeprecated: false
syntax:
content: 'new ConversationState(storage: Storage, namespace?: string)'
parameters:
- id: storage
type: <xref uid="botbuilder-core.Storage" />
description: Storage provider to persist conversation state to.
- id: namespace
type: string
description: >
(Optional) namespace to append to storage keys. Defaults to an empty
string.
inheritedMethods:
- name: clear(TurnContext)
uid: botbuilder-core.ConversationState.clear
package: botbuilder-core
summary: Clears the current state object for a turn.
remarks: >-
The cleared state object will not be persisted until
[saveChanges()](#savechanges) has
been called.
```JavaScript
await botState.clear(context);
await botState.saveChanges(context);
```
isPreview: false
isDeprecated: false
syntax:
content: 'function clear(context: TurnContext): Promise<void>'
parameters:
- id: context
type: <xref uid="botbuilder-core.TurnContext" />
description: Context for current turn of conversation with the user.
return:
description: A promise representing the async operation.
type: Promise<void>
inheritanceDescription: >-
<b>Inherited From</b>
[BotState.clear](xref:botbuilder-core.BotState.clear)
- name: createProperty<T>(string)
uid: botbuilder-core.ConversationState.createProperty
package: botbuilder-core
summary: >-
Creates a new property accessor for reading and writing an individual
property to the bot
states storage object.
remarks: ''
isPreview: false
isDeprecated: false
syntax:
content: 'function createProperty<T>(name: string): StatePropertyAccessor<T>'
parameters:
- id: name
type: string
description: Name of the property to add.
return:
description: An accessor for the property.
type: <xref uid="botbuilder-core.StatePropertyAccessor" /><T>
inheritanceDescription: >-
<b>Inherited From</b>
[BotState.createProperty](xref:botbuilder-core.BotState.createProperty)
- name: delete(TurnContext)
uid: botbuilder-core.ConversationState.delete
package: botbuilder-core
summary: Delete the backing state object for the current turn.
remarks: >-
The state object will be removed from storage if it exists. If the state
object has been
read in and cached, the cache will be cleared.
```JavaScript
await botState.delete(context);
```
isPreview: false
isDeprecated: false
syntax:
content: 'function delete(context: TurnContext): Promise<void>'
parameters:
- id: context
type: <xref uid="botbuilder-core.TurnContext" />
description: Context for current turn of conversation with the user.
return:
description: A promise representing the async operation.
type: Promise<void>
inheritanceDescription: >-
<b>Inherited From</b>
[BotState.delete](xref:botbuilder-core.BotState.delete)
- name: get(TurnContext)
uid: botbuilder-core.ConversationState.get
package: botbuilder-core
summary: Returns a cached state object or undefined if not cached.
remarks: >-
This example shows how to synchronously get an already loaded and cached
state object:
```JavaScript
const state = botState.get(context);
```
isPreview: false
isDeprecated: false
syntax:
content: 'function get(context: TurnContext): any | undefined'
parameters:
- id: context
type: <xref uid="botbuilder-core.TurnContext" />
description: Context for current turn of conversation with the user.
return:
description: A cached state object or undefined if not cached.
type: any | undefined
inheritanceDescription: '<b>Inherited From</b> [BotState.get](xref:botbuilder-core.BotState.get)'
- name: 'load(TurnContext, boolean)'
uid: botbuilder-core.ConversationState.load
package: botbuilder-core
summary: Reads in and caches the backing state object for a turn.
remarks: >-
Subsequent reads will return the cached object unless the `force` flag is
passed in which
will force the state object to be re-read.
This method is automatically called on first access of any of created
property accessors.
```JavaScript
const state = await botState.load(context);
```
isPreview: false
isDeprecated: false
syntax:
content: 'function load(context: TurnContext, force?: boolean): Promise<any>'
parameters:
- id: context
type: <xref uid="botbuilder-core.TurnContext" />
description: Context for current turn of conversation with the user.
- id: force
type: boolean
description: >-
(Optional) If `true` the cache will be bypassed and the state will
always be read in directly from storage. Defaults to `false`.
return:
description: The cached state.
type: Promise<any>
inheritanceDescription: '<b>Inherited From</b> [BotState.load](xref:botbuilder-core.BotState.load)'
- name: 'saveChanges(TurnContext, boolean)'
uid: botbuilder-core.ConversationState.saveChanges
package: botbuilder-core
summary: Saves the cached state object if it's been changed.
remarks: >-
If the `force` flag is passed in the cached state object will be saved
regardless of
whether its been changed or not and if no object has been cached, an empty
object will be
created and then saved.
```JavaScript
await botState.saveChanges(context);
```
isPreview: false
isDeprecated: false
syntax:
content: >-
function saveChanges(context: TurnContext, force?: boolean):
Promise<void>
parameters:
- id: context
type: <xref uid="botbuilder-core.TurnContext" />
description: Context for current turn of conversation with the user.
- id: force
type: boolean
description: >-
(Optional) if `true` the state will always be written out regardless
of its change state. Defaults to `false`.
return:
description: A promise representing the async operation.
type: Promise<void>
inheritanceDescription: >-
<b>Inherited From</b>
[BotState.saveChanges](xref:botbuilder-core.BotState.saveChanges)
methods:
- name: getStorageKey(TurnContext)
uid: botbuilder-core.ConversationState.getStorageKey
package: botbuilder-core
summary: Returns the storage key for the current conversation state.
remarks: ''
isPreview: false
isDeprecated: false
syntax:
content: 'function getStorageKey(context: TurnContext): string | undefined'
parameters:
- id: context
type: <xref uid="botbuilder-core.TurnContext" />
description: Context for current turn of conversation with the user.
return:
description: The storage key for the current conversation state.
type: string | undefined
extends: <xref uid="botbuilder-core.BotState" />