1
votes

I have created a bot for teams and added it to a channel (testChannel1) as a tab (using a configuration page). I have received a ConversationUpdate event to my server. When I try to send message using the context object that I have received in ConversationUpdate event the message was sent in General channel instead of testChannel1. I have added my bot to testChannel1 but I dont know why the message is sent in General. I am also not able to get the channels list using that context object it is throwing error Error: This method is only valid within the scope of a MS Teams Team..

contextActivityObject :- { "membersAdded": [ { "id": "28:[guid]" } ], "type": "conversationUpdate", "timestamp": "2020-04-24T12:00:06.7125247Z", "id": "f:[guid]", "channelId": "msteams", "serviceUrl": "https://smba.trafficmanager.net/in/", "from": { "id": "29:[id]", "aadObjectId": "[guid]" }, "conversation": { "isGroup": true, "conversationType": "channel", "tenantId": "[guid]", "id": "19:aba[id]@thread.tacv2" }, "recipient": { "id": "28:[guid]", "name": "teststandups" }, "channelData": { "team": { "aadGroupId": "[guid]", "name": "nikhilp", "id": "19:aba[id]@thread.tacv2" }, "eventType": "teamMemberAdded", "tenant": { "id": "[guid]" } } }

The scope I have provided for my bot is Team

I would be thankful for any help

1
A bot and a Tab are actually separate things, so they're not per se related, other than both being part of your same Teams app in this case (you don't need the Tab at all).Hilton Giesenow
Separate from the above, please elaborate on how you're trying to get the Channels list?Hilton Giesenow
Now I am able to get channels list. Before I have created a conversation reference and using that context I tried to fetch channels. This code worked for me const context = new TurnContext(adapter, activity); TeamsInfo.getTeamChannels(context).then(res => console.log(res)).catch(err => console.log(err));Nikhil Ponduri
What I am trying to do is I want to authenticate user to map his bot activity details to the user in my database. So I am trying to use tabs so that I can authenticate user when he is trying to install my bot. Is there any other approach to do this?Nikhil Ponduri

1 Answers

2
votes

So you've asked a couple of questions, I'll try answer as best as possible. Basically, that Conversation ID (19:aba[id]@thread.tacv2) is unique per channel, so if you're using the "General" channel one, it will for sure go into General.

To find out how to get the channel Ids, have a look at Get the list of channels in a team. That will show you -how- to get the info, but you need to get a trigger in order to be able to make that call. To do that, the best way is to hook into one of the triggers, like receiving a message from a user, or being added to the team. Included in these set of events, are channels being added and deleted. See more here.