Search by

flowgistics / converse-ms-botframework

AmandoVledder

Microsoft Teams (Bot Framework) driver for Laravel Converse.

Package info

github.com/Flowgistics/converse-ms-botframework

Homepage

pkg:composer/flowgistics/converse-ms-botframework

Fund package maintenance!

flowgistics

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.0.1 2026-12-01 19:46 UTC

This package is not auto-updated.

Last update: 2026-12-02 05:31:10 UTC


README

Converse for Microsoft Teams

Packagist PHP from Packagist GitHub Workflow Status (main) Total Downloads

A Microsoft Teams driver for Laravel Converse, built on the Microsoft Bot Framework. Your existing Converse bots, handlers, agents, cards and approvals work in Teams personal chats, group chats and channels.

use Laravel\Converse\Facades\Converse;

Converse::bot('support', SupportBot::class)
    ->connection('slack')
    ->connection('teams');

Requirements

  • PHP 8.4+
  • Laravel 13.38+
  • Laravel Converse 1.x
  • A Microsoft 365 tenant that allows custom Teams apps

Installation

Install Laravel Converse first, then require the driver:

composer require flowgistics/converse-ms-botframework

The service provider is discovered automatically and registers the botframework driver with Converse.

Configuration

Add a connection that uses the botframework driver to config/converse.php:

'connections' => [

    'teams' => [
        'driver' => 'botframework',
        'app_id' => env('TEAMS_APP_ID'),
        'app_password' => env('TEAMS_APP_PASSWORD'),
        'tenant_id' => env('TEAMS_TENANT_ID'),
        'service_url' => env('TEAMS_SERVICE_URL'),
    ],

],
Option Description
app_id The Microsoft App ID (client ID) of your bot.
app_password A client secret of the bot's app registration.
tenant_id The Directory (tenant) ID of a single tenant bot. Leave it empty for a legacy multi-tenant bot.
service_url Optional. The Bot Connector URL used for conversations the bot has not heard from yet. Defaults to https://smba.trafficmanager.net/teams/.

Then add the connection to a bot in routes/bot.php:

Converse::bot('support', SupportBot::class)->connection('teams');

Creating the bot in Microsoft Teams

  1. Create a single tenant bot in the Teams Developer Portal, or create an Azure Bot resource.
  2. Copy the Microsoft App ID, create a client secret and copy the Directory (tenant) ID of the app registration.
  3. Run the setup command. It validates the credentials against Microsoft and writes them to your .env file:
php artisan converse:setup teams
  1. Set the bot's messaging endpoint to the URL the setup command prints, which is https://your-app.com/converse/{bot}/{connection}.
  2. Enable the Microsoft Teams channel on the bot, add the bot to a Teams app manifest with the personal, team and groupChat scopes, and install the app in Teams.

Webhooks are acknowledged right away and handled on your queue, so make sure a queue worker is running.

How Teams Maps to Converse

Teams Converse
Personal chat with the bot A direct message. With no direct message handler, it routes to your mention handler, since every message in it is addressed to the bot.
Group chat A channel without threads. The bot only hears messages that @mention it.
Team channel A channel. Each post and its replies form a thread, and the bot replies inside it.
@mention of the bot $message->isMention(). The mention is removed from $message->text().
Card button or select An Action event with the button's ID and value.
Reaction A Reaction event. Teams' like, heart, laugh, surprised, sad and angry arrive as emoji.
Edited or deleted message MessageUpdated and MessageDeleted events.

In channels and group chats, Teams only delivers messages that @mention the bot unless the app requests the resource-specific consent permission ChannelMessage.Read.Group or ChatMessage.Read.Chat in its manifest.

Capabilities

The driver supports sending, editing and deleting messages, typing indicators, adding and removing reactions, downloading inbound attachments, sending images, opening direct messages and account linking deep links.

$thread->send('Plain text');
$thread->send(Markdown::make('**Markdown** with a [link](https://laravel.com)'));
$thread->send('Hello, '.$thread->mention($message->user()));

$sent = $thread->send('Working on it...');
$sent->edit('Done!');
$sent->addReaction(Emoji::Check);

$thread->updateStatus();

Microsoft Teams has no Bot Framework API for message history, channel lookups, user lookups by name or ephemeral messages, so the driver does not support those capabilities.

Cards

Converse cards render as Adaptive Cards 1.5. Titles and text become text blocks, fields become a fact set, tables become an Adaptive Card table, buttons become Action.Submit actions and link buttons become Action.OpenUrl actions. Fenced code renders in a monospace font.

Teams inputs never submit on their own, so a Select or RadioSelect renders as a choice set with its own submit button. Clicking it dispatches an Action whose value is the chosen option.

You may send a hand-written Adaptive Card through the botframework raw payload. The card's fallback text is used as the notification summary:

$thread->send(Card::make('Weekly report')->withRaw('botframework', [
    'type' => 'AdaptiveCard',
    'version' => '1.5',
    'body' => [['type' => 'TextBlock', 'text' => 'Weekly report', 'size' => 'Large']],
]));

An Action.Submit on a raw card without Converse's own data dispatches an Action with the ID botframework_submit and the submitted data as a JSON value.

Attachments

Files users share in personal chats and images they paste are downloaded and staged by Converse like on any other platform. Files shared in channels and group chats live in SharePoint and are not delivered to bots.

Bots can only send images inline. Images up to 1 MB are sent as part of the message, and larger images may be sent by their public URL. Other files are sent as a card with a download button when they have a public HTTPS URL:

$thread->sendAttachment(Attachment::fromPath(storage_path('chart.png')), 'This week');
$thread->sendAttachment(Attachment::fromUrl('https://example.com/report.pdf', 'report.pdf', 'application/pdf'));

Proactive Messages

Teams routes each conversation through a regional service URL. The driver remembers the service URL of every conversation and user it hears from in Converse's cache store, so scheduled messages and other proactive messages reach the right region. Set service_url when your bot must message conversations it has never heard from.

Opening a direct message with a user requires tenant_id, or a message from that user first:

Converse::directMessage('teams', $teamsUserId)->send('Your export is ready.');

Security

Every webhook must carry a JSON Web Token signed by the Bot Framework. The driver validates its signature against Microsoft's published signing keys, along with its issuer, audience, expiry, the channel endorsement of the key and the service URL of the activity. Requests that fail validation receive a 404 response.

The driver supports the Microsoft public cloud. The Bot Framework Emulator and sovereign clouds are not supported.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Thank you for considering contributing! Please review our contributing guide to get started.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

Converse for Microsoft Teams is open-sourced software licensed under the MIT license.