Search code examples
pythonslackslack-api

How to use slack-api pins.add method


I am trying to use pins.add method , documentation says they now don't support file, file_comment, but there is no specification on how send text that i want to pin.

I have tried using slack client as mentioned below, but it says not_pinnable and if i don't mention text it says no_item_specified.

sc.api_call("pins.add", channel=channel_id, ts=x, file='test', file_comment='helo')

Solution

  • For pinning a text you need to reference the message that you want to pin, which already needs to exist in a channel. You can reference a message by providing channel ID and the timestamp of the message.

    You get the timestamp of a message when you post it yourself (its in the response from the API) or from a message event or by fetching all messages from a channel with conversations.history.

    Example:

    sc.api_call("pins.add", channel=channel_id, timestamp=message_timestamp)