Search code examples
slackslack-api

How Can i get my direct messages in slack api?


How Can i get my direct messages in slack api ? i have try these methods search.messages etc and this link https://slack.com/api/search.messages but can not show result.


Solution

  • To get all your private messages:

    1. Get the list of direct message channels you are a member of with conversations.list by setting the types property to im

    2. Do a loop over the list of all channel and query each with conversations.history to get all messages.

    Make sure to use an access token authorized by yourself to see all private channels.