Skip to main content

Storage

There are two types of storage available to you during development; session storage and permanent storage. Both of these are available on the context object passed through to the handler functions.

Session Storage

Session storage persist only as long as the session. Stentor will automatically purge and create a new session storage once the session ends and a new one begins.

The session storage is on the context object available to the handler.


public async handleRequest(request: Request, context: Context): Promise<void> {

const sessionSlots = context.session.get("slots");

context.session.set("current_state", 2);

}

Session Values Managed by Stentor

Stentor will manage a couple of session values for you. Feel free to access these however editing them may cause unexpected behavior.

KeyDescriptionValues
new_userTrue if the user is brand newtrue, false
unknownInputsCurrent number of consecutive UnknownInputs received0, 1, 2
slotsCurrent slots received throughout the entire sessionObject with all slot values

Permanent Storage

Permanent storage persists indefinitely and is saved within the user table. The permanent storage also contains the session storage but it's lifecycle is managed by stentor. The storage can be accessed directly on the context object.


public async handleRequest(request: Request, context: Context): Promise<void> {

const lifetimeScore = context.storage.score;

// Later, update the score

context.storage.score = lifetimeScore + 1;

}

Values Managed by Stentor

Stentor will manage a couple of permanent values for you that you have access to.

KeyDescriptionValues
createdTimestampWhen the user first used the assistantISO-8601 string
lastActiveTimestampWhen the user was last seen by the assistantISO-8601 string
currentHandlerThe current active handlerHandler object
previousHandlerThe previous handler before the current oneHandler object
previousResponseThe previous response given to the userResponse object
sessionStoreThe session storage data and metadataSessionStorageData object