# Handling commands

## Handle command

To handle a command, you can use `@OnCommand` decorator

{% hint style="info" %}
Optional. `@OnCommand` takes command you want to listen to as argument
{% endhint %}

## Get command params

You can get command params too (e.g. when user writes /start hello or follows the bot link with some params). Use `@CommandParams` property decorator to it

{% hint style="info" %}
You can read more about property decorators [here](/nestgram/handling-updates/other-arguments-in-handler.md)
{% endhint %}

## Example

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

```typescript
import { OnCommand, Controller, CommandParams } from 'nestgram';
import { AppService } from './app.service';

@Controller()
export class AppController {
  constructor(private readonly appService?: AppService) {}

  @OnCommand('start')
  async start(@CommandParams() params: string[]): Promise<string> {
    console.log(params);
    return 'Hello, world!';
  }
}
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://degreetpro.gitbook.io/nestgram/handling-updates/handling-commands.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
