-
Notifications
You must be signed in to change notification settings - Fork 34
Better: Add HTML Sending Guide for RingCX Messaging. RD-41088 #273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aymebou
wants to merge
2
commits into
ringcentral:master
Choose a base branch
from
aymebou:rd41088-contents-api-html-abo
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| # Sending Rich Text Messages | ||
|
|
||
| Agent messages sent via the [Create Content API](https://developers.ringcentral.com/engage/digital/api-reference/Contents/createContent) support an optional `body_format` parameter on **RingCX Web Messaging** and **RingCX Mobile Messaging** channels where rich text has been enabled. When set to `html`, the body is interpreted as HTML and rendered natively in the client. | ||
|
|
||
| ## Request Example | ||
|
|
||
| ```bash | ||
| curl -X POST "https://[YOUR DOMAIN].api.digital.ringcentral.com/1.0/contents" | ||
| ``` | ||
|
|
||
| ```json | ||
| { | ||
| "in_reply_to_id": "<in_reply_to_id>", | ||
| "body": "<strong>Hello</strong> <u>world</u>", | ||
| "body_format": "html" | ||
| } | ||
| ``` | ||
|
|
||
| Omitting `body_format` (or setting it to `text`) treats the body as plain text, and the end customer will see the raw HTML instead of the rendered result. | ||
|
|
||
| !!! note | ||
| Rich text must be enabled on the channel by an administrator before `body_format=html` can be used. Passing `body_format=html` on a channel without this feature returns a `422` error. | ||
|
|
||
| ## Supported HTML | ||
|
|
||
| ### Tags | ||
|
|
||
| | Tag | Purpose | | ||
| |-----|---------| | ||
| | `<p>`, `<br>` | Paragraphs and line breaks | | ||
| | `<strong>`, `<em>`, `<u>` | Bold, italic, underline | | ||
| | `<h1>` – `<h6>` | Headings | | ||
| | `<blockquote>` | Quoted text | | ||
| | `<ul>`, `<li>` | Unordered lists (`ol` is not supported) | | ||
| | `<a>` | Hyperlinks | | ||
| | `<span>` | Inline styling, such as colors. | | ||
| | `<hr>` | Horizontal rule | | ||
|
|
||
| Any tag not in this list is rejected with a `422` status and an explicit validation error. | ||
|
|
||
| ### Attributes | ||
|
|
||
| | Attribute | Purpose | | ||
| |-----------|---------| | ||
| | `href` | Link target URL | | ||
| | `target` | Link opening behavior, e.g. `_blank` to open in new tab | | ||
| | `style` | To enrich an element with some style. Only `color` and `text-align` are accepted (see below) | | ||
|
|
||
| All other attributes are either stripped or produce a validation error. | ||
|
|
||
| ### CSS properties | ||
|
|
||
| Only two CSS properties are allowed inside `style`: | ||
|
|
||
| | Property | Accepted values | | ||
| |----------|----------------| | ||
| | `color` | Six-digit hex only — `#RRGGBB` | | ||
| | `text-align` | `start`, `center`, `end` | | ||
|
|
||
| **Example of a valid HTML:** | ||
|
|
||
| ```html | ||
| <p style="text-align:center"> | ||
| <span style="color:#E74C3C"><strong>Important notice</strong></span> | ||
| </p> | ||
| <ul> | ||
| <li>First item</li> | ||
| <li>Second item</li> | ||
| </ul> | ||
| <a href="https://example.com" target="_blank">Learn more</a> | ||
| ``` | ||
|
|
||
| ## Validation errors | ||
|
|
||
| When the submitted HTML violates the allow-list, the API returns `422` with `error: validation_error` and an `errors` array describing each violation. Fix the offending markup and retry — no message is created until the body passes validation. Of course, when using `text`, the HTML inside the body is escaped and rendered as-is to the end-customer. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the preview on the swagger for that option for info, I'll also use it for the WA development guide when I'll create the page :