Search code examples
slackslack-api

How can I create Hyperlinks in slack snippet


How does one create hyperlinks in slack snippets?

I am trying to upload a snippet through WEB API, but the Hyperlinks that am providing doesn't work and it posts as normal text. I can create hyperlinks in attachments, but I want to do the same with snippets.


Solution

  • Snippets are plain text and can not contain formatted text. If you want to upload a text file with hyperlinks you need to create a post.

    Use files.upload with the following minimum parameters:

    • token: your token
    • content: string with the content of you file via this POST variable
    • filetype: post
    • channel: ID of channels to share directly

    Add additional parameters as needed, but don't use the file parameter.

    Your file can be a standard text file. URLs will be automatically converted.

    Example:

    This is a test file! Hyperlink: https://www.google.de/
    

    This is how it looks in Slack: enter image description here