Reference · Developer Integration Guide
Shortform event
This guide is for developers applying the integration. You don’t need it to operate the Admin.
Comment notifications through Shortform events
You can register a callback defined with addShortformEventListener() to perform separate actions when comments are created/updated/deleted, using the DETAIL_CREATE_COMMENT / DETAIL_UPDATE_COMMENT / DETAIL_DELETE_COMMENT event messages fired by Shortform.
See the Shortform Events document for more events
- Run the callback defined with addShortformEventListener() and implement behavior based on the event messages received.
- Receive events related to comment create/update/delete through DETAIL_CREATE_COMMENT / DETAIL_UPDATE_COMMENT / DETAIL_DELETE_COMMENT.
- Receive the Shortform and Comment information related to the event from the payload.
Event message and payload specification
| Message | Description |
|---|---|
| DETAIL_CREATE_COMMENT | Create comment |
| DETAIL_UPDATE_COMMENT | Update comment |
| DETAIL_DELETE_COMMENT | Delete comments |
| Payload | Type |
|---|---|
| shorts | Shorts |
| comment | Comment |
Example
<script type="text/javascript" src="https://static.shoplive.cloud/shoplive-shortform.js"></script>
<script>
// Initialize
cloud.shoplive.initShortform({ accessKey: 'YOUR ACCESS KEY HERE' });
// Shortform event listener
const listener = (message, payload) => {
switch(message) {
case "DETAIL_CREATE_COMMENT":
console.log("User creates comment : ", payload);
//Notify Shortform creation through internal logic
...
break;
case "DETAIL_UPDATE_COMMENT":
console.log("User updated comment : ", payload);
//Notify Shortform update through internal logic
...
break;
case "DETAIL_DELETE_COMMENT":
console.log("User deleted comment : ", payload);
//Notify Shortform deletion through internal logic
...
break;
}
}
// Add event listener
cloud.shoplive.addShortformEventListener(listener);
</script>
Related documents:
- Track Shortform events
- Shortform Events