messages I am sending are not being formatted and channel and usernames are not being linked. I tried both RTM and also API call, in both cases it fails.
Here is my code:
from slackclient import SlackClient
token = 'token'
sc = SlackClient(token)
team_join_event = 'team_join'
message = ('Hi! \n\nPublic channel - <#C06VBR8UT|general>\n\n'
'Private channel #sports.\n\n Admin - <@U06VBQ8TB|v>')
if sc.rtm_connect():
user_id = 'U2T0SF1U0'
response = sc.api_call('im.open', user=user_id)
dm_channel_id = response['channel']['id']
# sc.rtm_send_message(dm_channel_id, message)
sc.api_call(
'chat.postMessage', channel=dm_channel_id, text=message,
link_names=1)
else:
print ("Connection Failed, invalid token?")
Here is how it appears:

I have tested to use a similar way but a bit different.
message = "hello test, <#ID|general>"
sc.api_call("chat.postMessage", channel=dm_channel_id, text=message)
This seems to work just fine. I had to make sure the ID was absolutely correct in order for the api_call to work though. Didn't use link_names=1 or anything just the way I wrote above.
^you are right. I was using IDs of my slack team on the test one. No wonder it did not work.
Thank you! (:
@avinassh you are welcome!
Most helpful comment
@avinassh you are welcome!