symfony/microsoft-teams-notifier

Symfony Microsoft Teams Notifier 桥接器

安装次数: 378,853

依赖者: 2

建议者: 0

安全: 0

星标: 8

关注者: 4

分支: 3

类型:symfony-notifier-bridge


README

通过Incoming Webhook为Symfony Notifier提供Microsoft Teams集成。

DSN示例

MICROSOFT_TEAMS_DSN=microsoftteams://default/PATH

其中

  • PATH具有以下格式:webhookb2/{uuid}@{uuid}/IncomingWebhook/{id}/{uuid}

向消息添加文本

使用Microsoft Teams,您可以使用ChatMessage类:

use Symfony\Component\Notifier\Bridge\MicrosoftTeams\MicrosoftTeamsTransport;
use Symfony\Component\Notifier\Message\ChatMessage;

$chatMessage = (new ChatMessage('Contribute To Symfony'))->transport('microsoftteams');
$chatter->send($chatMessage);

向消息添加交互

使用Microsoft Teams消息,您可以使用MicrosoftTeamsOptions类来添加消息卡选项

use Symfony\Component\Notifier\Bridge\MicrosoftTeams\Action\ActionCard;
use Symfony\Component\Notifier\Bridge\MicrosoftTeams\Action\HttpPostAction;
use Symfony\Component\Notifier\Bridge\MicrosoftTeams\Action\Input\DateInput;
use Symfony\Component\Notifier\Bridge\MicrosoftTeams\Action\Input\TextInput;
use Symfony\Component\Notifier\Bridge\MicrosoftTeams\MicrosoftTeamsOptions;
use Symfony\Component\Notifier\Bridge\MicrosoftTeams\MicrosoftTeamsTransport;
use Symfony\Component\Notifier\Bridge\MicrosoftTeams\Section\Field\Fact;
use Symfony\Component\Notifier\Bridge\MicrosoftTeams\Section\Section;
use Symfony\Component\Notifier\Message\ChatMessage;

$chatMessage = new ChatMessage('');

// Action elements
$input = new TextInput();
$input->id('input_title');
$input->isMultiline(true)->maxLength(5)->title('In a few words, why would you like to participate?');

$inputDate = new DateInput();
$inputDate->title('Proposed date')->id('input_date');

// Create Microsoft Teams MessageCard
$microsoftTeamsOptions = (new MicrosoftTeamsOptions())
    ->title('Symfony Online Meeting')
    ->text('Symfony Online Meeting are the events where the best developers meet to share experiences...')
    ->summary('Summary')
    ->themeColor('#F4D35E')
    ->section((new Section())
        ->title('Talk about Symfony 5.3 - would you like to join? Please give a shout!')
        ->fact((new Fact())
            ->name('Presenter')
            ->value('Fabien Potencier')
        )
        ->fact((new Fact())
            ->name('Speaker')
            ->value('Patricia Smith')
        )
        ->fact((new Fact())
            ->name('Duration')
            ->value('90 min')
        )
        ->fact((new Fact())
            ->name('Date')
            ->value('TBA')
        )
    )
    ->action((new ActionCard())
        ->name('ActionCard')
        ->input($input)
        ->input($inputDate)
        ->action((new HttpPostAction())
            ->name('Add comment')
            ->target('http://target')
        )
    )
;

// Add the custom options to the chat message and send the message
$chatMessage->options($microsoftTeamsOptions);
$chatter->send($chatMessage);

资源