Search code examples
slack-apislack

How do I post a snippet to slack channel


I am trying to post log info to slack and some of these logs can get pretty big. Is there a way to send it as a snippet so that slack doesn't chunk the text into multiple messages?


Solution

  • You can post a snippet to a Slack channel using the API method files.upload.

    In order for this to work you need to:

    • Use the content (not the file) parameter to upload the content of your file.
    • Provide the name of the channel in the channels parameter where the snippet should be posted.
    • The filetype is optional. Slack will determine the type of your file based on the filename or "magic bytes" of the file. e.g. using text as filetype will work.