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
- Drop
TTMSFNCCloudSlackonto a form or create it in code. - Set the OAuth credentials (
Authentication.ClientID,Authentication.Secret,Authentication.CallBackURL) and add the requiredScopes. - Persist tokens and call
Connect; onceOnConnectedfires, callGetAllUsersorGetUserConversations.
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.