diff --git a/lib/Service/AiIntegrations/AiIntegrationsService.php b/lib/Service/AiIntegrations/AiIntegrationsService.php index 8c2d84c54c..2ad971905a 100644 --- a/lib/Service/AiIntegrations/AiIntegrationsService.php +++ b/lib/Service/AiIntegrations/AiIntegrationsService.php @@ -265,7 +265,8 @@ public function getSmartReply(Account $account, Mailbox $mailbox, Message $messa $manager->runTask($task); $replies = $task->getOutput(); try { - $decoded = json_decode($replies, true, 512, JSON_THROW_ON_ERROR); + $cleaned = preg_replace('/^```json\s*|\s*```$/', '', trim($replies)); + $decoded = json_decode($cleaned, true, 512, JSON_THROW_ON_ERROR); $this->cache->addValue('smartReplies_' . $message->getId(), $replies); return $decoded; } catch (JsonException $e) {