From e9a4eae7d16a22da3f99c2f14eef5e4d31b530b2 Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 2 Sep 2022 17:39:49 +1000 Subject: [PATCH] Enable sending ephemeral messages to Slack --- src/API.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/API.php b/src/API.php index 02938d7..3a224f1 100644 --- a/src/API.php +++ b/src/API.php @@ -33,6 +33,7 @@ final class API private const scopes = [ 'auth.test'=>'', // No scope required 'chat.delete'=>'chat:write', + 'chat.postEphemeral'=>'chat:write', 'chat.postMessage'=>'chat:write', 'chat.update'=>'chat:write', 'conversations.history'=>'channels:history', // Also need groups:history for Private Channels and im:history for messages to the bot. @@ -216,6 +217,20 @@ final class API return new Generic($this->execute('pins.add',json_encode(['channel'=>$channel,'timestamp'=>$timestamp]))); } + /** + * Post a Slack Message to a user as an ephemeral message + * + * @param Message $request + * @return Generic + * @throws \Exception + */ + public function postEphemeral(Message $request): Generic + { + Log::debug(sprintf('%s:Post a Slack Ephemeral Message',static::LOGKEY),['m'=>__METHOD__,'r'=>$request]); + + return new Generic($this->execute('chat.postEphemeral',json_encode($request))); + } + /** * Post a Slack Message *