Send 1:1 chat message in teams from c# application - Graph API

Simon Bennetts 11 Reputation points
2022-03-30T15:12:03.31+00:00

Hi - I would like to be able to send a 1:1 chat message from an app in teams without the need to login.

Is that possible? I have an app that will find or create the chat between my app and the person I wish to send the message to, but I can't seem to send.

The documentation suggests you can only do that with delegated permissions but I want my call logging software, running on an IIS server, to send details of the call in a chat message to the person the call is assigned to. The backend system will not be signed in.

Thanks
Simon

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,448 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,648 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. JanardhanaVedham-MSFT 3,536 Reputation points
    2022-04-19T18:28:53.927+00:00

    Hi @Simon Bennetts ,

    Send Message in Chat Microsoft Graph API currently supports the delegated permissions scope only and hence this Graph API can be used with the signed-in user scope in your app. Since currently Send Message in Chat Microsoft Graph API do not support application permissions scope, the above mentioned requirement is not feasible unless you use the delegated authentication & permissions in your app.

    Reference:
    https://learn.microsoft.com/en-us/graph/api/chat-post-messages?view=graph-rest-1.0&tabs=http

    Hope this helps.

    If the reply is helpful, please click "Accept Answer" and kindly upvote it. If you have additional questions about this answer, please click "Comment".

    2 people found this answer helpful.
    0 comments No comments

  2. Bruce (SqlWork.com) 61,731 Reputation points
    2022-04-19T20:32:08.777+00:00

    you need to register the app in azure ad then grant graph api permissions to the app. the app can then login to Graph API with a secret and call the api. the app does not need to be hosted in azure, it just uses the azure appid to login to Graph API.

    see:

    https://learn.microsoft.com/en-us/graph/auth-v2-service

    0 comments No comments