Endpoint / method to post a reply to a message
New users to our community often post questions that are incomplete -- not enough detail for our expert users to post a meaningful reply. I would like to implement a "Needs more info" button that our Super Users can click on the topic root message that will create a boilerplate reply, perhaps from a generic moderator account, so that our Super Users don't feel the need to coax/cajole more details out of the OP.
I think the way to implement this is via an endpoint. Am I on the right track?
I've figured out how to add an action button to just the root message. What I'd like is:
- an example of an endpoint that posts/replies or otherwise modifies an existing message
- an example of the action script that I would add to the button to call that endpoint...and ideally refresh the message so that the person who clicked it would see the change applied.
Thanks,
Chris
cjdinger -
Here is the basic script which you use to call an endpoint. You will need to change the button-id and EndpointURL.
<@liaAddScript> ;(function($) { $(document).ready(function(){ $("button-id").click(function(){ $.post("EndpointURL", {'thread-id':"${page.context.thread.topicMessage.uniqueId}", function(status,data){ location.reload(); }}) }) }) })(LITHIUM.jQuery); </@liaAddScript>
jQuery helpful links:
https://www.w3schools.com/jquery/ajax_post.asp
https://www.w3schools.com/jquery/event_click.asp
On the Endpoint side.
<#assign messageID = http.request.parameters.name.get("thread-id","")> <#if messageID != ''> <#assign templateMessage = "This is boilerplate reply" /> <#attempt> <#assign restapi = restadmin("/messages/id/${messageID}/reply?message.body=${templateMessage?url}") /> <#recover> error in all </#attempt> </#if>
Endpoints helpful links:
https://community.lithium.com/t5/Components-endpoints-and-the/About-endpoints/ta-p/108971
https://community.lithium.com/t5/Developer-Knowledge-Base/Working-with-Endpoints/ta-p/60240
This is the just very basic example how you can achieve this. You may add validations to jquery and endpoint.