# Creating the first script

In the future, you can use one of the ready-made templates:

![](https://1932399487-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuRfd5lEYYH6D50QjzeAX%2Fuploads%2Fq9wtjFmJcWqMHmqCav3W%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202022-06-01%20%D0%B2%2019.06.52.png?alt=media\&token=6b43d266-f794-4b72-9863-b21ac7ec5e2b)

But now for training, we will create our own:

![](https://1932399487-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuRfd5lEYYH6D50QjzeAX%2Fuploads%2FQEPPKwDCXc9sv4rVe2wj%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202022-06-01%20%D0%B2%2019.07.43.png?alt=media\&token=a47edadf-c145-4ba9-a5e7-4bdf4d038d07)

Let's create a bot in Telegram. It will respond to the start button or the "Hi" message:

![](https://1932399487-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuRfd5lEYYH6D50QjzeAX%2Fuploads%2FqY6tfwVIjWFWXyyQ04wk%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202022-06-01%20%D0%B2%2019.08.42.png?alt=media\&token=759e04bb-7619-47a8-8cbc-ea154b8af72a)

The bot will respond to this with “Hello from the bot!”

![](https://1932399487-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuRfd5lEYYH6D50QjzeAX%2Fuploads%2FC0lJ5Oex2eI98dkgaVU1%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202022-06-01%20%D0%B2%2019.09.12.png?alt=media\&token=3c2d16b5-ffbf-48bc-b779-3c7a6133402b)

To publish a script, you need to link a channel. Click on the "Publish" button at the top right and we get a message:

![](https://1932399487-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuRfd5lEYYH6D50QjzeAX%2Fuploads%2FPgBxt8AJ1UwUYdz7wTbq%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202022-06-01%20%D0%B2%2019.09.36.png?alt=media\&token=5e87bd5d-df4b-4589-bd07-59b7258a6966)

A channel is any VK community or a chat bot in Telegram, which must first be added to the system.&#x20;

If we click "Create a channel", we will see that so far the list of channels is empty. Let's create a new bot. To do this, follow the link in BotFather:

![](https://1932399487-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuRfd5lEYYH6D50QjzeAX%2Fuploads%2F5TJIauLFNCoXtD0fcmmD%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202022-06-10%20%D0%B2%2016.03.17.png?alt=media\&token=34e6af56-8eb2-45e7-8b16-449870889575)

A dialogue will open in Telegram. Here you need to execute the /newbot command, select a name and username and get a token from BotFather:

![](https://1932399487-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuRfd5lEYYH6D50QjzeAX%2Fuploads%2Fymn4Har4HswgLKmKBFIh%2Fbotfather_1.png?alt=media\&token=11ce18f1-08b8-45e1-bc99-39ad83b31044)

Copy the token, paste it into the service window and click "Create":

![](https://1932399487-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuRfd5lEYYH6D50QjzeAX%2Fuploads%2FS8Sc9cChFXPIECK0efpG%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202022-06-10%20%D0%B2%2016.05.02.png?alt=media\&token=9f8e0295-8922-424f-b638-aea6227b48a9)

The channel is now bound to the script:

![](https://1932399487-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuRfd5lEYYH6D50QjzeAX%2Fuploads%2FLoqL3ynis2EGWqvJderH%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202022-06-10%20%D0%B2%2016.05.57.png?alt=media\&token=a6687a4c-4284-49e7-9839-f36e904c73af)

Pay attention to the words "Account is linked". Now it's set to "No". You need to click "bind" and send a specific message to your bot:

![](https://1932399487-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuRfd5lEYYH6D50QjzeAX%2Fuploads%2FpJphlTtECJeNLzU1RIxx%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202022-06-10%20%D0%B2%2016.07.15.png?alt=media\&token=f8302ce5-cdfb-4c71-8c68-61377d76f1ad)

![](https://1932399487-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuRfd5lEYYH6D50QjzeAX%2Fuploads%2FdE0dPpK9lkblEfrH53QX%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202022-06-01%20%D0%B2%2019.11%20copy.png?alt=media\&token=376d6817-4647-4f1f-8a91-0f77783428b9)

This will link your Telegram account to the service and confirm that you are an administrator. Now you can publish the script, go to the bot and test its work:

![](https://1932399487-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuRfd5lEYYH6D50QjzeAX%2Fuploads%2FsGZi2gzwF1C0qcdEVIdZ%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202022-06-01%20%D0%B2%2019.11%20copy_mybot_test_1.png?alt=media\&token=7cbc52f7-847d-49e2-bab2-e8fcfb26a537)

The administrator can also test unpublished scenarios, we will talk about this in more detail a little later.
