Slack and Teams Integration Advanced

Deploying your AI chatbot into Slack or Microsoft Teams puts it where your NOC team already works. ChatOps integration means engineers can troubleshoot network issues without leaving their collaboration platform, and the diagnostic conversation becomes part of the team's shared knowledge.

Slack Bot Implementation

Python
from slack_bolt import App
from network_chatbot import NetworkChatbot

app = App(token=os.environ["SLACK_BOT_TOKEN"])
chatbot = NetworkChatbot()
conversations = {}  # Thread-based conversation storage

@app.event("app_mention")
def handle_mention(event, say):
    thread_ts = event.get("thread_ts", event["ts"])
    user_msg = event["text"]

    # Get or create conversation history for this thread
    history = conversations.get(thread_ts, [])

    # Process through AI chatbot
    response = chatbot.chat(user_msg, history)

    # Store updated history
    history.append({"role": "user", "content": user_msg})
    history.append({"role": "assistant", "content": response})
    conversations[thread_ts] = history

    say(text=response, thread_ts=thread_ts)

app.start(port=3000)

Microsoft Teams Integration

For Teams, use the Bot Framework SDK to receive messages and respond with diagnostic results. The architecture is similar to Slack but uses Microsoft's Bot Connector service.

ChatOps Best Practices

PracticeImplementation
Thread-based conversationsKeep diagnostic conversations in threads to avoid channel noise
Rich formattingUse Slack blocks / Teams adaptive cards for structured output
Reaction-based feedbackLet users thumbs-up/down responses to improve quality
Escalation pathAllow chatbot to tag senior engineers when it cannot resolve an issue
Channel Strategy: Create dedicated channels for different use cases: #noc-bot for general queries, #network-alerts for automated alert enrichment, and #change-review for change impact analysis.

Try It Yourself

Create a basic Slack or Teams bot using the respective SDK. Connect it to your network chatbot backend and test with simple device status queries from your team's channel.

Next: Best Practices →