# Controller Helper class

## Build a bot link

Sometimes you need to build a **bot link** (e.g. **referral link** to the bot). Create **ControllerHelper class instance** and pass **Api** **class** to it. Then call `.getBotLink` method

{% hint style="info" %}
You can read more about Api class [here](/nestgram/config/api-class.md)
{% endhint %}

{% hint style="info" %}
.getBotLink takes argument: run parameters for **/start command** (optional)
{% endhint %}

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

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

@Controller()
export class AppController {
  @GetApi() api: Api;
  controllerHelper: ControllerHelper = new ControllerHelper(this.api);

  constructor(private readonly appService?: AppService) {}

  @OnCommand('start')
  async start(@UserId() userId: number): Promise<string | undefined> {
    const link: string | undefined = this.controllerHelper.getBotLink(userId.toString());
    return link;
  }
}
```

{% 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/config/controller-helper-class.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.
