The community will undergo maintenance on October 16th at 10:00 PM PDT and will be unavailable for up to one hour.
Good day everyone! Has anyone integrated MS Teams with Thingworx? You need to create a service similar to Twillio to be able to send notification to MS Teams. What is the template for implementing this service? Is it enough to just use the API to create a connection?
If you know how to use the Teams API that would be the way, don't think there is a connector/template for it.
I tried to set up a service in the same way with Twillio, but there were always some conflicts, but there were ...
I haven't been working for TW for that long, tell me how await works ... Also, I don't understand why TW swears at a construction like:
const options = {
authProvider,
};
Do I understand correctly that I need to write an analogue of Twillio?
// twillio
var employeeList = Groups[employees].GetGroupMembers();
for (var x = 0; x < employeesList.getRowCount(); x++) {
var employee = employeesList.getRow(x);
var params = {
to: employee.smsAddress,
text: "Hey, " + employee.firstName + "." + message
};
me.SendSMSMessage(params);
}
//teams api integr.
const options = {
authProvider,
};
const client = Client.init(options);
const chatMessage = {
body: {
content: 'Hello World'
}
};
await client.api('/teams/fbe2bf47-16c8-47cf-b4a5-4b9b187c508b/channels/19:4a95f7d8db4c4e7fae857bcebe0623e6@thread.tacv2/messages')
.post(chatMessage);
Yes except the Twillio piece that is being leveraged is an extension so there is a java library backing up that sendmessage call.
You'll have to figure out how to do that for Teams unless Teams can accept a straight API call
If you feel your question has been answered, please mark the appropriate response as the Accepted Solution for the benefit of others with the same question.
Regards.
--Sharon
Good time everyone!
I just can't figure out how to set up integration with Teams ... Please, tell me how I can get the API key of the chat / group / teams channel, so that I can use it in the future to send messages from TW. Also it is not clear to me how to implement the service for sending messages. The code that I posted above ThingWorx refuses to accept
I've been thinking about this since it's on our backlog for our next internal ThingWorx release. Have you written a Teams App before? I don't think you can call the MS Graph API as an Application and send messages. Teams Apps however can initiate chats and send notifications.
In general, I see two options for implementation:
1) Directly through the API, if it works, this is the best option, but so far nothing has really worked out for me
2) Through a "crutch", through some ready-made service, send notifications to some bot, which will already process messages on the other side and send them to channels / chats
What resources have you found so far that document and explain the usage of the MS Teams REST API?
At the moment I'm testing writing a service using this template https://docs.microsoft.com/en-us/graph/api/chat-post-messages?view=graph-rest-1.0&tabs=http
You probably want to unlock the POST items, but it looks like it requires a Microsoft sign-in. So this may not work from ThingWorx, I didn't unlock the post so I don't know if you can supply a user/pass or token but it looks like what you have as a link has all the API calls you need.
You could probably try it first in Postman and then take it over to ThingWorx.
The Get just seems to be a link and the response although it is odata should be fairly easily to convert to JSON
I thought of another option:
What if you just create a handler bot in the same MIcrosoft Bot Framework and send messages to it from ThingWorx, and he, in turn, will already process them and send them to the desired chat
Or will there also be difficulty in sending a message to the bot?
Hi @Egor.Litvinov.
You might want to consider requesting this functionality on the ThingWorx Ideas board. This will allow others who have a need for it to vote for your suggestion.
Unless someone has already implemented similar functionality, you'll have to dig into the Microsoft documentation for handling authentication, sending messages, etc.
Regards.
--Sharon
Hey! Thanks for the idea! I will study and most likely post an article there. At the moment I am studying Microsoft documentation
In order to use the graph APIs for sending messages or notifications, the AzureAD app registration used to call the API must both be associated with a Teams App and the user has to have the Teams App installed (either individually or transitively via a Team). And there's the question of whether you want to send a proactive message vs a simple notification. There's a MSGraph endpoint for sending a notification, but sending a proactive message does require the bot framework. Sending a proactive message is more complicated since the bot has to handle the conversation.
Hey! Thanks for the answer. Please tell me which of the options will be better and preferable in this task? In fact, you just need notifications / reports from equipment in teams. So far, I have been considering the option of constantly communicating with MS Graph. That is, we interact with the ThingWorx service with Graph, which directly calls certain commands. But the question arises, how to communicate with Graph? And the second option in my head is to create a handler bot on the side, but this option seems very difficult to me. Initially, I thought there was an opportunity to communicate directly with the Teams API, but alas, I did not find such an opportunity ...
Sending notifications would be easier since it doesn't require setting up chatbot. You would use the MS Graph API to send the notifications. There's not much code required... That said, the hard part is navigating all the permissions and setup for this!
1. Create an Azure AD Application registration. If you're using AzureAD authentication, you can reuse the same registration that you're using for SSO.
2. Create a Teams App. This is just a zip archive with a manifest.json and some icons. The manifest.json must have the activity notification templates and specify the AD Application from #1 to send activity notifications. You can use AppStudio or just edit the manifest directly.
3. Authenticate against the MS Graph with client id/secret from the AD Application registration.
4. Send the notification using the credentials from #3.
Teams Apps have a LOT of capabilities, but you don't need to worry about any of them to send a notification. In this case, we are using the Teams App as a way to grant permissions to a service (ie. Thingworx) to send notifications to users. Thingworx will only be able to send notifications to users that either install the Teams App or are a member of a Team that has the App installed in it.
We've setup a Team for Thingworx. We do all our user support via that Teams site. Access to ThingWorx is controlled by membership to that Team, and some of the permission levels (like Administrators) are managed using a Private Channel. With our scheme, all Thingworx users are members of the Team by definition. We've installed the Thingworx Teams App into the Team site so the App is "installed" by all ThingWorx users.
Depending on your level of permissions in the Azure tenant and how strict your IT dept is, getting the right permissions will be the most challenging - or at least it was for us. We needed to get permissions to Side-load the Teams App into Teams just to start development and Directory.ReadAll permissions on the app because the tenant admin had locked down what permissions users are able to consent to. Since no one had ever done this at our company, we basically had to teach IT how to do this... it was a pain. But worth it in the end.
Hope this helps!
Hi @Egor.Litvinov.
If you feel your question has been answered, please mark the appropriate response as the Accepted Solution for the benefit of others with the same question.
Regards.
--Sharon
Hi @Egor.Litvinov ,
If your idea is focued on teams channel then you can try incoming webhooks connector and use the restAPI to publish your messages in MS Teams channel.