# Handling text messages

## Handling text messages

To handle a text message, you can use the `@OnText` decorator

{% hint style="info" %}
Optional. `@Entity` takes text you want to listen to as argument. If you don't pass it, you will handle all text messages
{% endhint %}

## Get the text of the message

You can also get the text of the message by `@Text` parameter decorator

## Example

{% code title="app.controller.ts" %}

```typescript
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;
  }
}
```

{% endcode %}
