Share via


BotState Class

Definition

Defines a state management object and automates the reading and writing of associated state properties to a storage layer.

public abstract class BotState : Microsoft.Bot.Builder.IPropertyManager
type BotState = class
    interface IPropertyManager
Public MustInherit Class BotState
Implements IPropertyManager
Inheritance
BotState
Derived
Implements

Remarks

Each state management object defines a scope for a storage layer.

State properties are created within a state management scope, and the Bot Framework defines these scopes: ConversationState, UserState, and PrivateConversationState.

You can define additional scopes for your bot.

Constructors

BotState(IStorage, String)

Initializes a new instance of the BotState class.

Methods

ClearStateAsync(ITurnContext, CancellationToken)

Clears the state cache for this BotState.

CreateProperty<T>(String)

Creates a named state property within the scope of a BotState and returns an accessor for the property.

DeleteAsync(ITurnContext, CancellationToken)

Deletes any state in storage and the cache for this BotState.

DeletePropertyValueAsync(ITurnContext, String, CancellationToken)

Deletes a property from the state cache for this BotState.

Get(ITurnContext)

Gets a copy of the raw cached data for this BotState from the turn context.

GetCachedState(ITurnContext)

Gets the cached bot state instance that wraps the raw cached data for this BotState from the turn context.

GetPropertyValueAsync<T>(ITurnContext, String, CancellationToken)

Gets the value of a property from the state cache for this BotState.

GetStorageKey(ITurnContext)

When overridden in a derived class, gets the key to use when reading and writing state to and from storage.

LoadAsync(ITurnContext, Boolean, CancellationToken)

Populates the state cache for this BotState from the storage layer.

SaveChangesAsync(ITurnContext, Boolean, CancellationToken)

Writes the state cache for this BotState to the storage layer.

SetPropertyValueAsync(ITurnContext, String, Object, CancellationToken)

Sets the value of a property in the state cache for this BotState.

Applies to

See also