ConversationFn
ref / conversations / ConversationFn
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:
ts
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.
Type Parameters
C
ts
C extends Context
Type
ts
(conversation: Conversation<C>, ctx: C) => unknown | Promise<unknown>