> For the complete documentation index, see [llms.txt](https://degreetpro.gitbook.io/nestgram/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://degreetpro.gitbook.io/nestgram/messages/send-poll.md).

# Send poll

## Send poll

You can send the poll to the channel or to the user. It can be anonymous poll or quiz. To create it, use the **Poll class**

#### Poll class take arguments

<table><thead><tr><th width="192.3955890727367" data-type="number">Argument</th><th width="318.3333333333333">Description</th><th>Required</th></tr></thead><tbody><tr><td>1</td><td>Question</td><td><strong>Required</strong></td></tr><tr><td>2</td><td>Poll options (<em>array of string</em>)</td><td><strong>Required</strong></td></tr><tr><td>3</td><td><a href="https://core.telegram.org/bots/api#sendpoll">More options</a></td><td>Optional</td></tr></tbody></table>

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

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

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

  @OnCommand('start')
  sendPoll(): MessageSend {
    return new MessageSend(
      new Poll(
        'What is Nestgram?', // question
        ['Framework', 'Library'], // options
        { // params
          type: 'quiz', // send quiz
          is_anonymous: true, // send anonymous quiz
          correct_option_id: 0, // and correct answer is 'Framework'
        }
      ),
    );
  }
}
```

{% endcode %}

## Stop poll

To stop poll, use **StopPoll class-method** or `.stopPoll` **answer/api method**

#### StopPoll class-method take arguments:

<table><thead><tr><th width="193.33333333333331" data-type="number">Argument</th><th width="326.13483146067415">Description</th><th>Required</th></tr></thead><tbody><tr><td>1</td><td>Keyboard you want to add</td><td>Optional</td></tr><tr><td>2</td><td>Message id you want to edit</td><td>Optional. Current message id by default</td></tr><tr><td>3</td><td>Chat id in which poll you want to stop is located</td><td>Optional. Current chat id by default</td></tr><tr><td>4</td><td><a href="https://core.telegram.org/bots/api#stoppoll">More options</a></td><td>Optional</td></tr></tbody></table>

{% hint style="info" %}
If you want to know what arguments an API method takes, see the IDE hint
{% endhint %}

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

```typescript
import { Controller, Keyboard, KeyboardTypes, MessageSend, OnClick, OnCommand, Poll, StopPoll } from 'nestgram';
import { AppService } from './app.service';

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

  @OnCommand('start')
  sendPoll(): MessageSend {
    return new MessageSend(
      new Poll(
        'What is Nestgram?', // question
        ['Framework', 'Library'], // options
        { // params
          type: 'quiz', // send quiz
          is_anonymous: true, // send anonymous quiz
          correct_option_id: 0, // and correct answer is 'Framework'
        }
      ),
      new Keyboard(KeyboardTypes.underTheMessage)
        .btn('Stop me', 'stop'),
    )
  }

  @OnClick('stop')
  stopPoll(): StopPoll {
    return new StopPoll();
  }
}
```

{% endcode %}
