Custom Actions Quick Start Guide

 
List view
Understanding Nobi
Getting Started
Implement Nobi On Your Site
Answer Customer Questions With Your Knowledge Base
Control How Nobi Shows Products With Merchandising
Analyze Your Data
Add Your Own Custom Actions To Nobi
Control How Nobi Responds With Override Rules
Beta Products
Developers Guide
References

Custom Actions Quick Start Guide


This guide walks you through creating your first Custom Action in under 5 minutes. You'll build a simple promo code tool that gives customers discount codes through conversation—no backend required, no API needed.

What You'll Build

A promo code Custom Action that:
  • Activates when customers ask about discounts or deals
  • Copies a promo code to their clipboard automatically
  • Tells them the code and what discount they get
  • Works entirely in the browser (no server needed)
User experience:
  • User: "Do you have any promo codes?"
  • Nobi: "Yes! I've copied the code SAVE20 to your clipboard. It gives you 20% off your order. Just paste it at checkout!"
  • [Code is copied to clipboard, ready to paste]

Prerequisites

Before you begin:
Nobi is installed - Your website has the Nobi widget installed and working
You can edit your website - Access to add a small script to your site (or use Google Tag Manager)
That's it! No coding experience required—just copy and paste the code below.

Step 1: Copy This Code To Create A New Coupon

Copy and paste this entire block of code. This adds a new “get promo code” action that fires when your customers ask about discounts. We'll add it to your website in Step 2.
Complete working example:
window.NobiTools = [ { name: "getPromoCode", description: "Give the customer a promotional discount code when they ask about discounts, deals, promo codes, coupons, or sales", parameters: { type: "object", properties: {}, required: [] }, handler: async function(args) { try { // Your promo code (change this to your actual code) const promoCode = "SAVE20"; const discountAmount = "20% off"; // Copy code to clipboard so customer can paste it await navigator.clipboard.writeText(promoCode); // Return success message return { success: true, code: promoCode, discount: discountAmount, message: `I've copied the code ${promoCode} to your clipboard! It gives you ${discountAmount} your entire order. Just paste it at checkout.` }; } catch (error) { // If clipboard doesn't work, still provide the code return { success: true, code: "SAVE20", discount: "20% off", message: "Use code SAVE20 at checkout for 20% off your order!" }; } } } ];
Customize it for your business:
Change these values to match your actual promo code:
  • "SAVE20" → Your promo code
  • "20% off" → Your discount amount
  • Update the description if your code has specific rules
Examples:
const promoCode = "FREESHIP"; const discountAmount = "free shipping"; const promoCode = "WELCOME10"; const discountAmount = "$10 off orders over $50"; const promoCode = "FLASH25"; const discountAmount = "25% off sale items";

Step 2: Add Code to Your Website

Add the code from Step 1 to your website. Here are three easy ways to do it:

Option 1: Add to Your Website's HTML (Easiest)

If you can edit your website's HTML, add this right before the closing </head> tag:
<!DOCTYPE html> <html> <head> <title>Your Website</title> <!-- ADD THIS: Custom Actions code --> <script> window.NobiTools = [ { name: "getPromoCode", description: "Give the customer a promotional discount code when they ask about discounts, deals, promo codes, coupons, or sales", parameters: { type: "object", properties: {}, required: [] }, handler: async function(args) { const promoCode = "SAVE20"; const discountAmount = "20% off"; await navigator.clipboard.writeText(promoCode); return { success: true, message: `I've copied the code ${promoCode} to your clipboard! It gives you ${discountAmount} your entire order. Just paste it at checkout.` }; } } ]; </script> <!-- END Custom Actions code --> <!-- Your existing Nobi widget script should be here --> <script src="<https://cdn.nobi.ai/widget.js>"></script> </head> <body> <!-- Your page content --> </body> </html>

Option 2: Use Google Tag Manager (No Code Access Needed)

If you use Google Tag Manager:
  1. Log into Google Tag Manager
  1. Click "Tags" → "New"
  1. Name it "Nobi Custom Actions"
  1. Click "Tag Configuration" → Choose "Custom HTML"
  1. Paste the code from Step 1 (wrapped in <script> tags):
<script> window.NobiTools = [ { name: "getPromoCode", // ... paste the rest of the code here } ]; </script>
  1. Click "Triggering" → Choose "All Pages"
  1. Click "Save"
  1. Click "Submit" to publish
Important: Make sure this tag fires before your Nobi widget tag.

Option 3: Shopify (For Shopify Stores)

If you're on Shopify:
  1. Go to Online Store → Themes
  1. Click "Actions" → "Edit code"
  1. Find theme.liquid in the left sidebar
  1. Look for the </head> closing tag
  1. Paste the code from Step 1 right above </head>
  1. Click "Save"

Step 3: Understanding the Code

Let's break down what each part does. Don't worry—you don't need to understand all of this to use it, but it helps!

Tool Definition

{ name: "getPromoCode", description: "Give the customer a promotional discount code when they ask about discounts, deals, promo codes, coupons, or sales", // ... }
name: The identifier for this action. This must be unique and use camelCase (no spaces).
description: This is how Nobi's AI knows when to use this tool. The description says: "Give the customer a discount code when they ask about discounts, deals, promo codes, coupons, or sales."
So when a customer says things like:
  • "Do you have any promo codes?"
  • "Are there any deals right now?"
  • "Got any coupons?"
  • "Any discounts available?"
Nobi will recognize these match the description and run your tool!

Parameters

parameters: { type: "object", properties: {}, required: [] }
parameters: What information the tool needs to work. In our case, we don't need any information from the customer—we're just giving them a code! So properties is empty and nothing is required.
If you wanted to ask the customer something first (like "What's your email?"), you'd add it here. But for a simple promo code giveaway, we don't need anything.

Handler Function (The Action Part)

handler: async function(args) { // Your promo code const promoCode = "SAVE20"; const discountAmount = "20% off"; // Copy code to clipboard await navigator.clipboard.writeText(promoCode); // Tell Nobi what to say return { success: true, message: `I've copied the code ${promoCode} to your clipboard! It gives you ${discountAmount} your entire order.` }; }
handler: This is what actually happens when the tool runs.
Here's what it does step by step:
  1. Sets your promo code - const promoCode = "SAVE20"
  1. Copies it to clipboard - navigator.clipboard.writeText(promoCode) (so customer can paste it)
  1. Returns a message - Tells Nobi what to say to the customer
The return object has:
  • success: true - Tells Nobi everything worked
  • message - What Nobi should tell the customer
That's it! Pretty simple, right?

Step 4: Test It Out!

Time to see your Custom Action in action!

Quick Check: Is It Registered?

  1. Open your website in a browser
  1. Open the browser console (Press F12, or right-click → "Inspect" → "Console" tab)
  1. Type: window.NobiTools
  1. Press Enter
You should see something like [{name: "getPromoCode", ...}]
If you see undefined:
  • The code isn't loading yet - did you refresh the page?
  • Check if there are any red errors in the console
  • Make sure the code is added before the Nobi widget script

Test with Nobi

Open the Nobi chat widget and try these phrases:
Test 1: Direct question
  • Type: "Do you have any promo codes?"
  • Expected: Nobi immediately tells you the code and says it's been copied to your clipboard
Test 2: Different phrasing
  • "Got any discounts?"
  • "Are there any deals?"
  • "Do you offer coupons?"
  • All should trigger the promo code tool!
Test 3: Natural conversation
  • "I'm interested in this product but it's a bit pricey"
  • "Are there any sales going on?"
  • Should recognize you're asking about discounts

Verify It Works

After Nobi responds:
Clipboard test: Open a text editor or note app and press Cmd+V (Mac) or Ctrl+V (Windows). The promo code should paste!
Message check: Nobi's response should say something like "I've copied the code SAVE20 to your clipboard! It gives you 20% off your entire order."
Try it at checkout: Go to your checkout page and paste the code to make sure it actually works in your store

What Success Looks Like

You'll know it's working when:
  1. Customer asks about discounts/promos/deals
  1. Nobi responds immediately (no form needed!)
  1. Code is copied to clipboard automatically
  1. Nobi tells customer what the code is and what discount they get
  1. Customer can paste the code at checkout
The whole interaction takes 2 seconds!
Congratulations! You've successfully created your first Custom Action. You've turned Nobi into an automation tool that gives customers promo codes instantly—and it only took a few minutes.
What's next?
  • Try the dynamic code examples above to make your promo rotate
  • Build more simple actions (store hours, shipping info, page navigation)