|
| 1 | +Rich text is used in DevRev to represent text fields that can be formatted and can contain mentions, for example, description of an issue or body of a conversation. |
| 2 | + |
| 3 | +A simple rich text looks like one markdown string wrapped in an array: `["Hello **world**!"]`. |
| 4 | +Markdown must conform to [CommonMark Spec v0.30](https://spec.commonmark.org/0.30). |
| 5 | + |
| 6 | +## Rich text mentions |
| 7 | + |
| 8 | +To support mentions, `rich_text` can be formatted as an array of strings and mention objects like so: |
| 9 | +```json |
| 10 | +[ |
| 11 | + "Hello ", |
| 12 | + {"ref_type":"external_user_type", "id":"1...", "fallback_record_name": "John Doe"}, |
| 13 | + "how are you?" |
| 14 | +] |
| 15 | +``` |
| 16 | + |
| 17 | + |
| 18 | +Mention represents any mention (user, issue, etc.) in rich text and is defined as: |
| 19 | +| Field | Type | Required | Description | |
| 20 | +| ---------------------- | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------ | |
| 21 | +| `id` | String | Yes | Identifier of the item being mentioned. This could be a user ID or any other identifier, in the format used by the source system. | |
| 22 | +| `ref_type` | String | Yes | Type of the item being mentioned. Examples include "issue", "comment", etc. The recipe converts this according to user mappings. | |
| 23 | +| `fallback_record_name` | String | No | The text to display if the mention cannot be resolved. This could be a user's display name or a ticket title, for instance. | |
| 24 | + |
| 25 | +In reverse, the loader should expect the following structure: |
| 26 | +```json |
| 27 | +{ |
| 28 | + "type": "rich_text", |
| 29 | + "content": [ |
| 30 | + "Hello ", |
| 31 | + { |
| 32 | + "ref_type": "external_user_type", |
| 33 | + "id": "don:identity:dvrv-us-1:devo/xyz:devu/1", |
| 34 | + "fallback_record_name": "John Smith" |
| 35 | + }, |
| 36 | + "how are you?" |
| 37 | + ] |
| 38 | +} |
| 39 | +``` |
| 40 | + |
| 41 | +## Importing articles |
| 42 | + |
| 43 | +An article is a document containing essential information about the company's products, services, and processes. |
| 44 | +Articles support Markdown as well as HTML. |
| 45 | + |
| 46 | +Articles support mentions to artifacts and articles. An inline attachment must be mapped to an artifact. |
| 47 | +A link to another article must be mapped to an article. |
| 48 | + |
| 49 | +### Managing permissions |
| 50 | + |
| 51 | +You can manage article permissions in the `shared_with` field. Permissions can reference users, groups, and [platform groups](./platform_groups.md). |
| 52 | + |
| 53 | +### Inline attachments |
| 54 | +If an inline attachment is hosted in the source system, it must be created as an artifact in DevRev. |
| 55 | +The same link cannot be used as the attachment is deleted in the source system when our customers deactivate the account. |
| 56 | +However, creating an artifact is not enough. The artifact must be linked in the appropriate place in the article content. |
| 57 | + |
| 58 | +The following HTML example shows an inline attachment: |
| 59 | +```html |
| 60 | +<img src="don:core:dvrv-us-1:devo/0:artifact/1" alt="Alt Text"/> |
| 61 | +``` |
| 62 | + |
| 63 | +The following Markdown example shows an inline attachment: |
| 64 | +```markdown |
| 65 | + |
| 66 | +``` |
| 67 | + |
| 68 | +Let's say the content of your external system looks like this: |
| 69 | +```html |
| 70 | +<p> |
| 71 | + This is an article with one image. |
| 72 | +</p> |
| 73 | +<p> |
| 74 | + <img src="https://devrev.zendesk.com/hc/article_attachments/29908544740244" alt="download.jpeg"> |
| 75 | +</p> |
| 76 | +``` |
| 77 | + |
| 78 | +The content in DevRev should look like this: |
| 79 | +```html |
| 80 | +<p> |
| 81 | + This is an article with one image. |
| 82 | +</p> |
| 83 | +<p> |
| 84 | + <img src="don:core:dvrv-us-1:devo/0:artifact/1" alt="download.jpeg"> |
| 85 | +</p> |
| 86 | +``` |
| 87 | + |
| 88 | +`don:core:dvrv-us-1:devo/0:artifact/1` is the ID of the artifact created in DevRev corresponding to the attachment with ID `29908544740244` in the external source system. |
| 89 | +To achieve this, you need to transform the content of the article to the following JSON: |
| 90 | +```json |
| 91 | +[ |
| 92 | + "<p>This is an article with one image.</p><p><img src=\"", |
| 93 | + { |
| 94 | + "ref_type": "artifact", |
| 95 | + "id": "29908544740244", |
| 96 | + "fallback_record_name": "<fallback link>" |
| 97 | + }, |
| 98 | + "\" alt=\"download.jpeg\"></p>" |
| 99 | +] |
| 100 | +``` |
| 101 | + |
| 102 | +The `ref_type` should be set to artifact and the ID should be the ID of the attachment in the external source system. |
| 103 | +The platform replaces the mention block with the ID of the corresponding artifact. |
| 104 | +The resolved value is not wrapped in double quotes. |
| 105 | + |
| 106 | +### Links to other articles |
| 107 | +If there is a link to another article in the content of the article, you need to create a mention to the article. |
| 108 | +The link must be to an article that was either created in previous syncs or is created in the current sync. |
| 109 | +At the extractor stage, it is impossible to predict the ID of the article that is created in DevRev. |
| 110 | +This is why the platform handles this. This feature is only available for the HTML format. |
| 111 | +However, since Markdown can contain HTML, you can use the same approach for Markdown as well. |
| 112 | + |
| 113 | +The following HTML example shows a link to another article: |
| 114 | +```html |
| 115 | +<a data-article-id="don:core:dvrv-us-1:devo/0:article/10" href="/ART-10" target="_self"> |
| 116 | + Contact our Support Team |
| 117 | +</a> |
| 118 | +``` |
| 119 | + |
| 120 | +Let's say the content of your external system looks like this: |
| 121 | +```html |
| 122 | +<p> |
| 123 | + You can create an account and log-in |
| 124 | + <a href="https://devrev.zendesk.com/hc/en-us/articles/360059607772" target="_self"> |
| 125 | + only |
| 126 | + </a> |
| 127 | + with the company email. |
| 128 | +</p> |
| 129 | +``` |
| 130 | + |
| 131 | +The content in DevRev should look like this: |
| 132 | +```html |
| 133 | +<p> |
| 134 | + You can create an account and log-in |
| 135 | + <a data-article-id="don:core:dvrv-us-1:devo/0:article/10" href="/ART-10" target="_self"> |
| 136 | + only |
| 137 | + </a> |
| 138 | + with the company email. |
| 139 | +</p> |
| 140 | +``` |
| 141 | + |
| 142 | +`don:core:dvrv-us-1:devo/0:article/10` is the ID of the article created in DevRev corresponding to the article with ID `360059607772` in the external source system. |
| 143 | +To achieve this, you need to transform the content of the article to the following JSON: |
| 144 | +```json |
| 145 | +[ |
| 146 | + "You can create an account and log-in <a data-article-id=\"", |
| 147 | + { |
| 148 | + "ref_type": "article", |
| 149 | + "id": "360059607772", |
| 150 | + "fallback_record_name": "<fallback article ID>" |
| 151 | + }, |
| 152 | + "\" target=\"_self\"> only</a> with the company email." |
| 153 | +] |
| 154 | +``` |
| 155 | + |
| 156 | +The `ref_type` should be set to the item type in the external system that is being mapped to articles. |
| 157 | +For example, if you're importing documents from the external system as articles, |
| 158 | +the `ref_type` should be set to documents. The ID should be the ID of the item in the external source system. |
| 159 | + |
| 160 | +The platform replaces the mention block with the ID of the corresponding article in DevRev as well as adds the href attribute with the appropriate value. |
0 commit comments