Table of Contents

Getting started with TMS FNC Cloud Slack

Prerequisites

  • TMS FNC Core installed and the runtime package added to the project.
  • TMS FNC Cloud Pack installed.
  • A Slack app with OAuth credentials (client ID and secret) and the scopes your integration needs.

Add the component

  1. Drop TTMSFNCCloudSlack onto a form or create it in code.
  2. Set the OAuth credentials (Authentication.ClientID, Authentication.Secret, Authentication.CallBackURL) and add the required Scopes.
  3. Persist tokens and call Connect; once OnConnected fires, call GetAllUsers or GetUserConversations.

The minimal connect sequence — credentials, scopes, token persistence, and an OnConnected handler:

procedure TForm1.SetupSlack;
begin
  FSlack := TTMSFNCCloudSlack.Create(Self);

  // OAuth 2.0 app credentials from your Slack app configuration.
  FSlack.Authentication.ClientID := '<your-client-id>';
  FSlack.Authentication.Secret := '<your-client-secret>';
  FSlack.Authentication.CallBackURL := 'http://127.0.0.1:8888';

  // Slack requires an explicit scope for each kind of data the app touches.
  FSlack.Scopes.Clear;
  FSlack.Scopes.Add('users:read');
  FSlack.Scopes.Add('channels:read');
  FSlack.Scopes.Add('channels:history');
  FSlack.Scopes.Add('chat:write');

  FSlack.PersistTokens.Location := plIniFile;
  FSlack.PersistTokens.Key := TTMSFNCUtils.AddBackslash(TTMSFNCUtils.GetDocumentsPath)
    + FSlack.ClassName + '.ini';
  FSlack.LoadTokens;

  FSlack.OnConnected := SlackConnected;
  FSlack.Connect; // opens the browser for consent on first run, then fires OnConnected
end;

procedure TForm1.SlackConnected(Sender: TObject);
begin
  // CurrentUserID is available once connected.
  FSlack.GetAllUsers;
  FSlack.GetUserConversations(FSlack.CurrentUserID, 20);
end;

Next steps

  • Guides — authentication, users and profiles, and conversations and messages.
  • API reference — full class reference.