Let'sbecool
Let'sbecool

Reputation: 104

how to mention a user in slack message through the slack python API

here is my code

  client.api_call(api_method='chat.postMessage', json={'channel': '#staff', 'text': f'{user} This is a test.'})

the output I get is

U046NKX4LSD This is a test.

It should rather mention the username and the username should get a notification as you mention @username.

Upvotes: 0

Views: 2703

Answers (1)

Suyash Gaur
Suyash Gaur

Reputation: 2861

https://api.slack.com/reference/surfaces/formatting#mentioning-users

A mention is a special type of reference that will provide a link to the mentioned user's profile in the published text.

To mention a user in app-published text, you need to provide their user ID in the following syntax:

Hey <@U024BE7LH>, thanks for submitting your report.

Upvotes: 1

Related Questions