Back to Play 11 Resources
Play 11: Knowledge Base Q&A

Slack/Teams Bot Configuration Guide

Creating the internal Q&A bot interface connected to n8n.

Slack/Teams Bot Configuration Guide

You need a Q&A bot that actually works. Not a chatbot that gives canned responses, but a system that pulls real answers from your firm's knowledge base and delivers them where your team already works.

This guide shows you exactly how to wire up Slack or Microsoft Teams to n8n, creating a bot that queries your internal documentation, case files, or procedure manuals on demand. No fluff. Just the specific API calls, webhook configurations, and credential setups you need.

What You Need Before Starting

n8n instance running and accessible. You need a publicly accessible URL (not localhost). If you're testing locally, use ngrok to expose your n8n instance temporarily. Production deployments should use a proper domain with SSL.

Admin access to Slack or Teams. You need permission to create apps and install bots in your workspace. If you don't have this, stop now and get it from your IT admin.

Your knowledge base already indexed. This guide assumes you have documents in Pinecone, Qdrant, or another vector database

. The bot queries this database through n8n. If you haven't set that up, do it first.

Slack Bot Setup

1. Create the Slack App

Navigate to api.slack.com/apps and click "Create New App". Select "From scratch" (not from manifest).

Name it something specific: "Knowledge Base Assistant" or "Firm Q&A Bot". Generic names like "Helper" confuse users.

Select your workspace and click "Create App".

2. Configure Bot Permissions

Go to "OAuth & Permissions" in the left sidebar.

Scroll to "Scopes" and add these Bot Token Scopes:

  • chat:write (send messages)
  • channels:history (read channel messages)
  • groups:history (read private channel messages)
  • im:history (read direct messages)
  • app_mentions:read (respond when @mentioned)

Do NOT add channels:read or users:read unless you specifically need them. Minimize permissions.

3. Enable Event Subscriptions

Click "Event Subscriptions" in the left sidebar. Toggle "Enable Events" to On.

In the "Request URL" field, enter: https://your-n8n-domain.com/webhook/slack-kb-bot

Replace your-n8n-domain.com with your actual n8n URL. Slack will send a verification challenge to this endpoint. You need to set up the n8n webhook

BEFORE Slack will verify it.

Set up the n8n webhook

now:

  1. Open n8n and create a new workflow
  2. Add a "Webhook
    " node as the first step
  3. Set HTTP Method to "POST"
  4. Set Path to slack-kb-bot
  5. In the "Respond" section, select "Immediately"
  6. Add a "Respond to Webhook
    " node
  7. Set Response Code to 200
  8. In Response Body, add: {{$json["challenge"]}}

Save and activate this workflow. Now return to Slack and click "Retry" on the Request URL verification. It should show "Verified".

4. Subscribe to Events

Still in Event Subscriptions, scroll to "Subscribe to bot events". Add:

  • app_mention (when someone @mentions your bot)
  • message.channels (public channel messages)
  • message.groups (private channel messages)
  • message.im (direct messages to the bot)

Click "Save Changes". Slack will prompt you to reinstall the app. Do it.

5. Install the App and Get the Token

Go to "Install App" in the left sidebar. Click "Install to Workspace" and authorize.

Copy the "Bot User OAuth Token". It starts with xoxb-. Store this securely. You'll add it to n8n credentials.

6. Build the n8n Workflow

Delete the simple verification workflow you created earlier. Build the real one:

Node 1: Webhook

(Trigger)

  • HTTP Method: POST
  • Path: slack-kb-bot
  • Respond: Using 'Respond to Webhook
    ' Node

Node 2: Code Node (Extract Question)

// Extract the user's question from Slack event
const event = $input.item.json.event;
const text = event.text || '';
const userId = event.user;
const channel = event.channel;

// Remove bot mention from text
const question = text.replace(/<@[A-Z0-9]+>/g, '').trim();

return {
  json: {
    question: question,
    userId: userId,
    channel: channel
  }
};

Node 3: HTTP Request (Query Your Vector DB)

Configure this based on your vector database

. Example for Pinecone:

  • Method: POST
  • URL: https://your-index.pinecone.io/query
  • Authentication: Header Auth
  • Header Name: Api-Key
  • Header Value: {{$credentials.pineconeApiKey}}
  • Body (JSON):
{
  "vector": "`{{$json.embedding}}`",
  "topK": 3,
  "includeMetadata": true
}

You'll need an embedding step before this. Add an OpenAI node set to "Create Embedding" using the question text.

Node 4: OpenAI Node (Generate Answer)

  • Operation: Message a Model
  • Model: gpt-4
  • Prompt:
You are a knowledge base assistant for [YOUR FIRM NAME]. Answer the following question using ONLY the provided context. If the context doesn't contain the answer, say "I don't have that information in the knowledge base."

Context:
`{{$json.matches[0].metadata.text}}`
`{{$json.matches[1].metadata.text}}`
`{{$json.matches[2].metadata.text}}`

Question: `{{$('Code').item.json.question}}`

Answer:

Node 5: Slack Node (Send Response)

  • Credential: Add your Bot User OAuth Token here
  • Resource: Message
  • Operation: Post
  • Channel: {{$('Code').item.json.channel}}
  • Text: {{$json.choices[0].message.content}}

Node 6: Respond to Webhook

  • Response Code: 200
  • Response Body: {"ok": true}

Connect these nodes in sequence. Activate the workflow.

7. Test It

In any Slack channel where the bot is present, type: @Knowledge Base Assistant what is our document retention policy?

The bot should respond within 3-5 seconds with an answer pulled from your knowledge base.

If it doesn't work:

  • Check n8n execution logs for errors
  • Verify the webhook
    URL is publicly accessible
  • Confirm the bot token starts with xoxb-
  • Make sure the bot is invited to the channel (/invite @Knowledge Base Assistant)

Microsoft Teams Bot Setup

1. Register the Bot in Azure

Go to portal.azure.com and sign in. Search for "Azure Bot" and click "Create".

Fill in:

  • Bot handle: kb-assistant-bot (must be globally unique)
  • Subscription: Your Azure subscription
  • Resource group: Create new or use existing
  • Pricing tier: F0 (free tier works fine for internal use)
  • Microsoft App ID: Create new

Click "Review + create", then "Create".

2. Get Your App Credentials

Once deployed, go to the bot resource. Click "Configuration" in the left menu.

Copy the "Microsoft App ID". Click "Manage" next to it.

In the Certificates & secrets page, click "New client secret". Add a description like "n8n integration" and set expiration to 24 months.

Copy the secret VALUE immediately. You cannot retrieve it later. Store it securely.

3. Set the Messaging Endpoint

Back in the bot Configuration page, set Messaging endpoint to: https://your-n8n-domain.com/webhook/teams-kb-bot

Click "Apply".

4. Connect to Microsoft Teams

In the bot resource, click "Channels" in the left menu. Click the Teams icon.

Accept the terms and click "Apply". Teams is now enabled.

5. Create the Teams App Manifest

Create a file named manifest.json:

{
  "$schema": "https://developer.microsoft.com/json-schemas/teams/v1.16/MicrosoftTeams.schema.json",
  "manifestVersion": "1.16",
  "version": "1.0.0",
  "id": "YOUR-APP-ID-HERE",
  "packageName": "com.yourfirm.kbassistant",
  "developer": {
    "name": "Your Firm Name",
    "websiteUrl": "https://yourfirm.com",
    "privacyUrl": "https://yourfirm.com/privacy",
    "termsOfUseUrl": "https://yourfirm.com/terms"
  },
  "name": {
    "short": "KB Assistant",
    "full": "Knowledge Base Assistant"
  },
  "description": {
    "short": "Internal knowledge base Q&A",
    "full": "Ask questions and get answers from the firm's knowledge base"
  },
  "icons": {
    "outline": "outline.png",
    "color": "color.png"
  },
  "accentColor": "#FFFFFF",
  "bots": [
    {
      "botId": "YOUR-APP-ID-HERE",
      "scopes": ["personal", "team"],
      "supportsFiles": false,
      "isNotificationOnly": false
    }
  ],
  "permissions": ["identity", "messageTeamMembers"],
  "validDomains": []
}

Replace YOUR-APP-ID-HERE with your Microsoft App ID (twice).

Create two icon files: outline.png (32x32, transparent) and color.png (192x192). Simple logo images work fine.

Zip these three files together: manifest.json, outline.png, color.png. Name it kb-assistant.zip.

6. Install in Teams

Open Microsoft Teams. Click "Apps" in the left sidebar. Click "Manage your apps" then "Upload an app".

Select "Upload a custom app" and choose your kb-assistant.zip file.

Click "Add" to install it for yourself, or "Add to a team" to install it in a specific team channel.

7. Build the n8n Workflow

Node 1: Webhook

(Trigger)

  • HTTP Method: POST
  • Path: teams-kb-bot
  • Respond: Using 'Respond to Webhook
    ' Node

Node 2: Code Node (Extract Question)

// Teams sends different event types
const activity = $input.item.json;

// Ignore non-message activities
if (activity.type !== 'message') {
  return { json: { skip: true } };
}

const question = activity.text || '';
const conversationId = activity.conversation.id;
const serviceUrl = activity.serviceUrl;

return {
  json: {
    question: question,
    conversationId: conversationId,
    serviceUrl: serviceUrl,
    from: activity.from.id
  }
};

Node 3-4: Same vector DB query and OpenAI nodes as Slack version

Node 5: HTTP Request (Send Teams Response)

  • Method: POST
  • URL: {{$('Code').item.json.serviceUrl}}/v3/conversations/{{$('Code').item.json.conversationId}}/activities
  • Authentication: Header Auth
  • Header Name: Authorization
  • Header Value: Bearer {{$credentials.teamsAccessToken}}
  • Body (JSON):
{
  "type": "message",
  "text": "`{{$('OpenAI').item.json.choices[0].message.content}}`"
}

For the access token, you need to add a separate HTTP Request node that runs first to get a token from Microsoft:

  • Method: POST
  • URL: https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token
  • Body (Form):
    • grant_type: client_credentials
    • client_id: Your Microsoft App ID
    • client_secret: Your client secret
    • scope: https://api.botframework.com/.default

Extract the access token from the response and use it in the Authorization header.

Node 6: Respond to Webhook

  • Response Code: 200

Activate the workflow.

8. Test It

In Teams, find your bot in the Apps section and start a chat. Type: what is our document retention policy?

The bot should respond with an answer from your knowledge base.

If it doesn't work:

  • Check that the messaging endpoint is correct in Azure
  • Verify the App ID and secret are correct in n8n
  • Look at n8n execution logs for authentication errors
  • Confirm the bot is properly installed in Teams

Production Checklist

Before rolling this out firm-wide:

Rate limiting: Add a rate limit node in n8n to prevent abuse. Limit to 10 requests per user per minute.

Logging: Store all questions and answers in a database. Use this to improve your knowledge base and identify gaps.

Fallback responses: When the bot can't find an answer, direct users to a human expert or a help desk ticket system.

Access control: Restrict the bot to specific channels or users if your knowledge base contains sensitive information.

Monitoring: Set up alerts in n8n for workflow failures. You need to know immediately if the bot stops working.

Token refresh: Microsoft Teams tokens expire. Implement automatic token refresh in your n8n workflow.

Your bot is now live. Monitor usage for the first week and adjust the system prompt based on the types of questions people actually ask.

Revenue Institute

Reviewed by Revenue Institute

This guide is actively maintained and reviewed by the implementation experts at Revenue Institute. As the creators of The AI Workforce Playbook, we test and deploy these exact frameworks for professional services firms scaling without new headcount.

Revenue Institute

Need help turning this guide into reality? Revenue Institute builds and implements the AI workforce for professional services firms.

RevenueInstitute.com