XWiki Slack Integration Guide
Install XWiki Slack Integration, create your Slack app, link accounts, post the changes of the wiki in Slack channels and search it from Slack, with the access rights of the wiki applied.
Available in:
- English
- German
- Spanish
- French
- Italian
- Dutch
- Portuguese (Brazil)
Overview
XWiki Slack Integration, by Agnease, connects an XWiki farm to one Slack workspace. The changes of a page and of the pages under it, or of a whole wiki, are posted in the Slack channels chosen for them, everyone in the workspace can use and search the wiki from Slack with the /xwiki command, and the links to the wiki posted in Slack get a preview. Each wiki of the farm keeps its own Slack data: the links of its users, the channels of its pages and the messages posted for them.
This guide is organized by audience: users link their Slack account and use /xwiki, page and wiki administrators choose the channels and the changes they receive, and administrators install the extension and connect the wiki to Slack.
How It Works
- Your Slack administrator creates a Slack app in your own workspace, from settings prepared by the wiki, and gives its tokens to the wiki.
- The wiki opens a connection to Slack with Socket Mode and keeps it open. Slack sends the /xwiki commands and its events through it.
- Users link their Slack account to their wiki account, from Slack with /xwiki connect or from their profile with a code, so that the wiki knows who they are.
- The administrators of a page, or of a wiki, connect it to a Slack channel they are a member of, and choose the changes it receives.
- When one of these changes happens, the wiki reads the members of the channel and posts the change, in full or without its details.
| Situation | Result |
|---|---|
| Every member of the channel can view the page | The change is posted with the title of the page, its location and the author, the text of a comment or annotation, and, for an update, a link to its changes and the comment of its author. |
| A member of the channel can't view the page, or has no linked account | The channel is told that a page was created, updated or deleted, or that a comment was added, under the connected page, with a link that opens the page only for the users allowed to view it. |
| The event is addressed to some users, such as a mention | The event is never posted in a channel. |
| The page is hidden, or is the preferences of a page | The change is not posted. |
The wiki talks to Slack directly, through the app of your organization, without any third-party service: no Agnease server sees your content.
Key Terms
| Term | Meaning |
|---|---|
| Slack app | The app your organization creates in its Slack workspace. Slack users see its name on the messages of the wiki, the name of the wiki by default. |
| Manifest | The settings of the Slack app, prepared by the wiki, that Slack fills in when the app is created. |
| Bot token | The token the wiki uses to post messages and read the members of the channels. It starts with xoxb-. |
| App-level token | The token the wiki uses to open the Socket Mode connection. It starts with xapp-. |
| Socket Mode | The connection that the wiki opens to Slack, through which Slack sends its requests. The wiki needs no public address. |
| Linked account | A Slack account linked to a wiki account by its user, with /xwiki connect. It is kept in the wiki of the account, at most one per wiki. |
| Guest | A member of a channel whose Slack account is not linked to a wiki account, another bot, or a member of another organization in a shared channel. |
| Page with children | A non-terminal page of XWiki, which can have children, even before its first child. A channel follows such a page and the pages under it, or a whole wiki. |
| Change | What a channel receives: pages created, updated or deleted, comments and annotations added, and the events of the applications. |
Install and Connect
Requirements
- XWiki 16.10.0 or later.
- Administration rights on the main wiki, and the right to install extensions on the whole farm.
- Access to the xwiki.properties file of the installation, to add the Agnease extension repository.
- A Slack workspace where you may create and install apps.
- Outgoing HTTPS connections from the server of the wiki to slack.com, and WebSocket (wss) connections to its subdomains, through the proxy of the server if there is one. The wiki needs no public address.
Add the Agnease Extension Repository
The extension is distributed by the Agnease extension repository, which XWiki doesn't use by default.
- Open the 1. In the 1. Add the Agnease repository after them:extension.repositories = maven-xwiki:maven:https://nexus.xwiki.org/nexus/content/groups/public
extension.repositories = store.xwiki.com:xwiki:https://store.xwiki.com/xwiki/rest/
extension.repositories = extensions.xwiki.org:xwiki:https://extensions.xwiki.org/xwiki/rest/
extension.repositories = agnease.com:xwiki:https://agnease.com/rest/ - Restart XWiki.
Install the Extension
- Log in to the main wiki as an administrator.
- Open Administration > Extensions.
- Search for Slack Integration, the name of XWiki Slack Integration in the Extension Manager: the Agnease repository lists it with the other extensions.
- Click Install on farm, and choose to install it on the whole farm.
- Check that Administration > Social > Slack is now available on the main wiki.
Create the Slack App
Open Administration > Social > Slack on the main wiki.
- In 1. Create the Slack app, check the name of the app: Slack users see it on the messages of the wiki. By default, it is the name of the wiki. Change it and click Save the name if needed.
- Click Create the app in Slack. Slack opens with the settings of the app filled in: choose your workspace, review the settings and click Create.
- If Slack doesn't install the app at once, open Install App in the settings of the app, click Install to Workspace and allow it.
- Copy the Bot User OAuth Token from OAuth & Permissions. It starts with xoxb-.
- In Basic Information, under App-Level Tokens, click Generate Token and Scopes, give it a name, add the scope connections:write, generate it and copy it. It starts with xapp-.
Connect the Wiki to Slack
- In 2. Connect with the tokens of the app, paste both tokens.
- Click Save.
The status at the top of the section shows the workspace and the app found by Slack, and 3. Check the connection shows Connected to Slack through Socket Mode within a few seconds. The tokens are encrypted before they are saved, and their fields show stars from then on.
Test the Connection
- Type /xwiki help in any channel of Slack: the app answers, and only you see the answer.
- Invite the app to a channel by typing /invite @ followed by the name of the app in the channel.
- In 3. Check the connection, enter the channel and click Send a test message.
The check also lists the workspace, the app and the permissions that Slack reports, and the permissions the installed version needs that the app lacks.
Disconnect the Wiki
Click Disconnect in the Slack section: the tokens are removed. The app stays in the Slack workspace until a Slack administrator deletes it from its settings.
When the app is uninstalled from Slack, or its token revoked, the status says so. Reinstall the app and save its new bot token: the app-level token stays the same.
For Users
Use the Wiki from Slack
Everyone in the Slack workspace can type /xwiki in a channel or a direct message. The answer is shown only to the person who typed the command.
| Command | What it does |
|---|---|
| /xwiki help | Shows what you can do with the wiki from Slack, with a link to the wiki. |
| /xwiki connect | Links your Slack account to your account on the wiki: see below. /xwiki connect followed by a code links it with a code got in the wiki. |
| /xwiki account | Shows the accounts of the wikis that your Slack account is linked to, each with a link to the Slack section of its profile. |
| /xwiki disconnect | Unlinks your Slack account from your accounts on the wikis, at once. |
| /xwiki subscribe page | Posts in this channel the changes of the page and of the pages under it. |
| /xwiki unsubscribe page | Stops posting in this channel the changes of the page. |
| /xwiki subscriptions | Lists the pages connected to this channel that you can view. |
| /xwiki search text | Lists the first 5 pages of the wikis matching the text that you can view, with a link to all the results in the wiki. |
Search the Wiki from Slack
/xwiki search followed by words, such as /xwiki search budget 2027, searches the pages of all the wikis of the farm, as the search of the wiki does, and lists the first 5 that you can view, with their location and a link to all the results in the wiki.
- The pages are those that your linked account can view: in each wiki, your account of that wiki, else your account of the main wiki. Without a linked account, only the pages that guests can view are listed.
- When the farm has several wikis, the location of each page starts with the name of its wiki. Hidden pages are not listed.
- The search uses the search index of the wiki: a page created or changed a moment ago may be found a few seconds later.
Previews of Wiki Links
When someone posts in Slack the address of a page of the wiki, as the browser shows it, Slack shows a preview under the link: the title of the page, where it is in the wiki, the start of its text, who changed it last and when. The preview is added only when every member of the conversation can view the page; otherwise Slack shows the link alone.
- The start of the text is the content of the page in plain text, at most 300 characters, without what its macros display: they are not run for Slack.
- In a direct message or a group conversation, only the pages that guests can view get a preview.
- Hidden pages, pages that don't exist, attachments and other actions than viewing a page get no preview.
- A preview stays as it was when the link was posted: it is not updated when the page or its rights change.
- Slack previews only the links to the domains given in the manifest of the app: the domain of the main wiki and the domains of the wikis that have their own, five at most. The links to an IP address or to a name without a domain, such as localhost, get no preview.
Link Your Slack Account
The wiki needs to know who you are on the wiki to show you in Slack only what you can see on the wiki. Nothing links the accounts automatically: email addresses and names can be changed, so only logging into the wiki proves who you are there.
There are two ways to link it, and they give the same link.
From Slack, for an account of the main wiki:
- Type /xwiki connect in Slack. Only you see the answer, with a link to the main wiki.
- Open the link within 10 minutes, and log into the wiki if it asks you to.
- Check the Slack account, as Slack shows its name, its workspace and the account of the wiki shown on the page, and click Link my Slack account.
From the wiki, for any account, and the only way for a local account of a subwiki, since the link from Slack opens the main wiki, where that account can't log in:
- Log into the wiki of your account, open your profile and its Slack section, and click Get a code.
- Click Copy next to the command shown, such as /xwiki connect sales.K7F3M9QX2TRF4ABC, and paste it in an empty message in Slack within 10 minutes: it is the whole command, /xwiki connect included. If you already typed /xwiki connect, pasting the command or only the code after it works too.
Slack answers with the account of the wiki now linked. The code names the wiki of your account and works once; a new code replaces the previous one, and a code is offered only while no Slack account is linked to your account. The same code can be got on the page Slack.LinkAccount of your wiki, for a wiki whose user profiles have no Slack section.
Your Slack account is now linked, and the wiki notifies you of the link, with the Slack account and its workspace. The channels you are a member of can now receive the details of the pages you can view.
The link is kept in the wiki of your account: an account of the main wiki, which reaches every wiki of the farm, or a local account of a subwiki. Your Slack account can be linked to one account in each wiki: in a wiki, it acts as your account of that wiki, else as your account of the main wiki. To link it to another account, link it again with that account: the new link replaces the previous one in the wiki of that account.
The notification of a new link is turned on in every wiki of the farm when XWiki Slack Integration is installed, and in a new wiki when it starts. An administrator can turn it off in the default notification settings of the wiki, and each user in their own notification settings, under Slack.
Unlink Your Slack Account
- In Slack, type /xwiki disconnect: it removes the links of your Slack account in all the wikis.
- In the wiki, open the Slack section of your profile and click Unlink. The section shows the Slack account linked to your account and since when.
The administrators of a wiki see the Slack section of the profiles of the users of that wiki, and can unlink their Slack accounts. Other users don't see it. When a user is deleted or disabled, the links of their Slack accounts are removed too: a disabled user can't act in the wiki from Slack.
For Page Administrators
Post the Changes of a Page in a Channel
The administrators of a page with children choose the Slack channels where the changes of the page and of the pages under it, at any depth, are posted, and which changes each channel receives.
- Link your Slack account with /xwiki connect, if it isn't linked yet. Only a member of a channel can connect a page to it, so that nobody posts in the channels of other teams.
- Invite the app to the channel: type /invite followed by the name of the app in the channel.
- In the administration of the page, open Social > Slack notifications.
- Type the name of the channel, such as product, tick the changes to post, and click Add the channel.
The app posts a message in the channel to say which changes it now receives; if it can't, the section tells why.
| Change | Posted |
|---|---|
| Pages created under this page | A page created under the page, at any depth. Ticked by default. |
| Pages updated, this one included | A page saved with a major change, the page itself included. Posted in full, it links to the changes of the version and shows the comment its author gave when saving it. |
| Pages updated by a minor change, this one included | A page saved with Minor edit ticked. Tick it with the previous one to receive every change. |
| Pages deleted, this one included | A page deleted, the page itself included. The message has no link: the page no longer exists. |
| Comments added, on this page included | A comment added to the page or to a page under it, with its text when every member of the channel can view the page. |
| Annotations added, on this page included | An annotation added, with the annotated text and the annotation when every member of the channel can view the page. |
The text of a comment or of an annotation is shown as plain text, shortened after 500 characters, and its macros are not run. Adding a comment or an annotation is posted as the comment or the annotation, never as an update of the page. A page moved or renamed is posted as a page deleted and a page created.
Post the Events of the Applications
Under Events of the applications, the section lists the events that XWiki and the installed applications declare for the notifications of the wiki, such as the likes or the steps of a review, grouped by application.
- Expand an application to see its events, with their description.
- Tick the events to post, or tick an application to tick all its events. Use select all or none above the tree.
- Click Add the channel.
Such an event is posted with its description, in full or without details as the other changes. An application that declares its events for the notifications of the wiki, in Java or in a wiki page with an XWiki.EventStream.Code.EventClass object, needs nothing more: its events appear in the list as soon as it is installed.
Events addressed to some users, such as mentions or the alerts of an account, are personal: they are not listed and never posted in a channel.
Post the Changes of a Whole Wiki
The home page of a wiki is not the parent of its other pages, so a page can't bring the changes of the whole wiki. The administrators of a wiki connect a channel to all its pages in the administration of the wiki, under Social > Slack notifications, the same way as for a page: the channel receives the changes chosen for it of every page of the wiki, with the same rule for the details of the pages. In a farm, each wiki has its own channels. When the same channel is also connected to a page, a change under that page is posted once, as the changes chosen for that page.
Change or Remove a Channel
The channels of the page are listed in a table, with the changes each one receives. Filter it by channel or by change.
- To change the changes a channel receives, add it again with other changes ticked, in the form Add a Slack channel, or change the changes posted in one: they replace its own.
- To stop posting in a channel, click Remove in its row.
Connect a Page from Slack
You can also connect a page from the channel itself, when you are a member of the channel and your linked wiki account has the administration right on the page.
- In the channel, type /xwiki subscribe followed by the page: its address, as your browser shows it, or its reference, as the Information tab of the page shows it./xwiki subscribe https://wiki.example.com/xwiki/bin/view/Product/
/xwiki subscribe Product.WebHome
/xwiki subscribe sales:Product.WebHome - Check the message posted by the app in the channel.
A channel connected from Slack receives the pages created, or keeps the changes it already had; the answer links to the Slack notifications of the page, where the changes of the channel are chosen. Type /xwiki unsubscribe followed by the same page to stop it, and /xwiki subscriptions to list the pages connected to the channel: each user sees only the pages they can view.
What the Channel Sees
When a change is posted, the wiki reads the members of the channel.
- When every member can view the page, the change is posted in full, with the title of the page, its location, the author of the change, the text of a comment or annotation, and, for an update, a link to its changes and the comment of its author.
- Otherwise, the message says that a page was created, updated or deleted, or that a comment was added, under the page connected to the channel, with a link that opens the page only for the users allowed to view it, and tells nothing about it to the others.
A member whose Slack account is not linked to a wiki account counts as a guest, and so do other bots and the members of another organization in a channel shared with it. Nothing is ever skipped: everyone in the channel learns that something happened, and those allowed to view the page open it. Linking the Slack accounts with /xwiki connect is what lets the channels receive the details of the pages that are not public.
The message posted when a page is connected names the page, as a link of the wiki shows its title to users who can't view it.
Several Channels and Nested Pages
- A page can be connected to several channels, for example the channels of two teams following it. Each channel receives its own changes, in full or without their details depending on its own members.
- When a channel is connected to a page and to one of its children, a change under that child is posted once, as the changes chosen for the child, naming the child.
- Hidden pages and the preferences of the pages are not posted.
- The channels of the pages of a wiki are kept in that wiki, on a page that only its administrators can see.
Security and Operations
Slack Permissions
The app asks Slack only for the permissions that the installed version uses.
| Permission | Used to |
|---|---|
| chat:write | Post messages in the channels where the app was invited. |
| commands | Receive the slash command /xwiki. |
| channels:read, groups:read | Read the members of the public and private channels where the changes are posted. |
| users:read | Read the name that Slack shows for a user who types /xwiki connect, shown on the page confirming the link. |
| links:read, links:write | Receive the links to the wiki posted in Slack and add their previews: asked only when the wiki is reached by a domain name. |
| connections:write | Open the Socket Mode connection, on the app-level token. |
The app also receives these Slack events:
| Event | What the wiki does |
|---|---|
| app_uninstalled | Shows in the Slack administration that the app was uninstalled. |
| tokens_revoked | Shows in the Slack administration that the bot token was revoked. |
| member_joined_channel, member_left_channel | Reads the members of the channel again before posting the next change there. |
| link_shared | Adds a preview under the links to the pages of the wiki, when every member of the conversation can view the page. |
Network and Socket Mode
The wiki opens the connection to Slack with the app-level token and keeps it open: nothing reaches the wiki from outside, and the wiki has no address open to Slack. Each server of a cluster opens its own connection, and opens it again when Slack refreshes it, when it breaks and when the settings change.
Protect the Encryption Key
The tokens are encrypted with a key kept outside of the database. By default it is generated, the first time a token is saved, in the slack/secret-encryption.key file of the XWiki permanent directory.
To provide the key yourself, for instance when several servers share the database, set the same key on all of them in xwiki.properties, as 32 random bytes encoded in Base64:
base64 -w0 /var/lib/xwiki/data/slack/secret-encryption.key
# New installation: generate a key
openssl rand -base64 32
Server Settings
These optional properties go in xwiki.properties; restart the wiki after changing them.
| Property | Use |
|---|---|
| slack.secretEncryptionKey | The key encrypting the Slack secrets, 32 bytes encoded in Base64. By default, a key generated in the permanent directory. |
| slack.apiURL | The address of the Slack Web API, https://slack.com/api/ by default. Change it only for a Slack offer using another address. |
Messages Posted in Slack
The Slack section of the administration of each wiki lists, under Messages posted in Slack, the last messages that this server posted, or tried to post, for the pages of that wiki since it started, the newest first (100 at most for all the wikis): the date, the channel, the page, the change, and what happened.
- A message posted without the details of the page says why: a member of the channel without a linked account, a member who can't view the page, or members that the app can't read.
- A message that Slack refused shows the error of Slack, and a message that Slack couldn't take for a while is tried again later.
- The text of the messages is not kept, and a page is named only to an administrator allowed to view it.
- In a cluster, each server lists the messages it posted: the server where a change happens posts it.
Message Delivery and Slack Limits
- The messages are posted one after the other, at least one second apart in each channel, as Slack asks, without delaying the other channels.
- The members of a channel are read at most once every 10 seconds, and again as soon as Slack reports a member joining or leaving it.
- When Slack limits the calls or can't be reached, the wiki tries again later, a few times. The messages still waiting when the wiki stops are not posted.
- The values coming from the wiki, such as titles, names, comments and annotations, are escaped: Slack formatting, links and mentions in them are not interpreted.
- The changes are posted from the events that the wiki stores for its notifications: the wiki must store them, as it does by default.
Languages
XWiki Slack Integration is available in English, French, German, Dutch, Spanish, Italian and Brazilian Portuguese. The pages of the wiki follow the language of each user. The messages posted in Slack and the answers to /xwiki use the default language of the main wiki, since they are not addressed to one user of the wiki.
Upgrade and Uninstall
To upgrade:
- Upgrade the extension from the Extension Manager.
- Open Administration > Social > Slack and check the connection. When the new version needs more permissions, the check lists the missing ones: update the app with the manifest of step 1 (App Manifest in the settings of the app) and reinstall it in the workspace.
- Type /xwiki help in Slack, and check that a change is posted in a connected channel.
To uninstall, click Disconnect in the Slack section, uninstall the extension from the Extension Manager, then delete the app from its settings in Slack.
Troubleshooting and FAQ
Connection and Channel Messages
| Message | What to do |
|---|---|
| Slack cannot be reached from the wiki | Check that the server of the wiki can open HTTPS connections to slack.com. |
| Slack does not recognize this token | Copy the Bot User OAuth Token again from OAuth & Permissions in the settings of the app. |
| The app is not a member of this channel | Invite the app to the channel with /invite, then send the test message or save the channel again. |
| The saved bot token cannot be decrypted | The encryption key was changed or lost: save the bot token again. |
| Slack reported that the app was uninstalled, or that the bot token was revoked | Reinstall the app from its settings in Slack and save its new bot token. |
| The Slack app lacks permissions that this version of XWiki Slack Integration needs | Update the app with the manifest of step 1 and reinstall it in the workspace. |
| Link your Slack account first, in Slack notifications | Type /xwiki connect in Slack and confirm the link, then add the channel again. |
| Your Slack account is not a member of this channel, in Slack notifications | Join the channel in Slack, or ask one of its members who administers the page to connect it. A channel that the app can't see, such as a private channel it wasn't invited to, gets the same message. |
| The wiki is not connected to Slack, in Slack notifications | An administrator of the main wiki connects it in the Slack section of its administration. |
| This link is no longer valid | The link given by /xwiki connect works once, within 10 minutes: type /xwiki connect again in Slack. |
| This code is not valid, in Slack | A code works once, within 10 minutes: get a new one in the Slack section of your profile. |
| The connection to Slack failed | The message tells why: an app-level token that Slack doesn't recognize or that was revoked (generate a new one), a bot token saved as app-level token, or Slack unreachable (check the outgoing connections of the server). The wiki tries again automatically. |
Why Doesn't /xwiki Answer?
- Check that 3. Check the connection shows Connected to Slack through Socket Mode.
- When /xwiki answers dispatch_failed or nothing, check that the app uses the manifest of step 1, and that WebSocket connections to *.slack.com are allowed.
- When /xwiki isn't offered in Slack, the app was created before the installed version: update it with the manifest of step 1 and reinstall it.
Why Is a Change Posted Without Its Details?
At least one member of the channel can't view the page, or counts as a guest. Messages posted in Slack, in the Slack administration, tells which: usually a member whose Slack account isn't linked, who types /xwiki connect. Otherwise, check the rights of the page.
Why Isn't a Change Posted?
Check that:
- the change is ticked for the channel, in the Slack notifications of the connected page;
- the page is neither hidden nor the preferences of a page, and the event isn't addressed to some users only;
- the app is still a member of the channel;
- the wiki is connected to Slack;
- the wiki stores the events of its notifications.
Messages posted in Slack shows whether the message was tried and what Slack answered.
Can I Connect a Page Without Children?
Yes, when it can have children: a non-terminal page, such as Main.WebHome on a new wiki, is connected even before its first child, and the pages created under it later are posted too. Only a terminal page, which can't have children, can't be connected: connect its parent instead, whose changes include it, or connect the whole wiki in its administration.
Can the Users of a Subwiki Link Their Slack Account?
Yes. A local user of a subwiki gets a code in the Slack section of their profile, in their own wiki, and types it in Slack with /xwiki connect. The link from /xwiki connect alone opens the main wiki, where their account can't log in; it names no wiki of the farm.
Can Several Slack Workspaces Be Connected?
No. One Slack workspace is connected to the whole wiki farm.
Need help connecting XWiki to Slack?
Agnease can review your network and wiki farm setup, create the Slack app with you and plan the rollout to your teams.