Backoffice SDK

Important
Improperly applying customizations with the backoffice SDK can impact the Wix Answers App experience.
The Backoffice SDK enables you to add JavaScript code to customize the Wix Answers App, which is used by agents and administrators. You manage this SDK by adding JavaScript to the Custom JS pane on the Backoffice Custom Code page (https://<tenant_subdomain>.wixanswers.com/app/settings/custom-code).

You can test the code in your browser console before entering it on the Backoffice Custom Code page.

The following are some examples of what you can do using the SDK.
Note
If you have specific integration needs not met using the existing SDK, contact us at help@wixanswers.com with your request.

Methods

addListener(eventType:EventType, listener:function)

Add a listener for an event. Different payload are sent for different events.

Returns: None

The event types are as follows:
Type
Description
Payload
eventTypes.appLoaded
App Loaded
None
eventTypes.ticketLoaded
Ticket page loaded
{ticket: Ticket object, timeline: Ticket timeline object}
eventTypes.ticketWillLoad
Ticket page is about to be loaded
{ticket: Ticket object, timeline: Ticket timeline object}
eventTypes.ticketInfoSectionAdded
An info section was added to a ticket
??
eventTypes.ticketRelationAdded
Article relation added to a ticket
{ticket: Ticket, articleIds: [list of article GUIDs]}
eventTypes.ticketReplied
Agent replied to a ticket (not internal note)
{ticket: Ticket, replyContent: string}
eventTypes.ticketCustomFieldsUpdated
Ticket's custom field value added or modified
{ticket: Ticket, customFields: Map of {<field-name>: <value>}}

value format varies according to field type.
eventTypes.multipleTicketsReplied
Agent replied in bulk to multiple tickets (not internal notes)
{tickets: [list of ticket objects], replyContent: string}
eventTypes.multipleTicketsRelationAdded
Article relation added in bulk to multiple tickets
{tickets: [list of ticket objects], articleIds: [list of article GUIDs]}

addTicketInfoSection(title:string, HTML:string, isOpen:Boolean)

Add information section to the right sidebar when viewing a ticket. Set the third parameter to true to configure that the new section is open by default.

Returns: None

forceSavedRepliesSearchLocale(locale:two-letter locale string)

Configure that saved replies are searched only in the specified locale.

Returns: None

getCurrentAgent

Get list current agent.

Returns: Agent object

insertHtmlToReplyArea(HTML:string)

Append HTML to the reply area without sending the reply.

Returns: None

notify({content: string})

Pop up a UI notification on the bottom right of the screen.

Returns
: None
1
.notify({'content': 'Something wonderful happened!'})

setTicketRelatedArticlesFilter(filters:object)

Filter articles available to select in the related articles picker.

The input is an object, as follows:

{
    categoryIds: [<list of categories to include if the article matches any of them>],
    excludeCategoryIds: [<list of categories to exclude if the article matches any of them>],
    hasAllOfLabelIds: [<list of labels to include if the article matches all of them>],
    hasAnyOfLabelIds:  [<list of labels to include if the article matches any of them>],
    notHasAnyOfLabelIds: [<list of labels to exclude if the article matches any of them>],
}

Returns: None

Examples

Adding a Custom Section in the User Information Sidebar

To create a custom section in the user's information side bar inside a ticket page, add two methods: 
  • answersBackofficeSdk.addListener
  • answersBackofficeSdk.addTicketInfoSection

The first method enables Wix Answers to listen to the "ticket page loaded" event and receive the ticket's data. The second enables Wix Answers to add custom sections to the side bar.
Here is an example of a snippet that queries some service, checks if the user that opened the ticket is a "premium" user or not, and adds a custom section to the ticket page side bar.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function isPremiumUserByEmail(email, cb) {
 var isPremium = Math.random() > 0.5; //dummy check, replace this with an AJAX call to an external service, or any other meaningful action
 cb(isPremium);
}

function addPremiumUserSidebarItem(isPremium) {
    answersBackofficeSdk.addTicketInfoSection('Custom Data', '<p>Premium: ' + isPremium + '</p>');
}

answersBackofficeSdk.addListener(answersBackofficeSdk.eventTypes.ticketLoaded, function (ticketData) {
    console.info(ticketData);
    isPremiumUserByEmail(ticketData.user.email, function (isPremium) {
    
        addPremiumUserSidebarItem(isPremium);
    });
});
Test this script by adding it in the developers console and then navigating to a ticket page. To add this to your site, enter the script in the Custom JS pane on the Backoffice Custom Code page.

When the script is active, your sidebar includes the following:

Hide Widgets from the Settings Menu

Add the function answersBackofficeSdk.setHiddenWidgetIds to make widgets accessible only using a direct link. This is useful if you want to prevent accidental changes to your widget's settings.
1
2
3
4
answersBackofficeSdk.setHiddenWidgetIds([
    'a601657c-d618-be0f-a943-e6181512073f',
    'b342347a-1528-4fed-2323-234234ababa2'
]);