cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate I
Advocate I

Getting channel ID for channels in Teams?

Hello!

 

I have downloaded the following sample app to try and figure out how to send messages from my app to Teams: https://powerusers.microsoft.com/t5/Community-Apps-Gallery/Sample-Teams-Demo-App/m-p/86326#M18

 

I have managed to figure this formula out from the sample app:
MicrosoftTeams.PostMessageToChannel("Team-id-string", "channel-id-string", { body:{content: messageTB.Text, contentType:1 } })

This works as it should with no issues. When using the sampleapp I can look up the channel id for a newly created channel in the variable "channelResponse".

My question is: how do I find out what the id’s are for channels that already exist?

I have tried this formula:

MicrosoftTeams.GetChannelsForGroup(Team-id-string)

 

But this formula only returns a link:

https://graph.microsoft.com/beta/$metadata#groups('Team-id-string')/channels

 

This is an adress to an XML-file that only consists of miles of XML-code.

 

The id that I can find in the variable that works looks like this:
17:3151da3802ea43cd8701a684205978@thread.skype 

 

 

I how you guys have an awnser for me because I have tried everything Smiley Happy

 

 

Cheers,

Joakim

 

  

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Advocate I
Advocate I

Re: Getting channel ID for channels in Teams?

Hello @v-xida-msft!

 

Thank you for your answer but this does not work for me. The Teams-formulas seem unstable to me. If I try your work around I get this:

 

pa_issue.JPG

 

Now if I save, close and re-open the app I get his:

 

pa_issue2.JPG

 

This returns a description of the group and not the group name. At some point it did display the accurate name of the group but now it doesnt, it seems random.

 

Going over the issue today I found a way to get the channel nbame without the suggested work around. If I copy the URL for the channel I can extract the accurate channel-ID.

 

URL:
https://teams.microsoft.com/l/channel/19%3a3151da3802ea43cd8701a6faf4215978%40thread.skype/testi?groupId=a4c77160-21b4-4169-a683-5362475cf123&tenantId=1ffaf751-2c9b-46b8-a71b-845cf8b15f69

Just replace the parts marked blue with " : " and " @ " you get a valid channel-ID:

19:3151da3802ea43cd8701a6faf4215978@thread.skype

 

View solution in original post

4 REPLIES 4
Highlighted
Community Support
Community Support

Re: Getting channel ID for channels in Teams?

Hi @JoakimAndersson,

 

Do you want to get the Channel ID for existing channels in MS Teams?

 

I think there is something wrong with the formula that you provided.

 

I have made a test on my side, please take a try with the following workaround:7.JPG

 

8.JPG

 

9.JPG

 

 

Set the Items property of the Dropdown1 to following formula:

 

MicrosoftTeams.GetAllTeams().value

 

 

Set the Items property of the Dropdown2 to following formula:

 

MicrosoftTeams.GetChannelsForGroup(Dropdown1.Selected.id).value

On your side, you should modify your formula as below:

 

MicrosoftTeams.GetChannelsForGroup(Your-Team-id-string).value

 

Set the OnSelect property of the Button to following formula:

MicrosoftTeams.PostMessageToChannel(
Dropdown1.Selected.id, /* <-- Team Id */
Dropdown2.Selected.id, /* <-- Channel Id */
{
body:{
content:"PowerApps Test at 09/10/2018",
contentType:1
}
}
)

If you want to save the retrieved Channel Ids within a variable, please take a try with the following formula:

Set(channelResponse,MicrosoftTeams.GetChannelsForGroup(Dropdown1.Selected.id).value)

On your side, it is:

Set(channelResponse,MicrosoftTeams.GetChannelsForGroup(Your-Term-Id-string).value)

the variable looks as below:10.JPG

 

 

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Advocate I
Advocate I

Re: Getting channel ID for channels in Teams?

Hello and thank you for your awnser @v-xida-msft

 

I understand how your solution work but it doesn't work for me. The Teams-formulas seem unstable to me. When I try to replicate what you did this is my reslut:

 

pa_issue.JPG 

 

If I save, close and open the app again this is the result:

pa_issue2.JPG

Now this returns the description av the group and not the name of the group as it is supposed to. At one point it did display the correct name but now it doesn't. It seems random what value it returns.

Going over this issue today I found the awnser to my original question without the workaround you suggested. If I copy the channel-URL I get this:

https://teams.microsoft.com/l/channel/19%3a3151da3802ea43cd8701a6faf4215978%40thread.skype/testi?groupId=a2c77120-21b4-4169-a683-5342475cf123&tenantId=1ffaf731-2c9b-46b8-a71b-845cf8b15f67

Since I know the structure of a working channel-ID I figured out how to edit the url to get what I want. Replace % and the two folloing characters with " : " at the beginging of the string and then " @ " at the last part of the string:

19:3151da3802ea43cd8701a6faf4215978@thread.skype

 

This is the actual ID for the channel and it works as it should now.





  




Highlighted
Advocate I
Advocate I

Re: Getting channel ID for channels in Teams?

Hello @v-xida-msft!

 

Thank you for your answer but this does not work for me. The Teams-formulas seem unstable to me. If I try your work around I get this:

 

pa_issue.JPG

 

Now if I save, close and re-open the app I get his:

 

pa_issue2.JPG

 

This returns a description of the group and not the group name. At some point it did display the accurate name of the group but now it doesnt, it seems random.

 

Going over the issue today I found a way to get the channel nbame without the suggested work around. If I copy the URL for the channel I can extract the accurate channel-ID.

 

URL:
https://teams.microsoft.com/l/channel/19%3a3151da3802ea43cd8701a6faf4215978%40thread.skype/testi?groupId=a4c77160-21b4-4169-a683-5362475cf123&tenantId=1ffaf751-2c9b-46b8-a71b-845cf8b15f69

Just replace the parts marked blue with " : " and " @ " you get a valid channel-ID:

19:3151da3802ea43cd8701a6faf4215978@thread.skype

 

View solution in original post

Highlighted
Frequent Visitor

Re: Getting channel ID for channels in Teams?

This works great!

Anyone not getting it pay attention that he deleted the stuff at the end on that final example as well. 

 

Should work then.

 

Good Job.

Helpful resources

Announcements
Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,656)