-1

I want to capture the chat conversation programmatically from Slack windows app. I have tried to figured out the chat logs location locally but it seems that Slack app does not store its chat history locally. Please let me know how could I capture the chat logs by using cpp or c#?

Thanks.

Erik Kalkoken
  • 30,467
  • 8
  • 79
  • 114
sam
  • 481
  • 2
  • 8
  • 21

1 Answers1

4

Your assumption about how the Slack desktop works is incorrect. The app is just a viewer, all the content is stored in the cloud, not locally.

You can indeed "capture" any chat log from Slack given you have the permission to do so. Slack has an API that offers this functionality among others. To retrieve the chat from a channel you want to call conversations.history.

To get a token you need to create a Slack app and install that app into a workspace. Check out this link for more info on how to create a Slack app.

It's also possible to access the chat history of multiple Slack workspaces from one Slack app. For that each workspace has to install your Slack app once. During installation your Slack app will receive a newly generated token for the respective workspace, which it should store for later user.

Erik Kalkoken
  • 30,467
  • 8
  • 79
  • 114
  • @sam Here is an example on how to work with the Slack API in C#: https://stackoverflow.com/questions/53192395/how-to-post-a-message-via-slack-app-from-c-as-a-user-not-app-with-attachment – Erik Kalkoken Oct 15 '19 at 11:55
  • How to get a token and channel? – sam Oct 15 '19 at 12:51
  • You need to create and install a Slack app into your workspace: https://api.slack.com/start/overview – Erik Kalkoken Oct 15 '19 at 13:05
  • Ok. If I create an app then I can capture the chat logs from that particular app by using its token and channel. Correct? But I am trying to develop the monitoring app which will monitor the chat logs from slack without creating app. is it possible? – sam Oct 15 '19 at 13:24
  • As I said before: Your new app will be able to see all chat history of all apps and users, not only the one related to your app. It's only limited by what channels the user that installs the app has access to – Erik Kalkoken Oct 15 '19 at 13:32
  • It is possible to create a so called legacy token that gives you access to the API without having to install a Slack app. But installing a Slack app is the recommended solution. And you have access to the same channels as if you install a Slack app. see here for legacy token. https://api.slack.com/custom-integrations/legacy-tokens – Erik Kalkoken Oct 15 '19 at 13:35
  • I have generated the token and now able to view the chat logs. Thanks. But I am trying to create a generic app which will monitor the chat logs from different Slack Workspace. Do I need every workspace's token to get the chat logs? If yes then how could I get it if I don't have any credentials for that workspace? – sam Oct 15 '19 at 14:36
  • Yes, you need a token from every workspace. For that each workspace has to install your Slack app once. During the installation process your app will receive the token for that workspace, which it can then store and use to retrieve chat logs from the respective workspace. – Erik Kalkoken Oct 15 '19 at 14:46
  • Obviously the installation is done by a user that has credentials for that particular workspace. Usually you would publish your app to the App Directory so people can install it. But it's also possible to install Slack apps directly from a web page. – Erik Kalkoken Oct 15 '19 at 14:49
  • Hi Erik, can you please tell me how can we capture the received chat logs. I know that by using conversation.history API we can get the list of chat history, but I want to capture the current chat log – sam Oct 17 '19 at 09:44
  • That is the same thing. conversations.history will give you the most current chat log. – Erik Kalkoken Oct 17 '19 at 11:21