Forum Discussion
DVTitov
Nov 27, 2021Copper Contributor
Send personal messages to Teams from daemon service.
Hello, I need to send notifications to my colleagues using Teams in case of emergency which is detected by monitoring system. These messages must be sent on behalf of background service which cannot ...
- Dec 09, 2021
DVTitov - We got a confirmation from engineering team that
"To post as a background service, the user must use a bot."
So currently we do not have any way to send the direct message to user using Graph API.Thanks,
Chetan Sharma
----------------------------------------------------------------------------------------
If the response is helpful, please click "**Mark as Best Response**" and like it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.
ChetanSharma-msft
Microsoft
Dec 07, 2021DVTitov - You can send a personal messages to different users in Teams with daemon service but you will need to store their information like Service URL, conversation id in storage while installing the bot.
You can do it like below:
var conversationReference = new ConversationReference
{
ServiceUrl = serviceUrl,
Conversation = new ConversationAccount
{
Id = conversationId,
},
};
await this.botAdapter.ContinueConversationAsync(
botAppId: this.microsoftAppId,
reference: conversationReference,
callback: async (turnContext, cancellationToken) =>
{
// Send message.
var activityResponse = await policy.ExecuteAsync(async () => await turnContext.SendActivityAsync(message));
return response;
}
Reference link:
BotAdapter.ContinueConversationAsync Method (Microsoft.Bot.Builder) | Microsoft Docs
DVTitov
Dec 07, 2021Copper Contributor
Hi!
I'm not sure this is my case. I don't have a bot. I need to develop Linux daemon service that should propagate infrastructure monitoring alerts to system admins. I use Golang SDK and I'm able to query all users of my organization from Azure AD (Microsoft Graph API). Now I need a REST or Go SDK method to send message to Teams user referenced by their AD UPN.
Me daemon service is by no means a bot or web app. Imagine it's a plugin for Zabbix or MS SCOM.
I'm not sure this is my case. I don't have a bot. I need to develop Linux daemon service that should propagate infrastructure monitoring alerts to system admins. I use Golang SDK and I'm able to query all users of my organization from Azure AD (Microsoft Graph API). Now I need a REST or Go SDK method to send message to Teams user referenced by their AD UPN.
Me daemon service is by no means a bot or web app. Imagine it's a plugin for Zabbix or MS SCOM.
- ChetanSharma-msftDec 08, 2021
Microsoft
DVTitov - You can create a one-on-one chat with user based on UPN/AADObjectId and can send the messages based on chat id (Using Graph API):
https://docs.microsoft.com/en-us/graph/api/chat-post?view=graph-rest-1.0&tabs=http#example-3-create-a-one-on-one-chat-using-user-principal-name
https://docs.microsoft.com/en-us/graph/api/chat-post-messages?view=graph-rest-1.0&tabs=http#http-request- DVTitovDec 08, 2021Copper ContributorHi!
Example for Go behind that link is outdated, but anyway I cannot use chat API in applications only context.
My application gets Auth token using application secret obtained at Azure. I don't have any user logged in so I can't get Authorization Code.
Hence when I call chat API I get an error: "Chat API not allowed in application only context" (or similar).- ChetanSharma-msftDec 09, 2021
Microsoft
DVTitov - We got a confirmation from engineering team that
"To post as a background service, the user must use a bot."
So currently we do not have any way to send the direct message to user using Graph API.Thanks,
Chetan Sharma
----------------------------------------------------------------------------------------
If the response is helpful, please click "**Mark as Best Response**" and like it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.