Yammer REST API - Create Formatted Normal Message/Post

2 min read 05-10-2024
Yammer REST API - Create Formatted Normal Message/Post


Crafting Engaging Yammer Posts with the REST API: A Guide to Rich Formatting

The Yammer REST API allows developers to programmatically interact with Yammer, including creating and managing posts. However, creating visually appealing and engaging posts often requires formatting features beyond plain text. This article will guide you through utilizing the Yammer REST API to create formatted "Normal" messages (non-poll or question types) with rich text features.

The Challenge: Going Beyond Plain Text

Imagine you want to create a Yammer post announcing a new company initiative. You need to include a catchy title, a clear description, and maybe even a link to a relevant document. Simply posting plain text won't do justice to your message. This is where the power of formatting comes in.

The Solution: Leverage the Yammer REST API's Formatting Capabilities

The Yammer REST API allows you to create posts with a variety of formatting options, mirroring the formatting capabilities available in the standard Yammer interface. Here's a breakdown of the key elements:

  1. The body Parameter: This is where you input the actual content of your post. You can use plain text within the body parameter, but to enable rich formatting, you must utilize the body.body parameter.

  2. The body.body Parameter: This parameter allows you to embed HTML-like formatting tags within the message body. You can use tags for headings, bold text, italics, lists, links, and even images.

An Example: Creating a Formatted Post

Let's consider a simple example of announcing a new project:

{
  "body": {
    "body": "<h2>Introducing Project Phoenix!</h2> <p>Get ready for an exciting new project focused on streamlining our workflows. More details and updates will be shared soon. </p> <p>Stay tuned! </p> <a href='https://www.example.com/projectphoenix'>Learn more about Project Phoenix.</a>"
  },
  "message_type": "normal",
  "open_graph": {}
}

This JSON payload will create a Yammer post with:

  • A heading "Introducing Project Phoenix!" using <h2> tag.
  • Paragraph text with p tags.
  • A link to a relevant website using <a> tag.

Important Considerations:

  • Valid Formatting Tags: While you can use HTML-like tags, the Yammer API supports only a specific subset of tags. You can find a complete list of supported tags in the official Yammer API documentation.

  • Security: Ensure your formatting tags do not introduce potential security risks. Sanitize all user inputs to prevent cross-site scripting (XSS) vulnerabilities.

  • Preview Your Posts: Before posting, consider utilizing a tool to preview your formatted content to ensure the desired look and feel.

Going Beyond the Basics: Advanced Formatting Options

The Yammer API offers even more advanced formatting capabilities:

  • Images: You can add images to your posts using the body.body parameter and the img tag.
  • Attachments: You can attach files and documents directly to your posts.

The Power of Formatted Posts

By leveraging the formatting options provided by the Yammer REST API, you can create engaging and informative posts that enhance communication within your Yammer network. This can lead to greater user engagement, improved information dissemination, and overall better collaboration.

Resources:

Remember, utilizing the Yammer REST API to create formatted posts allows you to go beyond simple text and build richer, more impactful communication within your organization.