Using WordPress? Every integration here is also available as a plugin. Browse the plugin store →

Knowledge base Drupal Automation and webhooks

Teams Chat Bot & Notifications Module

Create outbound triggers from Drupal events, inbound slash commands via webhook, and adaptive card templates for rich, branded messages in Microsoft Teams.

Published 25 January 2024

  • drupal
  • microsoft-teams
  • notifications
  • chatbot
  • adaptive-cards
  • collaboration
  • webhooks

Overview

The Teams Chat Bot & Notifications Module transforms how your organization communicates by bridging Drupal content workflows with Microsoft Teams. This integration enables automated notifications for content changes, interactive bot commands, and rich adaptive card messages that maintain your brand identity.

Features

  • Automated notifications for Drupal events
  • Inbound webhook support for slash commands
  • Rich adaptive card templates
  • Two-way communication between platforms
  • Customizable notification rules
  • Bot framework integration
  • Team and channel targeting
  • Message threading and replies

Technical Details

Technologies: Microsoft Teams Bot Framework, Microsoft Graph API, Adaptive Cards, Drupal Event System, Drupal Rules module, Webhooks

Requirements:

  • Drupal 9.x or 10.x
  • Microsoft Teams subscription
  • Azure Bot Service registration
  • Bot Framework SDK
  • Drupal Rules or custom event subscribers
  • HTTPS endpoint for webhooks

API Endpoints:

Send message: POST /teams/{team-id}/channels/{channel-id}/messages
Reply to message: POST /teams/{team-id}/channels/{channel-id}/messages/{message-id}/replies
Incoming webhook: POST {webhook-url}
Activity feed: POST /teams/{team-id}/sendActivityNotification

Implementation

  1. Register bot in Azure Bot Service
  2. Create Teams app manifest and install bot
  3. Implement bot message handler in Drupal
  4. Create adaptive card templates for notifications
  5. Set up Drupal event subscribers for triggers
  6. Configure webhook endpoints for inbound commands
  7. Implement slash command parsing
  8. Add message routing and channel management
  9. Create admin UI for notification rules
  10. Test bot interactions and error handling
<?php
// Example: Drupal event subscriber for Teams notifications
namespace Drupal\teams_integration\EventSubscriber;

use Drupal\Core\Entity\EntityInterface;
use Drupal\node\Event\NodeEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class TeamsNotificationSubscriber implements EventSubscriberInterface {
  
  protected $teamsClient;
  
  public function __construct($teams_client) {
    $this->teamsClient = $teams_client;
  }
  
  public static function getSubscribedEvents() {
    return [
      'node.published' => 'onNodePublished',
      'node.updated' => 'onNodeUpdated',
    ];
  }
  
  public function onNodePublished(NodeEvent $event) {
    $node = $event->getNode();
    
    // Create adaptive card
    $card = [
      'type' => 'message',
      'attachments' => [[
        'contentType' => 'application/vnd.microsoft.card.adaptive',
        'content' => [
          'type' => 'AdaptiveCard',
          'body' => [
            [
              'type' => 'TextBlock',
              'size' => 'Large',
              'weight' => 'Bolder',
              'text' => '📝 New Content Published',
            ],
            [
              'type' => 'TextBlock',
              'text' => $node->getTitle(),
              'wrap' => true,
            ],
            [
              'type' => 'TextBlock',
              'text' => $node->get('body')->summary,
              'isSubtle' => true,
              'wrap' => true,
            ],
          ],
          'actions' => [[
            'type' => 'Action.OpenUrl',
            'title' => 'View Article',
            'url' => $node->toUrl('canonical', ['absolute' => TRUE])->toString(),
          ]],
        ],
      ]],
    ];
    
    // Send to configured Teams channel
    $this->teamsClient->sendMessage($card);
  }
}

Use Cases

  • Content approval workflows with team notifications
  • Breaking news alerts to editorial teams
  • Form submission notifications to support teams
  • System status updates and alerts
  • Collaborative content review processes

Benefits

  • Real-time notifications in Teams workspace
  • Reduced email overload for team communications
  • Rich, branded message formatting
  • Interactive elements for quick actions
  • Centralized communication in Teams
  • Improved response times for urgent updates
  • Audit trail of notifications and responses

Read next

  • Drupal · Automation and webhooks

    Dynamics 365 CRM Lead Capture

    Auto-create CRM leads on form submit with UTM tracking, custom entity forms surfaced in Drupal for seamless lead management.

  • Drupal · Automation and webhooks

    Microsoft Planner Task Automation

    Create Planner tasks from Drupal events with two-way sync, custom dashboards using Drupal Views and Charts for project tracking.

  • Drupal · Automation and webhooks

    Microsoft To-Do Task Automation

    Automate task creation using Drupal Rules or event subscribers with two-way sync for task status updates reflected in Drupal.

Back to the knowledge base