Notify to Teams on Firebase events

Microsoft Teams

The setup in Microsoft Teams is rather simple.

Google Firebase

In Google Firebase we will utilize the “Cloud Functions” feature to send the notifications.

npm install --save axios
const axios = require(‘axios’);
exports.notifyNewUser = functions.auth.user().onCreate((user) => {};
const webHook = "https://outlook.office.com/webhook/....";const curDate = new Date();
var card = {
"type": "message",
"attachments": [
{
"contentType": "application/vnd.microsoft.card.adaptive",
"contentUrl": null,
"content": {
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"size": "Medium",
"weight": "Bolder",
"text": "New User Created"
},
{
"type": "FactSet",
"facts": [
{
"title": "Create Date",
"value": curDate.toISOString()
},
{
"title": "UUID",
"value": user.uid
}
]
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.3"
}
}
]
};
axios.post(webHook, card)
.catch(error => {
console.error(error)
});
firebase deploy --only functions

Test

Testing is very easy.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Stefan Steinert

Stefan Steinert

System Operator and DevOPs Architect since childhood