Microsoft Teams
Goal
Create Incoming WebHook in Rocket.Chat
class Script {
process_incoming_request({ request }) {
// UNCOMMENT THE BELOW LINE TO DEBUG IF NEEDED.
// console.log(request.content);
if ('edited_message' in request.content) {
request.content = request.content;
}
let from = request.content.from;
let who = from.name;
let icon_url = '/avatar/' + from.name + '.jpg'
let body = request.content.text.slice(16);
if(!body) {
if(request.content.hasOwnProperty("sticker") && request.content.sticker.emoji) {
// It's a sticker
body = request.content.sticker.emoji
} else {
return {}
}
}
return {
content: {
username: who,
icon_url: icon_url,
text: body,
},
response: {
type: "message",
attachments: [{
contentType: "application/vnd.microsoft.card.adaptive",
content: {
type: "AdaptiveCard",
version: "1.4",
body: [{
type: "TextBlock",
text: "Message received",
}],
},
}],
}
};
}
}Create Outgoing WebHook in MS Teams:
Create Incoming WebHook in MS Teams:
Create Outgoing Webhook in Rocket.Chat:
Enjoy!
Last updated