Search code examples
pythonhyperlinkmarkdownslack-api

Post hyperlink to slack using slack sdk for python


I want to post to slack a string that includes a hyperlink, and I'm using slack SDK for python. The string is made up this way:

f":notepadicon: *{doc_to_report['desc']}*: {doc_to_report['file_name']} [link]({doc_to_report['url']})\n"

I know the markdown code for hyperlink is [text](url), and it should post the text with a hyperlink to the URL string, but my code is posting this:

Description of file: name_of_the_file.csv [link](https://url_string.com)

You can see that the markdown hyperlink code ([]()) is not being considered.

The funny part is that if I copy what the script posts to slack and paste it into a slack post, it is properly formated.

What am I doing wrong?


Solution

  • try <URL|text>, this is how to do it for slack urls (like linking to other channels) but i think this should work for other urls since markdown is not supported within the chat_postMessage api