Broid Microsoft Teams Integration
Broid Integrations is an open source project providing a suite of Activity Streams 2 libraries for unified communications among a vast number of communication platforms.
Connect your App to Multiple Messaging Channels with One OpenSource Language.
Message types supported
Simple
Image
Video
Buttons
Location
Phone number
✅
✅
✅
Buttons, Location, Phone number are platform limitations.
Getting started
Connect to Microsoft Teams
const BroidMsTeams = require ( ' broid-ms-teams ' ) ;
const msTeams = new BroidMsTeams ( {
token : ' xxxxx ' ,
tokenSecret : ' xxxxxx ' ,
} ) ;
msTeams . connect ( )
. subscribe ( {
next : data => console . log ( data ) ,
error : err => console . error ( ` Something went wrong: ${ err . message } ` ) ,
complete : ( ) => console . log ( ' complete ' ) ,
} ) ;
Options available
name
Type
default
Description
token
string
The app ID
token_secret
string
The app secret
service_id
string
random
Arbitrary identifier of the running instance
log_level
string
debug
Can be : fatal
, error
, warn
, info
, debug
, trace
http
object
{ "port": 8080, "http": "127.0.0.1" }
HTTP options (host
, port
)
Receive a message
msTeams . listen ( )
. subscribe ( {
next : data => console . log ( ` Received message: ${ data } ` ) ,
error : err => console . error ( ` Something went wrong: ${ err . message } ` ) ,
complete : ( ) => console . log ( ' complete ' ) ,
} ) ;
Post a message
To send a message, the format should use the broid-schemas .
const formatted_message = {
" @context " : " https://www.w3.org/ns/activitystreams " ,
" type " : " Create " ,
" generator " : {
" id " : " f6e92eb6-f69e-4eae-8158-06613461cf3a " ,
" type " : " Service " ,
" name " : " ms-teams "
} ,
" object " : {
" type " : " Note " ,
" content " : " hello world " ,
" context " : {
" type " : " Object " ,
" name " : " address_id " ,
" content " : " xxxxxxx#29:xxxxxxxxxxxx#msTeams#28:xxxxxxxxxxxx "
}
} ,
" to " : {
" type " : " Person " ,
" id " : " 2932680234 "
}
} ;
msTeams . send ( formatted_message )
. then ( ( ) => console . log ( " ok " ) )
. catch ( err => console . error ( err ) ) ;
Examples of messages
Message received
A simple direct message received from Sally
{
" @context " : " https://www.w3.org/ns/activitystreams " ,
" type " : " Create " ,
" published " : 1482903365195 ,
" generator " : {
" id " : " f6e92eb6-f69e-4eae-8158-06613461cf3a " ,
" type " : " Service " ,
" name " : " ms-teams "
} ,
" actor " : {
" type " : " Person " ,
" name " : " Sally " ,
" id " : " 2932680234 "
} ,
" object " : {
" type " : " Note " ,
" content " : " hello world " ,
" id " : " 814382944357937155 " ,
" context " : {
" type " : " Object " ,
" content " : " xxxxxxx#29:xxxxxxx#skype#28:xxxxxxxx "
}
} ,
" target " : {
" type " : " Person " ,
" name " : " MyBot " ,
" id " : " 1132680234 "
}
}
A image received from Sally
{
" @context " : " https://www.w3.org/ns/activitystreams " ,
" published " : 1483147401733 ,
" type " : " Create " ,
" generator " : {
" id " : " bf4ef3de-486b-40ea-80e1-e8d5af86d81c " ,
" type " : " Service " ,
" name " : " ms-teams "
} ,
" actor " : {
" id " : " 29:xxxxxxxxx " ,
" type " : " Person " ,
" name " : " Sally "
} ,
" target " : {
" type " : " Person " ,
" name " : " MyBot " ,
" id " : " 28:xxxxxxxxxxxx "
} ,
" object " : {
" type " : " Image " ,
" id " : " 1483147401729 " ,
" context " : {
" type " : " Object " ,
" name " : " address_id " ,
" content " : " xxxxxxx#29:xxxxxxxxxxxx#skype#28:xxxxxxxxxxxx "
} ,
" url " : " https://apis.skype.com/v2/attachments/0-cus-d1-432cb4158e59c36bc0814217ecf46318/views/original " ,
" mediaType " : " image/jpeg " ,
" name " : " image_name.jpg "
}
}
Send a message
{
" @context " : " https://www.w3.org/ns/activitystreams " ,
" type " : " Create " ,
" generator " : {
" id " : " f6e92eb6-f69e-4eae-8158-06613461cf3a " ,
" type " : " Service " ,
" name " : " ms-teams "
} ,
" object " : {
" type " : " Note " ,
" content " : " hello world " ,
" context " : {
" type " : " Object " ,
" name " : " address_id " ,
" content " : " xxxxxxx#29:xxxxxxxxxxxx#skype#28:xxxxxxxxxxxx "
}
} ,
" to " : {
" type " : " Person " ,
" id " : " 2932680234 "
}
}
{
" @context " : " https://www.w3.org/ns/activitystreams " ,
" type " : " Create " ,
" generator " : {
" id " : " f6e92eb6-f69e-4eae-8158-06613461cf3a " ,
" type " : " Service " ,
" name " : " ms-teams "
} ,
" object " : {
" content " : " hello world " ,
" type " : " Image " ,
" url " : " https://unsplash.it/200/300 " ,
" context " : {
" type " : " Object " ,
" name " : " address_id " ,
" content " : " xxxxxxx#29:xxxxxxxxxxxx#skype#28:xxxxxxxxxxxx "
}
} ,
" to " : {
" type " : " Person " ,
" id " : " 2932680234 "
}
}
{
" @context " : " https://www.w3.org/ns/activitystreams " ,
" type " : " Create " ,
" generator " : {
" id " : " f6e92eb6-f69e-4eae-8158-06613461cf3a " ,
" type " : " Service " ,
" name " : " ms-teams "
} ,
" object " : {
" type " : " Note " ,
" content " : " hello world " ,
" attachment " : [ {
" type " : " Button " ,
" content " : " Broid's website " ,
" name " : " broid " ,
" mediaType " : " text/html " ,
" url " : " https://www.broid.ai "
} , {
" type " : " Button " ,
" content " : " Falken's Maze " ,
" name " : " maze " ,
" url " : " value_maze "
} ] ,
" context " : {
" type " : " Object " ,
" name " : " address_id " ,
" content " : " xxxxxxx#29:xxxxxxxxxxxx#skype#28:xxxxxxxxxxxx "
}
} ,
" to " : {
" type " : " Person " ,
" id " : " 2932680234 "
}
}
Contributing to Broid
Broid is an open source project. Broid wouldn't be where it is now without contributions by the community. Please consider forking Broid to improve, enhance or fix issues. If you feel like the community will benefit from your fork, please open a pull request.
And because we want to do the better for you. Help us improving Broid by
sharing your feedback on our Integrations GitHub Repo and let's build Broid together!
Code of Conduct
Make sure that you're read and understand the Code of Conduct .
Copyright & License
Copyright (c) 2016-2017 Broid.ai
This project is licensed under the AGPL 3, which can be
found here .