Search code examples
slack-apigiphy

Post Slack message as specific user


I'm building a Slack bot with slash commands and I would like to post a message with an attachment as a specific user (specifically, the user that called the slash command).

I know this is possible because the Giphy Slack integration does so when responding to the /giphy [image] command, by responding as the user with a gif image.

  • I tried using the chat.meMessage method but this does not appear to support attachments.
  • I tried using the as_user argument in the chat.postMessage method, but this inherits the authenticated user rather than the user that called the slash command.
  • Responding to the slash command immediately or performing a delayed response (using response_url) doesn't seem to support non-bot responses. If they do, I can't seem to find where it's documented.

In the slash request Slack does provide both user_id and user_name parameters, so I imagine I can make use of those.


Solution

  • I reached out to Slack with this question, and unfortunately at this time it doesn't look like what I'm asking for is possible. The Giphy Slack integration was internally built.

    Maybe in the future!