20

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?

2
  • A quick look through the docs turns up that you upload it as a "file": api.slack.com/types/file api.slack.com/methods/files.upload Is there anything specific about that you're looking to ask? Commented Oct 24, 2016 at 23:25
  • 2
    Well, I am wanting to post log files to a slack channel in markdown (or some other nice on the eyes) format. The logs can get big sometimes and slack chunks the messages ruining the markdown that I had in there so I was wondering if it was possible to post that log description as a snippet instead so that it was easy to read in the slack channel. Commented Oct 25, 2016 at 15:06

1 Answer 1

19

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.
Sign up to request clarification or add additional context in comments.

3 Comments

Is it possible to do the same with botkit ?
Note: to get this working, I've also had to create a second message containing a link to the uploaded file. It seems that using files.upload alone only uploads a file but does not post a message in a channel linking to that file.
Are you sure you included channels in your request? that is required to get the file posted in a channel. You can also add a message with initial_comment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.