web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Microsoft teams PostMe...
Power Apps
Unanswered

Microsoft teams PostMessageToConversation

(0) ShareShare
ReportReport
Posted on by 22

Hello,

I have a gallery displaying items from excel table, i want to share any selected item to teams chat with the user who created that item

 

I have tried to use MicrosoftTeams.PostMessageToConversation but it it gave me syntax error MicrosoftTeams.PostMessageToConversation("User",ThisItem.details, ThisItem.userstaffid) 

also MicrosoftTeams.CreateChat(ThisItem.userstaffid,{topic:ThisItem.details}) and also didn't work 

 

any suggestion on what I'm missing here?

 

thanks 🙂 

Categories:
I have the same question (0)
  • v-qiaqi@microsoft.com Profile Picture
    on at

    Hi @IcE-TanK,

    Do you want to post Gallery selected item to Teams message?

    Could you please share the specific error message with me?

     

    I hope you investigate this connector deeper so that you should know that Message expect an untyped object value, which you need to use JSON to convert it into Json and parse it as below:

    MicrosoftTeams.PostMessageToConversation("User","Channel",ParseJSON(JSON({recipient:{groupId:"***",channelId:"***"},messageBody:"<p>testtest</p>"},JSONFormat.Compact)))
    

    vqiaqimsft_0-1699234080816.png

     

  • IcE-TanK Profile Picture
    22 on at

    Hi v-qiaqi-msft 

     

    yes I'm trying to send gallery item to a user via teams, I think I'm writing the code in a wrong way,

    can you please show me the right syntax?

  • v-qiaqi@microsoft.com Profile Picture
    on at

    Hi @IcE-TanK,

    I think I have shown you the right syntax, please check the previous reply.

  • IcE-TanK Profile Picture
    22 on at

    Hi @v-qiaqi-msft 

    i have read the code you wrote above but I couldn't understand what I missed since it didn't show any syntax error at all but of course it's because it reads all strings values as "TEXT" 

     

     

    MicrosoftTeams.PostMessageToConversation("User","Channel",ParseJSON(JSON({recipient:{groupId:"***",channelId:"***"},messageBody:"<p>testtest</p>"},JSONFormat.Compact)))

     

     

    MicrosoftTeams.PostMessageToConversation("User: the one wo is sending the message", Location: this is what I don't get :/, body: the content of the message which I'm selecting as the selected current item) 

     and now I'm completely lost XD 

     

    Edit: btw I'm not sending the message to any group or channel, it's only to single user chat...

  • shred_yerbootie Profile Picture
    12 on at

    Hi, 

     

    Have you figured this out yet? Been spinning on this for three days now. Documentation is shyte and apparently no one knows how to do this! It can't be this difficult! 

     

    How to send a message from PowerApps to another user in Teams?  

  • MattRo Profile Picture
    40 on at

    Wow, it was painful, but I managed to make this work:

    MicrosoftTeams.PostMessageToConversation(poster, location, body)

    • For poster, I couldn't get "Flow bot" to work,
    • For location, this is the edited name/title of my chat conversation. It is odd, sometimes it needs to be what I have here, other times, it just needs to not be blank.
    • body - it took a lot of research/troubleshooting to get the format right, then the errors told me that it needed "recipient" and "messageBody" 

     

    MicrosoftTeams.PostMessageToConversation(
        "User",
        "PowerApps group chat test",
        ParseJSON(
            JSON(
                {
                recipient:"19:XXXXXXXXXXXXXXXXXXXXXXXXXXa04@thread.v2",
                messageBody:RichTextEditor1.HtmlText
                }
            )
        )
    )
  • shred_yerbootie Profile Picture
    12 on at

    Hey Matt, 

     

    I actually ended up using the following. It was easy, and it seems to work pretty well.

     

    Paste the following into the OnSubmit button where you want to post a message to a Teams chat: 

     

    MicrosoftTeams.PostMessageToChannelV3("Team identifier here (1)", "Channel identifier here (2) >", {content: "<p>put your HTML here... </p>", contentType: "html"}); 

     

    That's the whole string. Fill it out according to your needs. To get the Team and Channel identifiers (1 and 2, above), I created a new blank screen, and then set up the following: 

     

    1. Create a Gallery (call it Gallery1) and set Items == MicrosoftTeams.GetAllTeams().value

    2. Add the following labels to the Template for this Gallery: 

       -- ThisItem.description      ---> This is the TEAM descriptor 

       -- ThisItem.displayName   ---> This is the TEAM Name

       -- ThisItem.id                     ---> This is the TEAMS ID you plug into the formula above (1)

     

    This gives you a list of the TEAMS you are a member of. 

     

    3. Create a second Gallery and set Items ==  MicrosoftTeams.GetChannelsForGroup(Gallery1.Selected.id).value

    4. Add the following labels to the Template for this Gallery: 

        -- ThisItem.displayName   ---> This is the CHANNEL display name

        -- ThisItem.description      ---> This is the Channel descriptor 

        -- ThisItem.id                     ---> This is the CHANNEL ID that you plug into the formula above (2) 

     

    Now you have a list of the CHANNELS associated with the proper TEAM

     

    Combine everything above and you will be able to send messages to the appropriate recipients. 

     

    Hope this helps! 

    Ted 

     

     

  • MattRo Profile Picture
    40 on at

    Hi Ted, thanks for the feedback. I didn't use the MicrosoftTeams.PostMessageToChannelV3 action because I am posting to a chat. As far as I can tell, in this scenario, there is no "Team identifier here (1)" for a chat.

     

    But, now that I think about it, maybe there is an analogous action to MicrosoftTeams.GetAllTeams().value that would give me an ID for all of my chats maybe like MicrosoftTeams.GetAllConversations().value? I will take a look at at some point. Thanks. -Matt

  • IcE-TanK Profile Picture
    22 on at

    I have tried many things and gave up already, I used the power flow and it sent the notification but with the improper details, i hope to solve this soon enough 

  • Volker Steltenkamp Profile Picture
    10 on at
    Thanks to @mattro I finally get this to work. Its now:
     
    MicrosoftTeams.PostMessageToConversation(
        "User";
        "Group Chat"; -> Fixed Value
        ParseJSON( 
            JSON( 
                {
                recipient: ThisItem.id;
     
                messageBody: "<p>Test2</p>"
                }
            )
        )
    )
    I use this in a gallery where all my Chats are listed using "ClearCollect(colMyChats;MicrosoftTeams.GetChats("Group";"all").value)" and you´ll need the ID of the Conversation as the recipient. In addtion according to Microsoft Teams - Connectors | Microsoft Learn even the V3 Version of "PostMessageToChannelV3" is deprecated so I think we have to use PostMessageToConversation for both posting to Channels and Chats!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard