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