Table of Contents

Bundle Installation

  1. Log into your NetSuite account
  2. Find the bundle by navigating to Customization>SuiteBundler>Search & Install Bundles
  3. Search for ‘NS Support Bot for Slack’ in the search field
  4. Click on the ‘Slack Support Bot’ name
  5. Click ‘Install’
  6. Once the installation has completed navigate to Setup>Slack Setup>Slack Setup and follow the instructions to connect your Slack account to NetSuite Support Bot
  7. Invite NetSuite Support Bot to the channel you chose as your default channel in the previous step (to invite go to the channel and type ‘/invite #support’)
top

Slack App Installation

  1. Navigate to Setup>Slack Setup>Slack Setup
  2. Click the ‘Add to Slack’ button to add NetSuite Support Bot to your slack account
  3. Choose the account to add NetSuite Support Bot
  4. Click ‘Authorize’ to add the bot
  5. Then add user tokens for each employee that will be accessing NetSuite via Slack. Note, you required to have at least one user here that is marked default, all actions taken by NetSuite support bot will appear to come from this user in NetSuite.

    1. Add the Slack Token Access Role to your user roles by searching your name in the global search bar at the top of the page, clicking ‘edit’ and then adding the ‘Slack Token Access Role’ under the ‘Access’ subtab. Click ‘Save’ once it is added.
    2. Now change to that role to manage your tokens by hovering over your name in the top right and clicking on the new role. If the role doesn’t appear at first you made need to log out and log back in for it to appear.
    3. Once logged into the Slack Token Access Role find the ‘Settings’ portlet on the home dashboard on the left hand side. Click the ‘Manage Access Tokens’ link.
    4. On the My Access Tokens page click the ‘New My Access Token’ button.
    5. On the Access Token page select ‘Slack Support Bot’ from the drop down and click ‘Save.’
    6. Once saved you will see the generated Token ID and Token Secret. Copy these values into a text document. Log back into the administrator role by hovering over your name in the upper right corner and selecting the Administrator role. Navigate back to the Slack setup page at Setup>Slack Setup>Slack Setup. Under the ‘Add Employee Tokens’ sub list select your name as the employee and paste in the Token ID and Token Secret click ‘Add.’
    7. Before you click ‘Submit’ make sure to select a default channel to send new cases to underneath the ‘Add To Slack’ button. Then click the ‘Submit’ button to commit the changes.
top

Usage Instructions

You can message NetSuite Support Bot directly in a DM in slack or from within a channel that Support Bot has been invited into. When sending a message to Support Bot from within a channel you must direct the message to Support Bot by including @support before your message.

To get started message ‘help’ to Support Bot for a list of supported commands. In most cases you will specify the command, followed by a case number and in some cases an additional parameter. Separate each of these elements by a single space. When specifying a name to assign or escalate a case to you must specify the first and last name of the person (a space between the two is optional). Please note that the first and last name must match the first and last name of an employee in NetSuite who is marked as a support rep.

Many commands require you to specify a case # to interact with that specific case. It is often easiest to use one of the first three commands to list out cases before choosing one to interact with. When you list cases you will see the case number, subject, abbreviation for the support rep assigned to the case, the company that the case is associated with and a color that corresponds to the priority. When you list your own cases you will see the abbreviation for the case status instead of who it is assigned to. Some commands support interacting with multiple cases at once. These include the ‘grab,’ ‘escalate,’ ‘assign,’ ‘close,’ ‘increase priority,’ and the ‘decrease priority’ commands. Simply separate each case number with a space (i.e. close 123 456 789).

List of all available commands:

  1. help
  2. open cases
  3. unassigned cases
  4. my cases
  5. grab (case #)
  6. last message (case #)
  7. all messages (case #)
  8. all attachments (case #)
  9. escalate (case #) *escalatee*
  10. increase/decrease priority (case #)
  11. assign (case #) *assignee*
  12. reply (case #) *message*
  13. close (case #)
  14. about
Custom Messages
Workflow

Sending messages through the Workflow is simple. The workflow actions are available to all records in all execution contexts. Simply add the action to your state and Support Bot will do the rest.

  • Basic Message
    1. Add the Slack - Basic Message action to your Workflow State
    2. Select the channel to post to or type the username of the person you wish to message
    3. If you do not know the username and wish to send to an employee you can select an employee from the drop down and Support Bot will attempt to find that user in your Slack channel's userbase. Note that the first and last name in Slack must match the first and last name in NetSuite for this to work.
    4. Enter the text that you want to send in your message. This text supports all standard markup in Slack (i.e. *bold* or _italics_)
  • Attachment Message
    1. Add the Slack - Attachment Message action to your Workflow State
    2. Add the channel or user you are sending to as described in the basic message setup
    3. Add extra information into the subsequent fields to create a content rich message. All of the additional fields are optional so you only need to fill in information that you want to see in your message. For a comprehensive list of where each item will show and what type of information should be in each field read the documentation at Slack attachment messages.
    4. Attachment Message Formatting
SuiteScript
  1. Import the module into your script by including /.bundle/165111/modules/public_slack_module.js in the Array of the first argument of the define function
  2. Add slack as the corresponding parameter in your executing function
  3. Create a message to send to you Slack account. Messages must contain a channel property as well as either a text or an attachment property
  4. Usernames must start with an '@' symbole while channels must start with a '#'. You can optionally have have Support Bot attempt to lookup the user by passing an employee id to the channel property in the form of { employee_id: 3 }
  5. Pass your message to the .send() method of the slack object
  6. var message = {
        channel: { employee_id: 3 },
        text: 'Can you approve this order?'
    };
    slack.send(message);
  7. You can optionally pass an Array of messages to the .send() method to send multiple messages in one call. It is preferred that you group multiple messages in a single Array and pass them to the .send() method instead of calling .send() multiple times as it improves performance and ensures synchronous delivery of all of your messages
  8. Additional parameters can be put in the message object to add content to your message. For a full list of available perameters see slack documentation on building attachment messages. Note: Buttons are not currently supported with custom messages.

  9. Examples:

    Sending a simple message in a User Event script running After Submit on an Estimate record.
    /**
     * @NApiVersion 2.x
     * @NScriptType UserEventScript
     * @NModuleScope SameAccount
     * author: xxxxxx
     * Date: 4/29/17
     * Version: 1.0
     */
    
    define(['/.bundle/165111/modules/public_slack_module.js'],
    
        /**
         * @param {slack} slack
         */
        function (slack) {
    
            /**
             * Function definition to be triggered before record is loaded.
             * @param {Object} context
             * @param {Record} context.newRecord - New record
             * @param {Record} context.oldRecord - Old record
             * @param {string} context.type - Trigger type
             * @Since 2015.2
             */
            function afterSubmit(context) {
    
                var rec = context.newRecord;
                var quoteURL = 'https://system.netsuite.com/app/accounting/transactions/estimate.nl?id=' + rec.id;
                var quoteNum = rec.getValue({ fieldId: 'tranid' });
                var message = {
                    channel: "#support",
                    text: 'Can someone look at quote <' + quoteURL + '|Quote #' + quoteNum + '?>'
                };
    
                var response = slack.send(message);
                log.debug('Response', response);
            }
    
            return {
                afterSubmit: afterSubmit
            }
        }
    );
    Simple Quote Message
    Scheduled Script that searches all Sales Orders pending approval and then sends a message for each one to a user in Slack.
    /**
     * @NApiVersion 2.x
     * @NScriptType ScheduledScript
     * @NModuleScope SameAccount
     * author: xxxxxx
     * Date: 4/29/17
     * Version: 1.0
     */
    
    define(['N/search', '/.bundle/165111/modules/public_slack_module.js'],
    
        /**
         * @param {search} search
         * @param {slack} slack
         */
        function (search, slack) {
    
            /**
             * Definition of the Scheduled script trigger point.
             * @param {Object} context
             * @param {string} context.type - The context in which the script is executed. It is one of the values from the context.InvocationType enum.
             * @Since 2015.2
             */
            function execute(context) {
    
                var slackMessages = [];
                var columns = [{name: 'salesrep'}];
                var filters = [{name: 'orderstatus', operator: 'anyof', values: ['Pending Approval']}];
    
                search.create({type: search.Type.SALES_ORDER, columns: columns, filters: filters})
                    .run().each(function (result) {
                        var employeeId = result.getValue({ name: 'salesrep' });
                        var soURL = 'https://system.netsuite.com/app/accounting/transactions/salesord.nl?id=' + result.id;
                        slackMessages.push({
                            channel: { employee_id: employeeId },
                            text: 'Can you approve this Sales Order? <' + soURL + '|Sales Order #' + result.id + '>'
                        });
                        return true;
                    });
                var slackResponse = slack.send(slackMessages);
                log.debug('Response from Slack', slackResponse);
            }
    
            return {
                execute: execute
            }
        }
    );
    Simple Quote Message

    Send a complex attachment style message After Submit on a User Event script.

    /**
     * @NApiVersion 2.x
     * @NScriptType UserEventScript
     * @NModuleScope SameAccount
     * author: xxxxxx
     * Date: 4/29/17
     * Version: 1.0
     */
    
    define(['/.bundle/165111/modules/public_slack_module.js'],
    
        /**
         * @param {slack} slack
         */
        function (slack) {
    
            /**
             * Function definition to be triggered before record is loaded.
             * @param {Object} context
             * @param {Record} context.newRecord - New record
             * @param {Record} context.oldRecord - Old record
             * @param {string} context.type - Trigger type
             * @Since 2015.2
             */
            function afterSubmit(context) {
                slack.send({
                    channel: #support,
                    attachments: [
                        {
                            fallback: 'New case has been submitted.',
                            color: '#36a64f',
                            pretext: 'here is some general information about the case.',
                            author_name: 'Bobby Tables',
                            author_link: 'https://system.netsuite.com/app/common/entity/employee.nl?id=7415&',
                            author_icon: 'http://pix.iemoji.com/images/emoji/apple/ios-9/256/dog-face.png',
                            title: 'Fixing computer problems',
                            title_link: 'https://system.netsuite.com/app/crm/support/supportcase.nl?id=167205',
                            text: 'This is some more detailed information about the case.',
                            fields: [
                                {
                                    title: 'Priority',
                                    value: 'High',
                                    short: false
                                }
                            ],
                            image_url: 'http://nssupportbot.com/images/instructions/dog-image.jpg',
                            footer: 'Slack API',
                            footer_icon: 'https://platform.slack-edge.com/img/default_application_icon.png',
                            ts: 123456789
                        }
                    ]
                })
            }
    
            return {
                afterSubmit: afterSubmit
            }
        }
    );
    Simple Quote Message
top
Change Bot Name
  1. Log into your slack account on the slack.com website and navigate to the home dashboard
  2. Click on configure apps
  3. Click on NS Support Bot
  4. Scroll to the bottom and click the pencil to edit next to the bot name
  5. Change the name to whatever you like and click Save Changes

Updating the App

To update the Slack Support Bot bundle follow these steps:

  1. Navigate to Customization>SuiteBundler>Search & Install Bundles>List
  2. If there is an update available you will see a blue ‘!’ underneath the version number of the Slack Support Bot
  3. Hover over the green action item on the left hand side of the Slack Support Bot bundle
  4. Click the ‘Update’ link
  5. What for the update to finish
top

Uninstalling The App

To uninstall the Slack Support Bot follow these steps:

  1. Navigate to Customization>SuiteBundler>Search & Install Bundles>List
  2. Hover over the green action item on the left hand side of the Slack Support Bot bundle
  3. Click the ‘Uninstall’ link
  4. What for the uninstallation link

Once the uninstallation is complete the Support Bot will disconnect from your Slack account and all bundle elements will be removed from your NetSuite account. Follow the installation instructions above if you wish to reinstall the Slack Support Bot bundle.

top