@@ -332,6 +332,99 @@ to add `message options`_::
332
332
333
333
$chatter->send($chatMessage);
334
334
335
+ Adding text to a Microsoft Teams Message
336
+ ----------------------------------------
337
+
338
+ With a Microsoft Teams, you can use the simple ChatMessage::
339
+
340
+ use Symfony\Component\Notifier\Bridge\MicrosoftTeams\MicrosoftTeamsTransport;
341
+ use Symfony\Component\Notifier\Message\ChatMessage;
342
+
343
+ $chatMessage = (new ChatMessage('Contribute To Symfony'))->transport('microsoftteams');
344
+ $chatter->send($chatMessage);
345
+
346
+ The result will be something like:
347
+
348
+ .. image :: /_images/notifier/microsoft_teams/message.png
349
+ :align: center
350
+
351
+ Adding Interactions to a Microsoft Teams Message
352
+ ------------------------------------------------
353
+
354
+ With a Microsoft Teams Message, you can use the
355
+ :class: `Symfony\\ Component\\ Notifier\\ Bridge\\ MicrosoftTeams\\ MicrosoftTeamsOptions ` class
356
+ to add `MessageCard options `_::
357
+
358
+ use Symfony\Component\Notifier\Bridge\MicrosoftTeams\Action\ActionCard;
359
+ use Symfony\Component\Notifier\Bridge\MicrosoftTeams\Action\HttpPostAction;
360
+ use Symfony\Component\Notifier\Bridge\MicrosoftTeams\Action\Input\DateInput;
361
+ use Symfony\Component\Notifier\Bridge\MicrosoftTeams\Action\Input\TextInput;
362
+ use Symfony\Component\Notifier\Bridge\MicrosoftTeams\MicrosoftTeamsOptions;
363
+ use Symfony\Component\Notifier\Bridge\MicrosoftTeams\MicrosoftTeamsTransport;
364
+ use Symfony\Component\Notifier\Bridge\MicrosoftTeams\Section\Field\Fact;
365
+ use Symfony\Component\Notifier\Bridge\MicrosoftTeams\Section\Section;
366
+ use Symfony\Component\Notifier\Message\ChatMessage;
367
+
368
+ $chatMessage = new ChatMessage('');
369
+
370
+ // Action elements
371
+ $input = new TextInput();
372
+ $input->id('input_title');
373
+ $input->isMultiline(true)->maxLength(5)->title('In a few words, why would you like to participate?');
374
+
375
+ $inputDate = new DateInput();
376
+ $inputDate->title('Proposed date')->id('input_date');
377
+
378
+ // Create Microsoft Teams MessageCard
379
+ $microsoftTeamsOptions = (new MicrosoftTeamsOptions())
380
+ ->title('Symfony Online Meeting')
381
+ ->text('Symfony Online Meeting are the events where the best developers meet to share experiences...')
382
+ ->summary('Summary')
383
+ ->themeColor('#F4D35E')
384
+ ->section((new Section())
385
+ ->title('Talk about Symfony 5.3 - would you like to join? Please give a shout!')
386
+ ->fact((new Fact())
387
+ ->name('Presenter')
388
+ ->value('Fabien Potencier')
389
+ )
390
+ ->fact((new Fact())
391
+ ->name('Speaker')
392
+ ->value('Patricia Smith')
393
+ )
394
+ ->fact((new Fact())
395
+ ->name('Duration')
396
+ ->value('90 min')
397
+ )
398
+ ->fact((new Fact())
399
+ ->name('Date')
400
+ ->value('TBA')
401
+ )
402
+ )
403
+ ->action((new ActionCard())
404
+ ->name('ActionCard')
405
+ ->input($input)
406
+ ->input($inputDate)
407
+ ->action((new HttpPostAction())
408
+ ->name('Add comment')
409
+ ->target('http://target')
410
+ )
411
+ )
412
+ ;
413
+
414
+ // Add the custom options to the chat message and send the message
415
+ $chatMessage->options($microsoftTeamsOptions);
416
+ $chatter->send($chatMessage);
417
+
418
+ The result will be something like:
419
+
420
+ .. image :: /_images/notifier/microsoft_teams/message-card.png
421
+ :align: center
422
+
423
+ .. versionadded :: 5.3
424
+
425
+ Options for Microsoft Teams were introduced in Symfony 5.3.
426
+
335
427
.. _`Block elements` : https://api.slack.com/reference/block-kit/block-elements
336
428
.. _`Embed elements` : https://discord.com/developers/docs/resources/webhook
337
429
.. _`message options` : https://core.telegram.org/bots/api
430
+ .. _`MessageCard options` : https://docs.microsoft.com/en-us/outlook/actionable-messages/message-card-reference
0 commit comments