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?
-
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?DBS– DBS2016-10-24 23:25:11 +00:00Commented Oct 24, 2016 at 23:25
-
2Well, 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.Jerrod Horton– Jerrod Horton2016-10-25 15:06:06 +00:00Commented Oct 25, 2016 at 15:06
Add a comment
|
1 Answer
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 thefile) parameter to upload the content of your file. - Provide the name of the channel in the
channelsparameter where the snippet should be posted. - The
filetypeis optional. Slack will determine the type of your file based on the filename or "magic bytes" of the file. e.g. usingtextasfiletypewill work.
3 Comments
Artur79
Is it possible to do the same with botkit ?
congusbongus
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.
Erik Kalkoken
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.