Handling text messages
Handle when user writes a text messages (e.g. "Hello, world!")
Handling text messages
To handle a text message, you can use the @OnText
decorator
Get the text of the message
You can also get the text of the message by @Text
parameter decorator
Example
import { OnText, Controller, Text } from 'nestgram';
import { AppService } from './app.service';
@Controller()
export class AppController {
constructor(private readonly appService?: AppService) {}
@OnText('Hello, world!')
async start(): Promise<string> {
return 'Hello!';
}
@OnText() // handle other text messages, optional
async text(@Text() text: string): Promise<string> {
return text;
}
}
Last updated