Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/grammy/convenience/session.ts

The Telegram Bot Framework.
Very Popular
Go to Latest
import * as grammy from "https://deno.land/x/grammy@v1.17.0/convenience/session.ts";

Classes

The memory session storage is a built-in storage adapter that saves your session data in RAM using a regular JavaScript Map object. If you use this storage adapter, all sessions will be lost when your process terminates or restarts. Hence, you should only use it for short-lived data that is not important to persist.

Functions

You can use this function to transform an existing storage adapter, and add more features to it. Currently, you can add session migrations and expiry dates.

This is an advanced function of grammY.

Session middleware provides a persistent data storage for your bot. You can use it to let your bot remember any data you want, for example the messages it sent or received in the past. This is done by attaching session data to every chat. The stored data is then provided on the context object under ctx.session.

Interfaces

When enhancing a storage adapter, it needs to be able to store additional information. It does this by wrapping the actual data inside an object, and adding more properties to this wrapper.

A lazy session flavor is a context flavor that holds a promise of some session data under ctx.session.

Options for enhanced sessions

A mapping from version numbers to session migration functions. Each entry in this object has a version number as a key, and a function as a value.

A session flavor is a context flavor that holds session data under ctx.session.

Options for session middleware.

A storage adapter is an abstraction that provides read, write, and delete access to a storage solution of any kind. Storage adapters are used to keep session middleware independent of your database provider, and they allow you to pass your own storage solution.

Type Aliases

Options for session middleware if multi sessions are used. Specify "type": "multi" in the options to use multi sessions.