In the group chat, my bot always forces me to reply every time I launch Telegram

I’ve made a simple Telegram bot that invites a user to a Trello board and notifies all users in the group chat when a card is moved from one list to another. I’m facing a problem. Every time I launch Telegram and select the group chat, I get this. In a private chat between me and the bot, everything is fine.

This is the GitHub repo of my project: https://github.com/loglinn05/loglinn05_chatos_bot/

To handle webhook requests from Telegram, I use defstudio/telegraph. This is what my handler class looks like:

<?php

namespace AppTelegram;

use AppModelsUser;
use DefStudioTelegraphEnumsChatActions;
use DefStudioTelegraphHandlersWebhookHandler;
use GuzzleHttpClient;

class Handler extends WebhookHandler
{
  private $trelloApiBaseUrl;
  private $trelloApiKey;
  private $trelloApiToken;
  private $boardId;

  public function __construct()
  {
    $this->trelloApiBaseUrl = env("TRELLO_API_BASE_URL");
    $this->trelloApiKey = env("TRELLO_API_KEY");
    $this->trelloApiToken = env("TRELLO_API_TOKEN");
    $this->boardId = env("BOARD_ID");
  }

  public function start()
  {
    $from = $this->message->from();
    $fromUser = User::where('telegram_user_id', $from->id())->first();

    $this->chat->action(ChatActions::TYPING)->send();

    // saying hello
    $name = $from->firstName();
    $this->reply("Hi, $name!");

    // adding a user to the database if they're not there
    if (!$fromUser) {
      $user = new User();
      $user->telegram_user_id = $from->id();
      $user->first_name = $from->firstName();

      if ($from->lastName()) {
        $user->last_name = $from->lastName();
      }

      $user->telegram_username = $from->username();
      $user->save();

      if ($user) {
        $this->chat->action(ChatActions::TYPING)->send();
        $this->reply("You've been added to the database.");
      }
    }

    $this->chat->action(ChatActions::TYPING)->send();
    $this->reply("If you need further assistance, enter /help.");
  }

  public function help()
  {
    $this->chat->action(ChatActions::TYPING)->send();
    $this->reply("
      I can invite you to our Trello board. Let's work _together_! xE2x9CxA8
      n*Enter /invite to proceed.*
    ");
  }

  public function invite()
  {
    $from = $this->message->from();
    $fromUser = User::where('telegram_user_id', $from->id())->first();

    $fromUser->status = "providing email";
    $fromUser->save();
    $this->forceToEnterEmail();
  }

  public function handleUnknownCommand(IlluminateSupportStringable $text): void
  {
    $this->chat->action(ChatActions::TYPING)->send();
    $this->reply("What do you mean?
    nI don't know this command! xF0x9Fx98x85");
  }

  public function handleChatMessage($email): void
  {
    $from = $this->message->from();
    $fromUser = User::where('telegram_user_id', $from->id())->first();

    if ($fromUser->status == "providing email") {
      $fullName = [];

      // set the user's email if it's not set
      // and set the full name for the invitation request
      if ($fromUser) {
        $fullName = ['fullName' => "{$fromUser->first_name} {$fromUser->last_name}"];
      }

      $invitationResponse = $this->sendInvitationRequest($email, $fullName);

      if (
        $invitationResponse->getStatusCode() == 200
      ) {
        if (!$fromUser->email) {
          $fromUser->email = $email;
          $fromUser->save();
        }
        $this->onSuccessfulInvitation();
      } elseif (
        $invitationResponse->getBody() == 'Member already invited'
      ) {
        $this->clearFromUserStatus();

        $this->chat->action(ChatActions::TYPING)->send();
        $this->reply("You're already invited. Enjoy the experience!");

        $this->getLinkToTheBoard();
      } elseif (
        json_decode($invitationResponse->getBody())->message == "invalid email address"
      ) {
        $this->chat->action(ChatActions::TYPING)->send();
        $this->reply("Invalid email address.");

        $this->forceToEnterEmail();
      } else {
        $this->clearFromUserStatus();

        $this->chat->action(ChatActions::TYPING)->send();
        $this->reply("Unknown error occurred during invitation attempt.");
      }
    }
  }

  private function forceToEnterEmail()
  {
    $this->chat->action(ChatActions::TYPING)->send();
    $this->chat->message("Please, enter your email so I can invite you:")->forceReply("Enter your email here...", selective: true)->send();
  }

  private function sendInvitationRequest($email, $fullName)
  {
    $client = new Client();
    $invitationResponse = $client->put(
      "$this->trelloApiBaseUrl/boards/$this->boardId/members?email=$email&key=$this->trelloApiKey&token=$this->trelloApiToken",
      [
        'http_errors' => false,
        'json' => $fullName
      ]
    );
    return $invitationResponse;
  }

  private function clearFromUserStatus()
  {
    $from = $this->message->from();
    $fromUser = User::where('telegram_user_id', $from->id())->first();

    $fromUser->status = null;
    $fromUser->save();
  }

  private function onSuccessfulInvitation()
  {
    $this->clearFromUserStatus();

    $this->chat->action(ChatActions::TYPING)->send();
    $this->reply("You've been successfully invited.");
    $this->getLinkToTheBoard();
  }

  private function getLinkToTheBoard()
  {
    $client = new Client();

    $getBoardResponse = $client->get("$this->trelloApiBaseUrl/boards/$this->boardId?key=$this->trelloApiKey&token=$this->trelloApiToken");

    if ($getBoardResponse->getStatusCode() == 200) {
      $linkToTheBoard = json_decode($getBoardResponse->getBody())->url;

      $this->chat->action(ChatActions::TYPING)->send();
      $this->reply("Here's the link to the board:
      n$linkToTheBoard");
    } else {
      $this->chat->action(ChatActions::TYPING)->send();
      $this->reply("Unfortunately, we couldn't get the link to the board.");
    }
  }
}

As you can see, the selective field is set to true:

private function forceToEnterEmail()
{
  $this->chat->action(ChatActions::TYPING)->send();
  $this->chat->message("Please, enter your email so I can invite you:")->forceReply("Enter your email here...", selective: true)->send();
}

But the bot still forces a user to enter their email.

So I decided to write something to the log in this function. And I noticed that nothing was added into the log file when I started Telegram again. In a PowerShell terminal where ngrok was running, I didn’t notice any requests to the Telegram API when the app launches.

If you have any ideas on how to solve this issue, please, share them. I’ll appreciate any help.

If you need something else to understand my question, feel free to ask.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật