WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud
  • Tanzu
    • Application Modernization
    • Tanzu services
    • Tanzu Community Edition
    • Tanzu Kubernetes Grid
    • vSphere with Tanzu
  • Home Lab
  • Nested Virtualization
  • 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

  • Quick Tip - lldpnetmap, a handy utility to map pNic to pSwitch on ESXi
  • Heads Up - Workaround for changing Mac OS X VM display resolution in vSphere & Fusion
  • Enhancements to Hybrid Linked Mode (HLM) in VMC using the new vCenter Cloud Gateway
  • Datastore File Management using vCLI vifs
  • How to deploy Tanzu Kubernetes Grid (TKG) Cluster with Antrea CNI 

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

Author

William Lam is a Senior Staff Solution Architect working in the VMware Cloud team within the Cloud Infrastructure Business Group (CIBG) at VMware. He focuses on Cloud Native technologies, Automation, Integration and Operation for the VMware Cloud based Software Defined Datacenters (SDDC)

Connect

  • Email
  • GitHub
  • LinkedIn
  • RSS
  • Twitter
  • Vimeo

Recent

  • Self-Contained & Automated VMware Cloud Foundation (VCF) deployment using new VLC Holodeck Toolkit 03/29/2023
  • ESXi configstorecli enhancement in vSphere 8.0 Update 1 03/28/2023
  • ESXi on Intel NUC 13 Pro (Arena Canyon) 03/27/2023
  • Quick Tip - Enabling ESXi Coredumps to be stored on USB 03/26/2023
  • How to disable the Efficiency Cores (E-cores) on an Intel NUC? 03/24/2023

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 © 2023

 

Loading Comments...