# Sending messages correctly

## Sending message as answer

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

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

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

  @OnCommand('start')
  async start(): Promise<string> {
    return 'Hello, world!';
  }
}
```

{% endcode %}

In this code in `start` method, you can see when the user writes command **/start**, the user gets the message `Hello, world!`. What's method returns will be sent to the user

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

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

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

  @OnCommand('start')
  async start(): Promise<MessageSend> {
    return new MessageSend('Hello, world!');
  }
}
```

{% endcode %}

MessageSend class-method is a wrapper for the message: it allows you to add keyboard, options, photo, or media to the message

If you don't know what will return your method (e.g. MessageSend or Edit) you can use MessageCreator class as return type (import from root)

#### MessageSend class-method take arguments:

<table><thead><tr><th width="150" data-type="number">Argument</th><th width="384.3333333333333">Description</th><th>Required</th></tr></thead><tbody><tr><td>1</td><td>Content (media or text)</td><td><strong>Required</strong></td></tr><tr><td>2</td><td><a href="../keyboards/keyboard-types-building-keyboard">Keyboard</a></td><td>Optional</td></tr><tr><td>3</td><td><a href="https://core.telegram.org/bots/api#sendmessage">Options</a></td><td>Optional</td></tr></tbody></table>

{% hint style="info" %}
Sometimes you can't use the class methods, for example when you want to get some info about the current chat, for that you can use the [**Answer class**](https://degreetpro.gitbook.io/nestgram/nestgram-features/answer-class)
{% endhint %}

## Sending message line

You can also send more than one message, use the `.next` method on the **MessageSend class**

{% hint style="info" %}
**.next method** takes argument: content you want to send (it can be **MessageSend class**). It also can be a function or an async function
{% endhint %}

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

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

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

  @OnCommand('start')
  start() {
    return new MessageSend('Hello, world!')
      .next('Second message')
      .next(new MessageSend('Third message'));
  }
}
```

{% endcode %}
