<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Milly Khamroev</title>
    <description>The latest articles on DEV Community by Milly Khamroev (@millykhamroev).</description>
    <link>https://dev.to/millykhamroev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1219132%2F0f69d600-3b98-4fb0-988c-bc79fcf1ef73.jpeg</url>
      <title>DEV Community: Milly Khamroev</title>
      <link>https://dev.to/millykhamroev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/millykhamroev"/>
    <language>en</language>
    <item>
      <title>Laravel package to integrate telegram bot api</title>
      <dc:creator>Milly Khamroev</dc:creator>
      <pubDate>Sun, 26 Nov 2023 11:33:21 +0000</pubDate>
      <link>https://dev.to/millykhamroev/laravel-package-to-integrate-telegram-bot-api-3l6e</link>
      <guid>https://dev.to/millykhamroev/laravel-package-to-integrate-telegram-bot-api-3l6e</guid>
      <description>&lt;p&gt;&lt;em&gt;Hello. My name is Milly, and I've been writing Telegram bots for a few years now. I used to write Telegram bots in PHP without any libraries. When I had to make a website, I learned about laravel and realized that Laravel has everything. I just lacked a library to work with the Telegram API in Laravel and decided to develop it myself.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://github.com/Mirmuxsin/laragram" rel="noopener noreferrer"&gt;Laragram&lt;/a&gt;: a Laravel package to integrate the Telegram bot API
&lt;/h2&gt;

&lt;p&gt;Features&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It has every method of Telegram bot API that is fully documented.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvice28vfc9to9bu67rgb.png" alt="Methods"&gt;
&lt;/li&gt;
&lt;li&gt;Update-objects, which are easy to handle, are documented too.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F92sx8se6cmufj71a0xsn.png" alt="Objects"&gt;
&lt;/li&gt;
&lt;li&gt;FSM Routing
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg0fnezduf86gv3ep2fu0.png" alt="FSM Routing"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Now let's try to install it and send hello world.
&lt;/h3&gt;

&lt;p&gt;First, install the Laragram package, and make sure that the database connection settings are correct!&lt;br&gt;
&lt;code&gt;composer require milly/laragram&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then run these commands to publish assets and config&lt;br&gt;
&lt;code&gt;php artisan vendor:publish --provider="Milly\Laragram\LaragramServiceProvider"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Add your telegram bot token to .env&lt;br&gt;
&lt;code&gt;TELEGRAM_BOT_TOKEN=123456789:XXXXXXXXXXXXXXXXXXXXXXXXXXX&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Run migration to be able to use FSM-Routing&lt;br&gt;
&lt;code&gt;php artisan migrate&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And we are ready to use telegram methods. Let's test the basic sendMessage method:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;

&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;\Milly\Laragram\Laragram&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nc"&gt;Laragram&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;sendMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s1"&gt;'your_telegram_id'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'Hello world'&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;When you run this code, you should get the message 'Hello world' from your telegram bot (you should have started the bot before). And that's it. Isn't it easy?&lt;/p&gt;

&lt;p&gt;You can check out the full documentation from on github: &lt;a href="https://github.com/Mirmuxsin/laragram" rel="noopener noreferrer"&gt;https://github.com/Mirmuxsin/laragram&lt;/a&gt; &lt;/p&gt;

</description>
      <category>laravel</category>
      <category>telegram</category>
      <category>telegrambot</category>
      <category>api</category>
    </item>
  </channel>
</rss>
