WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple
You are here: Home / Uncategorized / Quick Tip - Encoding emojis in a Microsoft Teams message using O365 API

Quick Tip - Encoding emojis in a Microsoft Teams message using O365 API

07.13.2020 by William Lam // Leave a Comment

One easy way to integrate with Microsoft Teams is to use an incoming webhook which can be configured on a per-channel basis. While working on creating some new PowerShell functions for the VMware Event Broker Appliance (VEBA), I was stuck trying to figure out how to properly encode an emoji icon into the MessageCard type for sending a message to a teams channel.

After a bit of searching and some trial/error, I finally found that you needed to use the emoji hex code with the following format:

&#x<EMOJI-HEX-CODE>;

I used this site here to find the emoji to hex code translation. In addition, I also found that the emojis will only render when used in either the activityTitle or text property of the MessageCard. I was initially trying use this within the facts property which does not work.

Here is a working PowerShell example on constructing the the MessageCard JSON which utilizes emojis:

$teamsMessage = [PSCustomObject][Ordered]@{
    "@type"      = "MessageCard"
    "@context"   = "http://schema.org/extensions"
    "themeColor" = '0078D7'
    "summary"      = "VMC SDDC Deleted"
    "sections"   = @(
        @{
            "activityTitle" = "&#x1F6A8; **VMC SDDC Deleted** &#x1F6A8;";
            "activitySubtitle" = "In VMC-Customer[0] Organization";
            "activityImage" = "https://blogs.vmware.com/vsphere/files/2019/07/Icon-2019-VMWonAWS-Primary-354-x-256.png"
            "facts" = @(
                @{
                    "name" = "SDDC:";
                    "value" = "M11-SDDC";
                },
                @{
                    "name" = "Date:";
                    "value" = "2020-07-12T11:20:03.364000Z";
                },
                @{
                    "name" = "User:";
                    "value" = "*protected email*";
                }
            );
            "markdown" = $true;
            "text" = "&#x1F629; This is the text field &#x1F629;";
        }
    )
}

$body = $teamsMessage | ConvertTo-Json -Depth 5
Invoke-WebRequest -Uri $teamsWebhookURL  -Method POST -ContentType "application/json" -Body $body | Out-Null

Here is what the rendered Microsoft Teams message will looks like posting to the webhook:

More from my site

  • Exploring new VCSA VAMI API w/PowerCLI: Part 7
  • How to Deploy an OVF/OVA in the ESXi Shell
  • New vSphere 6.5 APIs worth checking out
  • Quick Tip - Suppress in-guest VMware Tools update notifications
  • Can I deploy both Tanzu Kubernetes Grid (TKG) and vSphere with Tanzu on same vSphere Cluster?

Categories // Uncategorized Tags // Emojis, Microsoft Teams

Thanks for the comment!Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025
  • vCenter Identity Federation with Authelia 04/16/2025
  • vCenter Server Identity Federation with Kanidm 04/10/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025

 

Loading Comments...