Stammer.ai Docs
  • Welcome
    • 👋Welcome to Stammer.ai
    • 📑About Stammer.ai
    • 🆕New/ Latest Updates
  • START HERE
    • ❓What is Stammer.ai?
    • 🫡Agency Quick Start Guide
    • 📚Glossary
    • 🤑Our Community
  • AI Features
    • 🤖AI Agents (Chatbots)
      • How AI Agents Work
      • How to Build an AI Agent
    • 🔃AI Agent Dashboard
      • (White Label) Marketplace
      • Default Chatbot
      • Share Chatbot
      • Clone Chatbot
      • Chatbot UUID
      • Delete Chatbot
      • Summary (Analytics)
    • 💬Conversations
      • Review Past Conversations
      • Conversation Links
      • Training Better Responses
      • Live Chat
        • Human Handoff Automation (for Live Chat)
    • 📚Knowledge Base Explained
      • 💽Data Storage (Characters)
        • Storage (Characters) Example
      • Copy & Paste Text
      • Upload Documents
      • Scrape Websites
        • 24-hour Auto-Scraping
        • Scraping a Google Doc
        • Google Docs
      • Question & Answer Pairs
      • Data & Content Security
      • Citations/ Sources
      • HTML Rendering (Embed Images & Videos)
    • ✍️Prompting
      • What is a Base System Prompt?
      • Writing a Base System Prompt
      • Prompt Examples (Marketplace)
        • Base System Prompt Template (General)
    • 🔧AI Agent Settings
    • 🎨AI Chat Widget
      • Customize Chat Widget Apperance
      • Chat Widget Pop-Up
      • Initial Messages Pop-Up
      • Chat Widget Voice
    • ⚙️Advanced Settings for AI Agent
      • Model Version
      • Prioritize Question/Answer Results
      • Chatbot Visibility
      • Temperature
      • Message Template
      • Support Email
      • Domains
      • Show Data Sources in Chat Widget
      • Debug Mode
    • Leads 2.0
    • 📈Leads (Legacy)
      • Overview of Lead Generation
      • Lead Collection Form Fields
      • Lead Collection Webhook URL
      • Lead Collection Email Notification
      • In Chat Lead Collection Base System Prompt
      • Sending Lead Data to Zapier
      • Sending Lead Data to GHL
      • Sending Lead Data to Zoho CRM
    • 📅Scheduling
      • AI Scheduling - Simplified
      • AI Scheduling - Experimental (Beta)
        • What is Scheduling?
        • Calendar Integration
          • Google Calendar
        • Appointment Scheduling Activation
        • Appointment Scheduling Webhook URL
        • Appointment Scheduling Email Notification
        • Appointment Scheduling Base System Prompt
        • The Appointment Scheduling Functions & Customizing the Appointment Scheduling Prompt
    • 🧊Integrations
      • Embed Chatbot on a Website
      • Zapier App
      • GoHighLevel (GHL)
      • Instagram DM
      • Facebook Messenger
      • WhatsApp
      • ElevenLabs Voice
      • Discord
    • 🤖Troubleshooting
      • How to Respond in Any Language
      • Responses are Too Long
      • Debug Mode
      • Clickable Links in Responses
    • 🌌Functions (Labs)
      • Custom Functions
        • How Custom Functions Work
        • Code Generation Prompt for Custom Functions
        • Stock Market Data - Custom Function
        • Shopify - Custom Function
        • Airtable - Custom Function
        • Google Sheets - Custom Function
    • 🔄Vault
      • OpenAI API Key (ChatGPT)
      • Anthropic API Key (Claude)
      • xAI API Key (Grok)
      • Eleven Labs API Key
  • 👑MasterChat
  • White Label
    • 🤑What is White Labeling?
    • 👤Client Sub-Accounts
      • Create Sub-Account
      • Sub-Account Wallet
      • Sub-Account Storage Balance
      • Sub-Account Extra AI Agents
      • How to clone a chatbot to a sub-account
    • 🔗Custom Domain
      • Troubleshooting Custom Domain Deployment DNS Issues
    • 🏗️The SaaS Configurator
      • Create Subscription Package
        • Custom Packages + Settings
      • Add-Ons
        • Storage (Characters) - Add Ons
        • AI Agent Rebilling - Add Ons
        • MasterChat - Add Ons
        • Advanced Scraper - Add Ons
    • 👍White Label API
      • API Documentation
      • AI Agent API
        • Message AI Agent
        • Create AI Agent
        • Retrieve AI Agent
        • Update AI Agent
        • Delete AI Agent
      • Knowledge Base API
        • Add AI Agent Q/A
        • Add URLs to Scrape
        • Add Files (Pdf, Doc etc.)
      • Conversations
        • AI Agent Conversations
        • Retrieve Conversation
        • Delete A Conversation
      • Sub-Accounts
        • Create Sub-Account
        • Retrieve Sub-Account
        • Update Sub-Account
        • Delete Sub-Account
      • User
        • Retrieve User's Data
      • Examples
        • Create New Sub-Account (Zapier Example)
        • White Label API x Zapier X Slack Example
        • AI Chatbot Chrome Extension
    • 👾White Label (Your) Marketplace
    • 😇White Label Free Trials
      • Free Trial Settings (No CC Req.)
      • Free Trial Settings (CC Req.)
    • 🎨Custom Dashboard Styling
  • Agency Settings
    • ⛳Agency Dashboard
    • 👥User Permissions
    • 😎Agency Profile
    • 👥User Access
    • 💳Connect Stripe
    • 🔗Custom Menu Links
    • 🤘Default Prompts
  • Account Management
    • ⚙️Billing Usage & Settings
    • 💲Agency Billing
      • Subscription Plans
      • Change Subscription Plan
      • Update Credit Card
      • Download Invoice
      • Refunds
      • Cancel Subscription
    • 💱Agency Wallet
      • The Agency Wallet System
      • Agency vs Sub-Account Wallet
      • Auto Billing
      • Add Funds to Wallet
      • AI Messages Costs
      • AI Agents Costs
      • Storage (Characters) Costs
    • 🤲Admin Account Profile
      • Change Password
      • Google Auth Login
  • Support
    • 🤝Need Help?
    • 🔓Security & Compliance
      • Data Privacy & Security Report
      • GDPR
      • Terms & Conditions
      • Privacy Policy
      • Data Processing Agreement
      • AI Model Data Usage
      • Service Level Agreement
    • ⚡Discord Community
    • 📹Weekly Office Hours
    • 🙌FAQ
      • General
      • Localization
      • Data/Security
      • Set Up
      • Password
      • Technical Questions
      • Sales/Onboarding
      • Marketing/Pricing
      • Where can I find...?
      • Other
      • Alternatives to Stripe Connect
    • 📰Changelog/ Roadmap
    • 🍭Resources
      • Sales Deck
      • 💰AI Agency 101
        • How to Price Your AI Chatbots
        • How to Get More Clients
        • The Value Proposition of AI Agents
        • AI SaaS Funnel Explained
    • 🤑Affiliate Program
Powered by GitBook
On this page
  1. White Label
  2. White Label API
  3. Examples

AI Chatbot Chrome Extension

Creating a Chrome Extension to Communicate with Stammer's AI Chatbot API using Replit

PreviousWhite Label API x Zapier X Slack ExampleNextWhite Label (Your) Marketplace

Last updated 6 months ago

Setting Up the Project on Replit

  1. Create a New Replit Project

    • Go to and log in.

    • Click Create Repl.

    • Choose HTML, CSS, JS as the template, name your project, and click Create Repl.

  2. Organize Your Project Files

    • Inside Replit, create three main files:

      • manifest.json: Defines the extension’s properties.

      • popup.html: Builds the user interface for the extension.

      • popup.js: Manages the communication with the Stammer chatbot API.

  3. Building the Files

    1. Let’s go through each of these files and set up the code.

Step 1: Create manifest.json

In Replit, create a file named manifest.json. This file will define the Chrome extension’s settings and permissions.

{
  "manifest_version": 3,
  "name": "Stammer Chatbot",
  "version": "1.0",
  "description": "Send a message to the Stammer AI chatbot and get a response.",
  "action": {
    "default_popup": "popup.html",
    "default_icon": {
      "16": "icon16.png",
      "48": "icon48.png",
      "128": "icon128.png"
    }
  },
  "permissions": [
    "storage",
    "activeTab",
    "scripting"
  ]
}

This configuration sets up:

  • The extension’s version and description

  • Points to popup.html as the popup interface

  • Defines required permissions like storage and access to the active tab

Step 2: Build the User Interface in popup.html

Create a file named popup.html in Replit. This file provides the UI for the extension’s popup window. It contains a text area where the user can type their message, a button to send the message, and a display area for the chatbot’s response.

<!DOCTYPE html>
<html>
  <head>
    <title>Chat with Stammer</title>
    <style>
      body {
        font-family: Arial, sans-serif;
        padding: 10px;
        width: 300px;
      }
      textarea {
        width: 100%;
        height: 80px;
        margin-bottom: 10px;
      }
      button {
        width: 100%;
        padding: 10px;
        background-color: #4CAF50;
        color: white;
        border: none;
        cursor: pointer;
      }
      button:hover {
        background-color: #45a049;
      }
      #response {
        margin-top: 10px;
        font-size: 14px;
        color: #333;
      }
    </style>
  </head>
  <body>
    <h3>Send a Message to Stammer</h3>
    <textarea id="message" placeholder="Type your message here..."></textarea>
    <button id="sendMessage">Send Message</button>
    <div id="response"></div>

    <script src="popup.js"></script>
  </body>
</html>

Step 3: Writing the JavaScript Logic in popup.js

Create a file named popup.js in Replit. This script sends the user’s message to the Stammer API and displays the chatbot’s response.

document.getElementById('sendMessage').addEventListener('click', async () => {
  const message = document.getElementById('message').value;
  const responseDiv = document.getElementById('response');
  
  if (!message) {
    responseDiv.textContent = "Please type a message.";
    return;
  }

  responseDiv.textContent = "Sending...";

  const data = {
    chatbot_uuid: "12345678-1234-5678-1234-567812345678",  // Replace with actual chatbot UUID
    query: message,
    user_key: "user-unique-key"  // Replace with actual user key
  };

  try {
    const response = await fetch("https://app.stammer.ai/en/chatbot/api/v1/message/", {
      method: 'POST',
      headers: {
        'Authorization': 'Token <YOUR-API-TOKEN>',  // Replace with actual API token
        'Content-Type': 'application/json'
      },
      body: JSON.stringify(data)
    });

    if (response.ok) {
      const result = await response.json();
      responseDiv.textContent = result.data.answer;
    } else {
      const errorData = await response.json();
      responseDiv.textContent = `Error: ${errorData.message}`;
    }
  } catch (error) {
    responseDiv.textContent = `Error: ${error.message}`;
  }
});

This script:

  • Waits for the user to click the button

  • Sends the input message to the Stammer API

  • Displays the chatbot’s response or an error message if something goes wrong

Step 4: Testing Locally in Chrome

Since Chrome extensions can’t be run directly in Replit, you’ll need to download your files and test them in Chrome.

  1. Download the Project:

    • In Replit, go to the top menu, click on the three dots next to your project name, and select Download as ZIP.

    • Extract the ZIP file to a folder on your computer.

  2. Load the Extension in Chrome:

    • Open Chrome and go to chrome://extensions/.

    • Enable Developer mode by toggling the switch on the top right.

    • Click Load unpacked and select the folder where you extracted your extension files.

    • You should see your extension appear in the toolbar.

Using the Extension

Once your extension is loaded:

  1. Click the extension icon in your Chrome toolbar.

  2. A popup window will open with a text box to type a message.

  3. Click Send Message to interact with the chatbot. The response will appear below the text area.

Optional: Adding Icons

If you want to make the extension look nicer, you can add icons in different sizes:

  • icon16.png (16x16 pixels)

  • icon48.png (48x48 pixels)

  • icon128.png (128x128 pixels)

These icons will show up in the Chrome toolbar and extension settings.

Sharing the Project on Replit

If you want to share your extension code with others, you can make your Replit project public or invite collaborators directly. This way, team members can easily review or contribute to the code from their own accounts.

👍
Replit