token . '/sendMessage'; $inlineButtons = []; if (!empty($this->buttons)) { foreach ($this->buttons as $button) { $buttonUrl = data_get($button, 'url'); if ($buttonUrl && Str::contains($buttonUrl, 'http://localhost')) { $buttonUrl = str_replace('http://localhost', config('app.url'), $buttonUrl); } $inlineButtons[] = [ 'text' => $button['text'], 'url' => $buttonUrl, ]; } } $payload = [ 'parse_mode' => 'markdown', 'reply_markup' => json_encode([ 'inline_keyboard' => [ [...$inlineButtons], ], ]), 'chat_id' => $this->chatId, 'text' => $this->text, ]; ray($payload); $response = Http::post($url, $payload); if ($response->failed()) { throw new \Exception('Telegram notification failed with ' . $response->status() . ' status code.' . $response->body()); } } }