question

SeelamBharathiCognizant-1377 avatar image
0 Votes"
SeelamBharathiCognizant-1377 asked CarlZhao-MSFT commented

How to Join logged in user to the groupchat in teams using graph api

I have created a personal BOT and created a tabin the tab when the user click on the button that user automatically added to the groupchat
GraphServiceClient graphClient = new GraphServiceClient( authProvider );

var conversationMember = new AadUserConversationMember
{
VisibleHistoryStartDateTime = DateTimeOffset.Parse("2019-04-18T23:51:43.255Z"),
Roles = new List<String>()
{
"owner"
},
AdditionalData = new Dictionary<string, object>()
{
{"user@odata.bind", "https://graph.microsoft.com/v1.0/users/8b081ef6-4792-4def-b2c9-c363a1bf41d5"}
}
};

await graphClient.Chats["{chat-id}"].Members
.Request()
.AddAsync(conversationMember);
Its throwing an error The initiator 8:orgid:e11885e0-aef7-41e7-be4b-a32c55b5b8e4 is not a member of the roster afbe6dc0-ab9b-49b7-8cfc-c9794834a6f8 in the generic thread 19:19496b7b2d12406694dabcf0edb24cee@thread.v2.isSelfJoining: True isSelfJoiningEnabled: False

when i tried with application token(bot)getting error requested api is not supported in application-only context

microsoft-graph-teamworkmicrosoft-graph-usersmicrosoft-graph-people
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @SeelamBharathiCognizant-1377,

Welcome to Microsoft Q&A!

The "office-teams-windows-itpro" tag is for general questions related to Teams client, since from the description your query is about graph, I'll change the tag to "microsoft-graph-teamwork" so that hopefully their community members can help look into this.

0 Votes 0 ·

Is your user a guest or a member?

0 Votes 0 ·

1 Answer

CarlZhao-MSFT avatar image
0 Votes"
CarlZhao-MSFT answered CarlZhao-MSFT commented

Hi @SeelamBharathiCognizant-1377

The API supports both user context and application context, if you are using user context then you have to log in with the owner of the group chat and get token, then use that token to add new members, in user context only the group chat owner can add new members. If you are using application context then you can add new members directly.

195065-image.png

Note that if your user is a guest, you must set roles to "guest" when adding him to the group chat.

 Roles = new List<String>()
 {
     "guest"
 }

If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our [documentation][4] to enable e-mail notifications if you want to receive the related email notification for this thread.



image.png (25.0 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @SeelamBharathiCognizant-1377 Would you please provide us with an update on the status of your issue?

0 Votes 0 ·

Hi @SeelamBharathiCognizant-1377

Is there anything else I can help with regarding this issue?

You can comment us at any time and we will continue to follow up.

Thanks,
Carl Zhao

0 Votes 0 ·