Set Up Scripts

With script integrations, you can create custom bot actions to use in bot responses in stories, rules, and fallback. Creating custom actions requires writing code in JavaScript. Because Bot Builder scripts operate on the server, there are some limitations to consider while building your scripts.

Create a Script Integration

Required permissionChatbot (ACD > DFO > Roles > [choose one] > Core Modules)

A script integration holds one or more custom bot actions. Each bot action has its own script.

  1. In CXone, click the app selector and select Bot Builder.

  2. Click the bot you want to work with.
  3. Click Integrations icon, which looks like a plug. in the left icon menu.
  4. Click the Scripts tab, then click New Integration.
  5. Click the title to rename the integration.
  6. Create script variables to use in this integration, if any are needed.
  7. Add one or more custom bot actions to the integration. This is where you create your scripts. They can reference script variables, if needed.
  8. When you're finished making changes, click Train and Stage to update your bot modelClosed Version of a bot that has been trained and staged.

Create a Custom Bot Action

Required permissionChatbot (ACD > DFO > Roles > [choose one] > Core Modules)

Custom bot actions can be added to bot responses in stories, rules, and fallback.

  1. In CXone, click the app selector and select Bot Builder.

  2. Click the bot you want to work with.
  3. Click Integrations icon, which looks like a plug. in the left icon menu.
  4. On the Scripts tab, click the script integration you want to work with.
  5. Under Actions, click New Action.
  6. Enter a name for the action and press Enter.
  7. Click the new action to expand its properties.
  8. Click Open Editor to code your custom JavaScript:
    1. In the editor, replace the default Hello World code, but keep all new code within the main function. You can structure other functions within main if needed. Code outside of main will not be executed.
    2. Include script variables in your code as needed. Create the variables, if you haven't already done so.
    3. Click the execute script triangle A triangle arrow pointing to the right. in the toolbar at the top of the editor to see the output results of the script. The results appear in the Console pane on the right side of the editor.
  9. Click the open angle bracket An open angle bracket <. in the top left corner of the editor to return to the script integration page where the lists of actions and variables are.
  10. Click the action you're working with.
  11. In the Editable Variables drop-down, select any script variables that you referenced in your code.
  12. Enable your action when it's ready to test in a storyClosed Used to train bot for interaction handling based on intent and context, ruleClosed Used to define bot's response to messages that don't change with context., or fallbackClosed These sites are for the development and support of CXone, not its operation. Blocking these may interfere with access to help and download links within the platform...
  13. Add your action to a story, rule, or fallback.
  14. When you're finished making changes, click Train and Stage to update your bot modelClosed Version of a bot that has been trained and staged.

Create Script Variables

Required permissionChatbot (ACD > DFO > Roles > [choose one] > Core Modules)

The variables you create can only be used in the script integration where you create them. They cannot be used in other script integrations, even in the same bot.

  1. In CXone, click the app selector and select Bot Builder.

  2. Click the bot you want to work with.
  3. Click Integrations icon, which looks like a plug. in the left icon menu.
  4. On the Scripts tab, click the script integration you want to work with.
  5. Under Variables, click New Action.
  6. Enter a name and press Enter.
  7. Click the variable in the list to expand its properties.
  8. To create a single-value variable that can be made editable in a bot action: 
    1. Click Text or Number.
    2. Enter the Default Value for this variable. If you don't want the variable to have a default value, leave this field empty. You can update the variable value when it's used in a bot action.
    3. For number variables only, enter a Min Value and a Max Value to provider upper and lower limits on the values the variable can hold.
  9. To create a read-only, single-value variable:
    1. Click Secret.
    2. Enter the Value. Bot Builder masks all but the first five characters of the value you enter. The value is fully visible if you view the contents of a variable in the console.
  10. To create a list of possible values for this variable:
    1. Click Select.
    2. Enter the possible variable Values separated with a comma ( , ). For example, red,blue,green.
    3. Click Default Value and select the value you want to be the default.
    4. To remove the default value, hover the cursor over the field and click X.
  11. Use your variable in a custom bot action script.
  12. When you're finished making changes, click Train and Stage to update your bot modelClosed Version of a bot that has been trained and staged.

Make Variables Editable

Required permissionChatbot (ACD > DFO > Roles > [choose one] > Core Modules)

You can make a variable editable in a custom bot action if you want to be able to specify or select a value for that variable when you use that action in a bot response. If you use a variable in more than one action in a script integration, you must make it editable in each action. Additionally, the variable must be referenced in a script before you can make it editable in that script.

  1. In CXone, click the app selector and select Bot Builder.

  2. Click the bot you want to work with.
  3. Click Integrations icon, which looks like a plug. in the left icon menu.
  4. On the Scripts tab, click the script integration you want to work with.
  5. Under Actions, click an action on the script integration page to expand its properties.
  6. Select one or more variables in the Editable Variables drop-down. Secret variables do not appear in this list. They cannot be made editable. Changes are saved automatically.
  7. Specify the value of the variable when you use the selected custom action in a story, rule, or fallback.
  8. When you're finished making changes, click Train and Stage to update your bot modelClosed Version of a bot that has been trained and staged.

Enable a Bot Action

When a bot action is ready to be used in a bot response, you must enable it. Actions that aren't enabled won't show up in the bot actions list when you're working in a story, rule, or fallback.

  1. In CXone, click the app selector and select Bot Builder.

  2. Click the bot you want to work with.
  3. Click Integrations icon, which looks like a plug. in the left icon menu.
  4. On the Scripts tab, click the script integration you want to work with.
  5. Under Actions, click an action on the script integration page to expand its properties.
  6. Click Disabled Icon of a toggle switch. to enable the action. Click it again to disable the action and remove it from the bot action list.