Skip to main content
Module

x/grammy_conversations/conversation.ts>ConversationFn

Conversational interfaces for grammY
Go to Latest
type alias ConversationFn
import { type ConversationFn } from "https://deno.land/x/grammy_conversations@v1.1.0/conversation.ts";

A user-defined conversation builder function that can be turned into middleware for a conversation. This is the type of the function that you should use to write your conversation. It can be used like so:

const myConversation: ConversationFn<MyContext> = async (conversation, ctx) => {
  // TODO define the conversation
}

The first parameter is the conversation handle which you can use to wait for new messages, use forms, and access utilies such as random number generation.

The second parameter is the initial context object. In this parameter, the conversation builder function will receive the context object that was received when the conversation was started.

definition: (conversation: Conversation<C>, ctx: C) => unknown | Promise<unknown>