This feature is available with the Plugin for Business plan and higher.
If you're on the Plugin for Startup or Plugin Expansion plan, consider upgrading to access this feature. For more details, visit our pricing page or contact support.
Comments attach a conversation thread to any section or block in the template. Users can reply, mention teammates, react with a thumb up or down, and resolve a thread once it is handled. Every conversation is stored through your own API endpoints.
To enable the feature, set the following option inside Topol Options:
Comments work without the options below, but attribution and unread tracking depend on them. Without a current user the editor sends an empty currentUserId, and it can no longer tell which comments are unread.
js
currentUser: { userId: "current user userId", name: "current user name", profilePhotoUrl: "link to the current user's profile picture",};templateId: "id";
teamUsers lists the colleagues who can be mentioned in a thread.
All three properties are required on both currentUser and every entry in teamUsers, and userId has to be a string. The current user is filtered out of teamUsers automatically, so passing the whole team is fine; that person simply cannot mention themselves.
All keys are camelCase. Until the next major the editor also sends the old names with every request (template_id, entity_id, current_user_id, sort_by, show_resolved) and accepts the old snake_case names in responses (involved_users, created_by, created_at, read_by, user_id, profile_photo_url), so backends written against them keep working. Every key and type is listed in the backend key reference.
entityId corresponds to authorize.entityId in Options
currentUserId
user id of current user
sortBy
"date" or "unread"
showResolved
boolean
The editor calls this endpoint on load, whenever sorting or the resolved-display preference changes, after a comment is marked read or unread, and on every editor.refreshComments(key) call.
Response:
json
{ "success": true, "data": [ { "key": "conversation_key", //section or block uid on which the conversation is based "type": "block", // or section "resolved": false, "delete": false, "involvedUsers": [ { "userId": "userId", "profilePhotoUrl": "link to the user's profile picture", "name": "user name" } ], // list of involved users, maximum of the first 7 users will be displayed "comments": [ { "id": "comment_id", "createdBy": { "userId": "userId", "profilePhotoUrl": "link to the user's profile picture", "name": "user name" }, "createdAt": "ISO 8601 time", "content": "text content of the comment", "readBy": ["userId of the user who saw the comment"], "reactions": [ { "createdBy": { "userId": "userId", "profilePhotoUrl": "link to the user's profile picture", "name": "user name" }, "type": "thumb-up" // or thumb-down } ] } ] } ]}
A few details are worth knowing before implementing this response:
resolved accepts true, false, 0 or 1, which suits a MySQL-backed store directly. Both resolved and delete may be omitted.
reactions may be omitted. Only thumb-up and thumb-down are rendered; any other value is accepted and then ignored.
Every object under createdBy needs all three of userId, name and profilePhotoUrl. The list is validated as a whole, so one comment with an incomplete author blanks the entire panel.
Unread state is derived from the last comment of each thread. readBy on earlier comments is never inspected.
The response is the same conversation object as above, returned on its own rather than inside an array. The involvedUsers list is not rendered in this view.
This endpoint is called when a conversation is opened, when the user selects a different block or section, right after a comment is posted, and when editor.refreshComments("conversation_key") is called with the key of the open conversation.
A resolved conversation carries a Resolved badge and is dimmed in the comments panel, so open threads stand out. Inside a resolved conversation:
The reply box is replaced by "This conversation is resolved." and a Reopen conversation button.
The resolve button's tooltip reads Reopen conversation instead of Mark as resolved.
Mark as unread is turned off, with the tooltip "Resolved conversation can't be marked as unread".
Show resolved, in the comments panel's sort menu, is off by default. The editor sends its state as the showResolved parameter of List conversations, and your endpoint decides whether to return resolved conversations.
Resolving and reopening both go through the endpoint below.
This endpoint is called when you click to resolve button.
Request:
json
{ "templateId": "id of the template", "entityId": "entity userId", "currentUserId": "current user userId", "hostname": "origin", "key": "api key", "resolved": true // or false depending on whether we want resolved or unresolved}
This endpoint is called when new comment is entered.
Request:
json
{ "templateId": "id of the template", "entityId": "entity userId", "currentUserId": "current user userId", "hostname": "origin", "key": "api key", "type": "block", // or section, is for setting up a conversation "content": "text content of comment", "mentions": ["userId of the user who is mentioned in the comment"]}
type carries block or section when the comment opens a new conversation, and an empty string when replying to an existing one, so the endpoint has to tolerate all three. The values in mentions are the userId strings from teamUsers.
This endpoint is called when edit specific comment, react (add thumbs up or down) to specific comment or click to mark as read/unread conversation (will call for last comment of conversation).
Request:
json
{ "templateId": "id of the template", "entityId": "entity userId", "currentUserId": "current user userId", "hostname": "origin", "key": "api key", // if edit the comment "content": "new text content of comment", "mentions": ["userId of the user who is mentioned in the comment"], // if react to the comment "react": "thumb-up", // or thumb-down // if click on mark as read/unread on the parent conversation "action": "mark_as_read" // or mark_as_unread}
Comments do not poll, so after your application adds or deletes a comment the editor needs to be told to reload.
js
// reload the list, and the open thread if this key matches iteditor.refreshComments("conversation_key");// reload the conversation list onlyeditor.refreshComments("");
The key is required. The conversation list reloads on every call whatever key is passed, so an empty string is the way to refresh only the list. A key matching the currently open conversation additionally reloads that thread's detail view, which makes the affected key the right value to pass after a specific thread changed.
Comments in Template
This feature is available with the Plugin for Business plan and higher.
If you're on the Plugin for Startup or Plugin Expansion plan, consider upgrading to access this feature. For more details, visit our pricing page or contact support.
Comments attach a conversation thread to any section or block in the template. Users can reply, mention teammates, react with a thumb up or down, and resolve a thread once it is handled. Every conversation is stored through your own API endpoints.
To enable the feature, set the following option inside Topol Options:
Identifying users and the template
Comments work without the options below, but attribution and unread tracking depend on them. Without a current user the editor sends an empty
currentUserId, and it can no longer tell which comments are unread.teamUserslists the colleagues who can be mentioned in a thread.All three properties are required on both
currentUserand every entry inteamUsers, anduserIdhas to be a string. The current user is filtered out ofteamUsersautomatically, so passing the whole team is fine; that person simply cannot mention themselves.WARNING
Before implementing the endpoints, check how to work with API endpoints.
Key names
All keys are camelCase. Until the next major the editor also sends the old names with every request (
template_id,entity_id,current_user_id,sort_by,show_resolved) and accepts the old snake_case names in responses (involved_users,created_by,created_at,read_by,user_id,profile_photo_url), so backends written against them keep working. Every key and type is listed in the backend key reference.List conversations
/{API.CONVERSATIONS}GETapplication-jsonParams:
The editor calls this endpoint on load, whenever sorting or the resolved-display preference changes, after a comment is marked read or unread, and on every
editor.refreshComments(key)call.Response:
A few details are worth knowing before implementing this response:
resolvedacceptstrue,false,0or1, which suits a MySQL-backed store directly. Bothresolvedanddeletemay be omitted.reactionsmay be omitted. Onlythumb-upandthumb-downare rendered; any other value is accepted and then ignored.createdByneeds all three ofuserId,nameandprofilePhotoUrl. The list is validated as a whole, so one comment with an incomplete author blanks the entire panel.readByon earlier comments is never inspected.Detail conversation
/{API.CONVERSATIONS}/{conversation_key}GETapplication-jsonkey,hostname,templateId,entityId,currentUserIdThe response is the same conversation object as above, returned on its own rather than inside an array. The
involvedUserslist is not rendered in this view.This endpoint is called when a conversation is opened, when the user selects a different block or section, right after a comment is posted, and when
editor.refreshComments("conversation_key")is called with the key of the open conversation.Unread messages should be marked as read.
Resolved conversations
A resolved conversation carries a Resolved badge and is dimmed in the comments panel, so open threads stand out. Inside a resolved conversation:
Show resolved, in the comments panel's sort menu, is off by default. The editor sends its state as the
showResolvedparameter of List conversations, and your endpoint decides whether to return resolved conversations.Resolving and reopening both go through the endpoint below.
Resolve or unresolve conversation
/{API.CONVERSATIONS}/{conversation_key}PATCHThis endpoint is called when you click to resolve button.
Request:
Expected Response: STATUS 200
Delete conversation
/{API.CONVERSATIONS}/{conversation_key}DELETEkey,hostname,templateId,entityId,currentUserIdThis endpoint is called when user deletes a conversation.
Consider whether to delete the conversation or just soft delete.
Expected Response: STATUS 200
Add comment
/{API.CONVERSATIONS}/{conversation_key}POSTThis endpoint is called when new comment is entered.
Request:
typecarriesblockorsectionwhen the comment opens a new conversation, and an empty string when replying to an existing one, so the endpoint has to tolerate all three. The values inmentionsare theuserIdstrings fromteamUsers.Expected Response: STATUS 200
Edit, react, read or unread the comment
/{API.COMMENTS}/{comment_id}POSTThis endpoint is called when edit specific comment, react (add thumbs up or down) to specific comment or click to mark as read/unread conversation (will call for last comment of conversation).
Request:
Expected Response: STATUS 200
Delete user's comment
/{API.COMMENTS}/{comment_id}DELETEkey,hostname,templateId,entityId,currentUserIdThis endpoint is called when user deletes a comment.
Expected Response: STATUS 200
refreshComments
Comments do not poll, so after your application adds or deletes a comment the editor needs to be told to reload.
The key is required. The conversation list reloads on every call whatever key is passed, so an empty string is the way to refresh only the list. A key matching the currently open conversation additionally reloads that thread's detail view, which makes the affected key the right value to pass after a specific thread changed.
toggleComments
Opens and closes the comments panel from your own UI.