Showing posts with label chatbots. Show all posts
Showing posts with label chatbots. Show all posts

Thursday, September 25, 2025

23 Practical Examples of Chatbot Tools for Multiple Niches using RapidTextAI

 


RapidTextAI – AI Article Generation, AI Articles Writer GPT4, Gemini, Deepseek and Grok

RapidTextAI Blocks is an advanced AI-powered content generation plugin for WordPress. It integrates seamlessly with Gutenberg, WP Bakery, and Elementor, allowing you to instantly generate high-quality, AI-driven content right from your favorite page builder. Perfect for bloggers, marketers, and content creators looking to automate and speed up their content creation process. Use this plugin to create chatbots, below are the examples of tools that can be implemented with this plugin.

🌦️ 1. Weather Information (General Utility)

You already started this with WeatherAPI.com. Let’s make it precise:

  • Tool Name: get_weather
  • Description: Get current weather information for a city
  • API URL:

    http://api.weatherapi.com/v1/current.json
    
  • Method: GET
  • Headers:

    [
      {"key": "Content-Type", "value": "application/json"}
    ]
    
  • Parameters (JSON Schema):

    {
      "type": "object",
      "properties": {
        "q": {
          "type": "string",
          "description": "City name, state code and country code"
        },
        "key": {
          "type": "string",
          "description": "Your WeatherAPI API Key"
        }
      },
      "required": ["q", "key"]
    }
    
  • Response Field: current.condition.text

 Example chat:

User: “What’s the weather in Lahore right now?” Bot → API → “It’s currently Sunny in Lahore.”


🍽️ 2. Restaurant Search (Food/Niche)

Use Yelp Fusion API (free API key from Yelp).

  • Tool Name: find_restaurants
  • Description: Find top restaurants in a given city
  • API URL:

    https://api.yelp.com/v3/businesses/search
    
  • Method: GET
  • Headers:

    [
      {"key": "Authorization", "value": "Bearer YOUR_YELP_API_KEY"}
    ]
    
  • Parameters:

    {
      "type": "object",
      "properties": {
        "term": {
          "type": "string",
          "description": "Search term, e.g. 'pizza' or 'coffee'"
        },
        "location": {
          "type": "string",
          "description": "City or area name"
        },
        "limit": {
          "type": "integer",
          "description": "Number of results to return (max 10)"
        }
      },
      "required": ["term", "location"]
    }
    
  • Response Field: businesses[0].name

 Example chat:

User: “Find me the best sushi in New York.” Bot → Yelp API → “Top suggestion: Sushi Nakazawa.”


✈️ 3. Flight Information (Travel Niche)

Use AviationStack API (free plan).

  • Tool Name: get_flight_status
  • Description: Get flight status info
  • API URL:

    http://api.aviationstack.com/v1/flights
    
  • Method: GET
  • Parameters:

    {
      "type": "object",
      "properties": {
        "access_key": {
          "type": "string",
          "description": "Your AviationStack API key"
        },
        "flight_iata": {
          "type": "string",
          "description": "IATA code of the flight, e.g. 'EK215'"
        }
      },
      "required": ["access_key", "flight_iata"]
    }
    
  • Response Field: data[0].flight_status

 Example chat:

User: “What’s the status of Emirates EK215?” Bot → API → “The flight is currently En-Route.”


💰 4. Crypto Prices (Finance Niche)

Use CoinGecko API (free, no key).

  • Tool Name: crypto_price
  • Description: Get real-time cryptocurrency prices
  • API URL:

    https://api.coingecko.com/api/v3/simple/price
    
  • Method: GET
  • Parameters:

    {
      "type": "object",
      "properties": {
        "ids": {
          "type": "string",
          "description": "Crypto ID (e.g. bitcoin, ethereum)"
        },
        "vs_currencies": {
          "type": "string",
          "description": "Currency to compare against (e.g. usd)"
        }
      },
      "required": ["ids", "vs_currencies"]
    }
    
  • Response Field: bitcoin.usd (or <id>.<currency>)

 Example chat:

User: “What’s the current price of Bitcoin in USD?” Bot → API → “Bitcoin is trading at $67,450.”


📅 5. Calendar Bookings (Productivity Niche)

Use Google Calendar API or a simpler Cal.com API. Example:

  • Tool Name: book_meeting
  • Description: Schedule a meeting using Cal.com
  • API URL:

    https://api.cal.com/v1/bookings
    
  • Method: POST
  • Headers:

    [
      {"key": "Authorization", "value": "Bearer YOUR_CAL_API_KEY"},
      {"key": "Content-Type", "value": "application/json"}
    ]
    
  • Parameters:

    {
      "type": "object",
      "properties": {
        "name": { "type": "string", "description": "Name of the person" },
        "email": { "type": "string", "description": "Email address" },
        "date": { "type": "string", "description": "Date (YYYY-MM-DD)" },
        "time": { "type": "string", "description": "Time (HH:MM)" }
      },
      "required": ["name", "email", "date", "time"]
    }
    
  • Response Field: confirmation.id

 Example chat:

User: “Book a meeting for tomorrow at 3 PM with John.” Bot → API → “Meeting booked! Confirmation ID: 82XZ1.”


🛒 6. Product Search (E-commerce Niche)

Use Fake Store API (open-source demo API).

  • Tool Name: search_products
  • Description: Search products from store API
  • API URL:

    https://fakestoreapi.com/products
    
  • Method: GET
  • Response Field: 0.title

 Example chat:

User: “Show me some electronics.” Bot → API → “One option is ‘SanDisk 32GB Flash Drive’.”


📰 7. News Headlines (Media Niche)

Use NewsAPI.org.

  • Tool Name: get_news
  • Description: Get latest headlines
  • API URL:

    https://newsapi.org/v2/top-headlines
    
  • Method: GET
  • Headers:

    [
      {"key": "Authorization", "value": "Bearer YOUR_NEWSAPI_KEY"}
    ]
    
  • Parameters:

    {
      "type": "object",
      "properties": {
        "country": { "type": "string", "description": "Country code, e.g. 'us'" },
        "category": { "type": "string", "description": "Category like business, sports" }
      },
      "required": ["country"]
    }
    
  • Response Field: articles[0].title

 Example chat:

User: “Give me the latest sports news from the US.” Bot → API → “Headline: ‘Lakers secure playoff spot with last-minute win.’”

8) Currency Conversion (finance)

  • Tool Name: convert_currency
  • Description: Convert an amount from one currency to another
  • API URL: https://api.exchangerate.host/convert (no key required)
  • Method: GET
  • Headers: []
  • Parameters (JSON):
{
  "type":"object",
  "properties":{
    "from":{"type":"string","description":"ISO code e.g. USD"},
    "to":{"type":"string","description":"ISO code e.g. PKR"},
    "amount":{"type":"number","description":"Amount to convert"}
  },
  "required":["from","to","amount"]
}
  • Response Field: result Example chat: “Convert 129 USD to PKR.”

9) Stock Prices (markets)

  • Tool Name: stock_quote
  • Description: Get latest stock price for a symbol
  • API URL: https://www.alphavantage.co/query
  • Method: GET
  • Headers: []
  • Parameters (JSON):
{
  "type":"object",
  "properties":{
    "function":{"type":"string","enum":["GLOBAL_QUOTE"],"description":"Use GLOBAL_QUOTE"},
    "symbol":{"type":"string","description":"Ticker e.g. AAPL"},
    "apikey":{"type":"string","description":"Alpha Vantage API key"}
  },
  "required":["function","symbol","apikey"]
}
  • Response Field: Global Quote.05. price Example chat: “What’s AAPL trading at right now?”

10) IP Geolocation (utilities/personalization)

  • Tool Name: ip_lookup
  • Description: Get location info for an IP address
  • API URL: https://ipapi.co/{ip}/json/ (put {ip} in URL at call-time)
  • Method: GET
  • Headers: []
  • Parameters (JSON):
{
  "type":"object",
  "properties":{
    "ip":{"type":"string","description":"IP v4/v6 address"}
  },
  "required":["ip"]
}
  • Response Field: city Example chat: “Where is 8.8.8.8 located?”

11) Time Zone / Current Time (productivity)

  • Tool Name: current_time
  • Description: Get current time for a timezone
  • API URL: http://worldtimeapi.org/api/timezone/{tz}
  • Method: GET
  • Headers: []
  • Parameters (JSON):
{
  "type":"object",
  "properties":{
    "tz":{"type":"string","description":"IANA TZ e.g. Asia/Karachi"}
  },
  "required":["tz"]
}
  • Response Field: datetime Example chat: “What time is it in Oslo?”

12) Language Translation (multilingual sites)

  • Tool Name: translate_text
  • Description: Translate text using LibreTranslate
  • API URL: https://libretranslate.com/translate
  • Method: POST
  • Headers:
[
  {"key":"Content-Type","value":"application/json"}
]
  • Parameters (JSON):
{
  "type":"object",
  "properties":{
    "q":{"type":"string","description":"Text to translate"},
    "source":{"type":"string","description":"Source lang e.g. en"},
    "target":{"type":"string","description":"Target lang e.g. ur"},
    "format":{"type":"string","enum":["text","html"],"description":"Optional"}
  },
  "required":["q","source","target"]
}
  • Response Field: translatedText Example chat: “Translate ‘hello friend’ to Urdu.”

13) SMS Notifications (support/sales)

  • Tool Name: send_sms
  • Description: Send an SMS via Twilio
  • API URL: https://api.twilio.com/2010-04-01/Accounts/{ACCOUNT_SID}/Messages.json
  • Method: POST
  • Headers: (RapidTextAI tool can use Basic Auth in URL or you can pass)
[
  {"key":"Content-Type","value":"application/x-www-form-urlencoded"}
]
  • Parameters (JSON):
{
  "type":"object",
  "properties":{
    "account_sid":{"type":"string","description":"Twilio Account SID"},
    "auth_token":{"type":"string","description":"Twilio Auth Token"},
    "From":{"type":"string","description":"Your Twilio number"},
    "To":{"type":"string","description":"Recipient E.164 e.g. +15551234567"},
    "Body":{"type":"string","description":"Message text"}
  },
  "required":["account_sid","auth_token","From","To","Body"]
}
  • Response Field: sid Example chat: “Text Ali that his order shipped.”

14) Email Send (lead-gen/alerts)

  • Tool Name: send_email
  • Description: Send transactional email via SendGrid
  • API URL: https://api.sendgrid.com/v3/mail/send
  • Method: POST
  • Headers:
[
  {"key":"Authorization","value":"Bearer YOUR_SENDGRID_API_KEY"},
  {"key":"Content-Type","value":"application/json"}
]
  • Parameters (JSON):
{
  "type":"object",
  "properties":{
    "to":{"type":"string"},
    "subject":{"type":"string"},
    "html":{"type":"string","description":"HTML body"},
    "from":{"type":"string","description":"Sender email"}
  },
  "required":["to","subject","html","from"]
}
  • Response Field: (leave blank — 202 accepted on success) Example chat: “Email the brochure to sara@example.com.”

15) URL Shortening (marketing)

  • Tool Name: shorten_link
  • Description: Shorten a URL using Bitly
  • API URL: https://api-ssl.bitly.com/v4/shorten
  • Method: POST
  • Headers:
[
  {"key":"Authorization","value":"Bearer YOUR_BITLY_TOKEN"},
  {"key":"Content-Type","value":"application/json"}
]
  • Parameters (JSON):
{
  "type":"object",
  "properties":{
    "long_url":{"type":"string","description":"Full URL to shorten"}
  },
  "required":["long_url"]
}

16) Shipping Tracking (e-commerce support)

  • Tool Name: track_shipment
  • Description: Track parcel using AfterShip
  • API URL: https://api.aftership.com/v4/trackings/{slug}/{tracking_number}
  • Method: GET
  • Headers:
[
  {"key":"aftership-api-key","value":"YOUR_AFTERSHIP_KEY"},
  {"key":"Content-Type","value":"application/json"}
]
  • Parameters (JSON):
{
  "type":"object",
  "properties":{
    "slug":{"type":"string","description":"Courier slug e.g. dhl, fedex"},
    "tracking_number":{"type":"string","description":"Tracking number"}
  },
  "required":["slug","tracking_number"]
}
  • Response Field: data.tracking.tag Example chat: “Track FedEx 612999999999.”

17) Address Geocoding (local services)

  • Tool Name: geocode_address
  • Description: Convert address to lat/long (OpenCage)
  • API URL: https://api.opencagedata.com/geocode/v1/json
  • Method: GET
  • Headers: []
  • Parameters (JSON):
{
  "type":"object",
  "properties":{
    "q":{"type":"string","description":"Full address"},
    "key":{"type":"string","description":"OpenCage API key"},
    "limit":{"type":"integer","default":1}
  },
  "required":["q","key"]
}
  • Response Field: results[0].geometry.lat (or omit to read full) Example chat: “Geocode ‘10 Downing St, London’.”

18) Country Info (education/travel)

  • Tool Name: country_info
  • Description: Get facts by country name (REST Countries)
  • API URL: https://restcountries.com/v3.1/name/{name}
  • Method: GET
  • Headers: []
  • Parameters (JSON):
{
  "type":"object",
  "properties":{
    "name":{"type":"string","description":"Country name e.g. Pakistan"}
  },
  "required":["name"]
}
  • Response Field: 0.capital[0] Example chat: “What’s the capital of Norway?”

19) Joke/Fun (engagement)

  • Tool Name: random_joke
  • Description: Fetch a dad joke
  • API URL: https://icanhazdadjoke.com/
  • Method: GET
  • Headers:
[
  {"key":"Accept","value":"application/json"}
]
  • Parameters (JSON):
{
  "type":"object",
  "properties":{}
}
  • Response Field: joke Example chat: “Tell me a joke.”

20) Helpdesk Ticket (SaaS support)

  • Tool Name: freshdesk_ticket
  • Description: Create a ticket in Freshdesk
  • API URL: https://YOURDOMAIN.freshdesk.com/api/v2/tickets
  • Method: POST
  • Headers:
[
  {"key":"Authorization","value":"Basic BASE64(API_KEY:X)"},
  {"key":"Content-Type","value":"application/json"}
]
  • Parameters (JSON):
{
  "type":"object",
  "properties":{
    "email":{"type":"string"},
    "subject":{"type":"string"},
    "description":{"type":"string"},
    "priority":{"type":"integer","enum":[1,2,3,4]},
    "status":{"type":"integer","enum":[2,3,4,5]}
  },
  "required":["email","subject","description"]
}
  • Response Field: id Example chat: “Open a high-priority ticket: checkout failed for order #9042.”

  • Tool Name: create_checkout_link
  • Description: Create a Stripe Payment Link for a product/price
  • API URL: https://api.stripe.com/v1/payment_links
  • Method: POST
  • Headers:
[
  {"key":"Authorization","value":"Bearer YOUR_STRIPE_SECRET"},
  {"key":"Content-Type","value":"application/x-www-form-urlencoded"}
]
  • Parameters (JSON):
{
  "type":"object",
  "properties":{
    "line_items[0][price]":{"type":"string","description":"Price ID"},
    "line_items[0][quantity]":{"type":"integer","description":"Qty"}
  },
  "required":["line_items[0][price]","line_items[0][quantity]"]
}
  • Response Field: url Example chat: “Create a checkout link for Price_ID=price_123 qty=1.”

22) Social Posts (marketing utilities)

  • Tool Name: post_to_telegram
  • Description: Send a message to a Telegram channel
  • API URL: https://api.telegram.org/bot{BOT_TOKEN}/sendMessage
  • Method: POST
  • Headers:
[
  {"key":"Content-Type","value":"application/json"}
]
  • Parameters (JSON):
{
  "type":"object",
  "properties":{
    "bot_token":{"type":"string"},
    "chat_id":{"type":"string","description":"Channel or user id"},
    "text":{"type":"string"}
  },
  "required":["bot_token","chat_id","text"]
}
  • Response Field: ok Example chat: “Publish today’s promo to Telegram channel.”

23) PDF Generation (ops/sales)

  • Tool Name: make_pdf
  • Description: Generate a PDF from HTML via PDFMonkey
  • API URL: https://api.pdfmonkey.io/api/v1/documents
  • Method: POST
  • Headers:
[
  {"key":"Authorization","value":"Bearer YOUR_PDFMONKEY_API_KEY"},
  {"key":"Content-Type","value":"application/json"}
]
  • Parameters (JSON):
{
  "type":"object",
  "properties":{
    "document[template_id]":{"type":"string"},
    "document[editable]":{"type":"boolean","default":false},
    "document[metadatas][filename]":{"type":"string"},
    "document[variables]":{"type":"object","description":"Data for template"}
  },
  "required":["document[template_id]","document[variables]"]
}
  • Response Field: document.download_url (you may need a second GET to poll — or leave field blank and let bot summarize) Example chat: “Generate a PDF quote for Ali, total $299.”

how to use these quickly

  1. open RapidTextAI → AI Chatbots → Tools → Add Tool
  2. copy each block’s values into your Tool form.
  3. for auth headers (Bearer/Basic), paste keys/tokens; for per-call secrets, include them in Parameters so the model supplies them.
  4. in your chatbot system prompt, tell the model when to use each tool:

“For payments use create_checkout_link; for shipping use track_shipment; for jokes use random_joke; for conversions use convert_currency…”


 Key Takeaway

Each chatbot tool follows the same pattern:

  1. Define Tool Name & Description.
  2. Provide API URL and HTTP method.
  3. Add Headers (if API key needed).
  4. Write Parameters (JSON Schema).
  5. Pick Response Field (to extract short answer).

This way, you can make AI-powered assistants for any niche: weather, travel, crypto, e-commerce, bookings, support, news, and more.



RapidTextAI Chatbots for WordPress — Complete Setup & Real-World Examples (Bookings, Support, Lead-Gen, and More)



What you’ll build

  • A production-ready chatbot widget you can drop anywhere in WordPress (page, post, sidebar).
  • A tools system so the bot can do things: create bookings, open support tickets, capture leads, query posts/products, call external APIs, and hand off to humans.
  • Optional Retrieval-Augmented answers from your own WordPress content.

This tutorial assumes you have the RapidTextAI – AI Text Block plugin installed from WP.org or GitHub and the Chatbots extension enabled inside it. If you don’t, install/enable it first. (WordPress.org)


1) Install & enable the Chatbots extension

  1. Install the plugin

    • From WordPress: Plugins → Add New → “AI Content Writer & Auto Post Generator (RapidTextAI)” → Install → Activate. (WordPress.org)
    • Or clone the repo (developer workflow).
  2. Connect RapidTextAI

    • Go to Settings → RapidTextAI and paste your RapidTextAI API key.
    • Pick default model(s) (e.g., GPT-4/5, Gemini 2.5, DeepSeek V3, Grok-2)—RapidTextAI supports multi-model combos. (app.rapidtextai.com)
  3. Enable Chatbots

    • In the plugin’s settings, turn Chatbots on (extension inside the plugin).

Tip: Keep a low-cost model for small talk and switch to a higher-IQ model for tasks (the examples below show how to route per-tool).


2) Create your first chatbot

  1. Go to RapidTextAI → Chatbots → Add New.
  2. Fill the key fields:

    • Name/Slug: e.g., Site Support Bot.
    • System Prompt (persona):

      “You are a concise, helpful assistant for {site_name}. Answer clearly. If the user requests a booking, call the book_appointment tool. For support issues, call open_ticket. For product queries, call search_products first. If unsure, ask one question.”

    • Knowledge sources (optional): enable WordPress retrieval (posts, pages, docs).
    • Tools: toggle the tools you want (we’ll add custom ones in §5–§7).
    • Routing (optional):

      • Chit-chat → economical model
      • Tool calls / “high stakes” → your best model
  3. Save the chatbot; note the Chatbot ID (you’ll use it in shortcodes/blocks).

3) Embed the chatbot on a page

Option A — Gutenberg block

  • Edit a page and insert RapidTextAI Chatbot block, select your Chatbot ID.

Option B — Shortcode

[rapidtextai_chatbot id="site-support" theme="clean" position="bottom-right" welcome="Hi! How can I help?"]

Option C — Anywhere via PHP (widget/theme)

echo do_shortcode('[rapidtextai_chatbot id="site-support"]');

Most sites go with the block or shortcode. If you need a floating launcher on every page, place the shortcode in a reusable block or your theme footer.


4) Train the bot on your content (optional but powerful)

Turn on Knowledge / Retrieval inside your Chatbot:

  • Scope to Posts, Pages, Docs, or a specific category like “Help Center.”
  • Set chunking size (e.g., 500–1,000 chars) and “max passages” (e.g., 5–10).
  • Rebuild the index after bulk edits for freshness.

This yields on-brand answers and reduces hallucinations.


5) Add a Bookings tool (create appointments from chat)

Below is a minimal, production-friendly tool that:

  • validates user inputs,
  • creates a “booking” custom post (or calls an external API),
  • returns a confirmation back to the chatbot.

You can swap the “storage” layer for WooCommerce Bookings, Amelia, Calendly, Google Calendar, etc. The pattern stays the same—only the inside of the handler changes.

5.1 – Register a REST action the chatbot can call

Add to a small mu-plugin or your theme’s functions.php:

/**
 * Tool: book_appointment
 * Endpoint: /wp-json/rapidtextai/v1/tool/book_appointment
 */
add_action('rest_api_init', function () {
  register_rest_route('rapidtextai/v1', '/tool/book_appointment', [
    'methods'  => 'POST',
    'permission_callback' => '__return_true',
    'callback' => function ($request) {
      $p = $request->get_json_params();

      // Basic validation
      $name  = sanitize_text_field($p['name']  ?? '');
      $email = sanitize_email($p['email'] ?? '');
      $date  = sanitize_text_field($p['date']  ?? '');
      $time  = sanitize_text_field($p['time']  ?? '');
      if (!$name || !$email || !$date || !$time) {
        return new WP_REST_Response([
          'ok' => false,
          'error' => 'Missing required fields: name, email, date, time.'
        ], 400);
      }

      // Create booking CPT (or integrate external API here)
      $booking_id = wp_insert_post([
        'post_type'   => 'booking',
        'post_status' => 'publish',
        'post_title'  => "Booking for $name on $date $time",
        'meta_input'  => compact('name','email','date','time')
      ]);

      if (is_wp_error($booking_id)) {
        return new WP_REST_Response(['ok' => false, 'error' => $booking_id->get_error_message()], 500);
      }

      // Email the team/user (optional)
      wp_mail(get_option('admin_email'), 'New Booking', "Name: $name\nEmail: $email\nDate: $date $time");

      return ['ok' => true, 'booking_id' => $booking_id, 'message' => 'Booked successfully.'];
    }
  ]);
});

5.2 – Expose the tool to the chatbot

Tell the bot what this tool expects/returns. Many chatbot frameworks (including yours) let you register tools via a filter or settings. In your plugin’s Chatbot → Tools UI, add:

  • Tool Name: book_appointment
  • Description: “Create an appointment. Requires name, email, date, time.”
  • Method: POST
  • URL: /wp-json/rapidtextai/v1/tool/book_appointment
  • JSON schema (for the model):
{
  "type": "object",
  "properties": {
    "name":  { "type": "string", "description": "Customer full name" },
    "email": { "type": "string", "description": "Customer email" },
    "date":  { "type": "string", "description": "ISO date e.g. 2025-09-25" },
    "time":  { "type": "string", "description": "24h time e.g. 14:30" }
  },
  "required": ["name","email","date","time"]
}

Result: The model can autonomously choose book_appointment during a chat (“I want a slot on Friday at 2 PM”) and your endpoint will create it.


6) Add a Support tool (open tickets from chat)

Use the same pattern to create tickets in your favorite system: your own CPT, Freshdesk, HelpScout, Zendesk, or a WP helpdesk plugin.

6.1 – Minimal ticket tool (CPT)

/**
 * Tool: open_ticket
 * Endpoint: /wp-json/rapidtextai/v1/tool/open_ticket
 */
add_action('rest_api_init', function () {
  register_rest_route('rapidtextai/v1', '/tool/open_ticket', [
    'methods'  => 'POST',
    'permission_callback' => '__return_true',
    'callback' => function ($request) {
      $p = $request->get_json_params();
      $email   = sanitize_email($p['email'] ?? '');
      $subject = sanitize_text_field($p['subject'] ?? 'No subject');
      $body    = wp_kses_post($p['body'] ?? '');

      if (!$email || !$body) {
        return new WP_REST_Response(['ok'=>false,'error'=>'email and body are required'], 400);
      }

      $ticket_id = wp_insert_post([
        'post_type'   => 'ticket',
        'post_status' => 'publish',
        'post_title'  => $subject . ' — ' . $email,
        'post_content'=> $body,
        'meta_input'  => compact('email')
      ]);

      return ['ok'=>true,'ticket_id'=>$ticket_id,'message'=>'Ticket created. Our team will email you shortly.'];
    }
  ]);
});

Register the tool in the Chatbot UI as:

  • Name: open_ticket
  • Description: “Create a support ticket. Requires email and issue body.”
  • Schema for email, subject, body.

If you use a SaaS helpdesk, call their REST API inside the callback instead of creating a CPT.


7) Add a Lead-gen tool (store leads + email opt-in)

/**
 * Tool: capture_lead
 * Endpoint: /wp-json/rapidtextai/v1/tool/capture_lead
 */
add_action('rest_api_init', function () {
  register_rest_route('rapidtextai/v1', '/tool/capture_lead', [
    'methods' => 'POST',
    'permission_callback' => '__return_true',
    'callback' => function($request) {
      $p = $request->get_json_params();
      $name  = sanitize_text_field($p['name'] ?? '');
      $email = sanitize_email($p['email'] ?? '');
      $note  = sanitize_textarea_field($p['note'] ?? '');

      if (!$email) return new WP_REST_Response(['ok'=>false,'error'=>'email required'], 400);

      // Store lead as a post or in a CRM
      $lead_id = wp_insert_post([
        'post_type'   => 'lead',
        'post_status' => 'publish',
        'post_title'  => "$name <$email>",
        'post_content'=> $note,
        'meta_input'  => compact('email')
      ]);

      // Optional: Add to Sendy/Mailchimp/HubSpot here via their APIs.

      return ['ok'=>true,'lead_id'=>$lead_id,'message'=>'Thanks! We’ve saved your details.'];
    }
  ]);
});

Register tool capture_lead with fields name, email, note.


8) Example: Make the bot smart about your products (search first, then answer)

A common pattern is a search tool that returns a few results the model can read and synthesize into an answer.

/**
 * Tool: search_products
 * Query WooCommerce and return top matches
 */
add_action('rest_api_init', function () {
  register_rest_route('rapidtextai/v1', '/tool/search_products', [
    'methods'=>'POST',
    'permission_callback'=>'__return_true',
    'callback'=>function($request){
      $q = sanitize_text_field(($request->get_json_params())['query'] ?? '');
      if (!$q) return new WP_REST_Response(['ok'=>false,'error'=>'query required'], 400);

      $args = [
        'post_type' => 'product',
        'posts_per_page' => 5,
        's' => $q
      ];
      $res = [];
      $loop = new WP_Query($args);
      while ($loop->have_posts()) {
        $loop->the_post();
        $price = function_exists('wc_get_product') ? wc_get_product(get_the_ID())->get_price() : '';
        $res[] = [
          'id'=> get_the_ID(),
          'title'=> get_the_title(),
          'url'=> get_permalink(),
          'price'=> $price
        ];
      }
      wp_reset_postdata();
      return ['ok'=>true,'results'=>$res];
    }
  ]);
});

Register tool search_products with an object that includes query and returns results[] (id, title, url, price). In your system prompt, tell the model:

“For product questions, always call search_products first, then answer using the results. If the user wants to buy, share the product URLs.”


9) Guardrails & UX polishing

  • Ask first, then act: “I can book that for you on Friday 2:00 PM—shall I proceed?” This avoids accidental tool calls.
  • PII minimization: Only collect what you actually need (e.g., email for tickets).
  • Rate limiting / nonce: If your site has heavy traffic, wrap endpoints with nonces or simple rate-limits.
  • Hand-off to human: If confidence is low or user is frustrated, give a “contact human” button (link to WhatsApp, email, or live chat).
  • Model routing: Use a cheaper model for small talk; switch to a stronger model for tool calls or knowledge answers (supported by RapidTextAI’s multi-model setup). (app.rapidtextai.com)

10) Hypothetical (but realistic) blueprints you can ship today

A) “Book a demo” concierge

  • Tools used: capture_lead, book_appointment
  • Flow: “Book a demo next week” → bot collects name/email → checks available slots (your own calendar API or a Google Calendar service account) → confirms booking → email notification.

B) Tier-1 Support triage

  • Tools used: open_ticket, search_posts (KB), optional handoff_to_human
  • Flow: User describes an issue → bot retrieves top 3 KB articles → summarizes answers → if unresolved, opens a ticket with transcript + context.

C) Product finder (e-commerce)

  • Tools used: search_products → (optional) add_to_cart
  • Flow: “I need a black hoodie under $30” → search → present top matches with links → if user says “buy #2,” call add_to_cart.

D) Lead magnet + Newsletter

  • Tools used: capture_lead, optional webhook to Sendy/Mailchimp
  • Flow: Offer a free checklist or coupon → capture email → send via your ESP → store lead in CPT/CRM.

11) Optional: Retrieval from your WP content (RAG)

If your Chatbots module exposes retrieval from posts/pages, enable it in the bot settings. Otherwise, you can add a lightweight tool:

/**
 * Tool: search_posts
 * Returns short excerpts from posts/pages to ground answers.
 */
add_action('rest_api_init', function(){
  register_rest_route('rapidtextai/v1','/tool/search_posts',[
    'methods'=>'POST',
    'permission_callback'=>'__return_true',
    'callback'=>function($req){
      $q = sanitize_text_field(($req->get_json_params())['query'] ?? '');
      $args = ['post_type'=>['post','page'],'posts_per_page'=>5,'s'=>$q];
      $loop = new WP_Query($args);
      $items=[];
      while($loop->have_posts()){ $loop->the_post();
        $items[]=[
          'id'=>get_the_ID(),
          'title'=>get_the_title(),
          'url'=>get_permalink(),
          'excerpt'=>wp_strip_all_tags(get_the_excerpt())
        ];
      }
      wp_reset_postdata();
      return ['ok'=>true,'results'=>$items];
    }
  ]);
});

Prompt nudge:

“When a question is about our documentation, call search_posts first and cite the URLs you used.”


12) Production checklist

  • Security: sanitize all inputs, prefer nonces for logged-in flows.
  • Observability: log tool calls (time, user, payload, result) to a custom table or Log channel.
  • Content quality: add a tone style (“concise, friendly”) and brand facts in the system prompt.
  • Fallbacks: if a tool fails, apologize and provide a manual link (“You can also book here: /bookings/”).
  • A/B test prompts: keep versions; small changes improve success rates significantly.

13) Frequently asked questions

Q. Can I run multiple chatbots? Yes—create multiple and embed per page (e.g., Pricing bot, Docs bot). (WordPress.org)

Q. Can I switch models per request? Yes—RapidTextAI supports multi-model workflows; route cheap/expensive models by intent/tool. (app.rapidtextai.com)

Q. Do I need another plugin for the widget? No—the Chatbots extension in your RapidTextAI plugin provides the widget/block/shortcode. (WordPress.org)


14) Copy-paste System Prompt you can reuse

You are {site_name} Assistant. Goals: Solve user requests quickly, accurately, and politely. Rules:

  1. If user asks for booking, call book_appointment (collect name, email, date, time; confirm before calling).
  2. For support issues, ask 1–2 clarifying questions, then call open_ticket with the summary; return the ticket ID.
  3. For product questions, call search_products, then answer using results; include links.
  4. If the user asks about site content, call search_posts and cite URLs.
  5. If unsure, ask a clarifying question. Keep answers under 120 words unless asked for detail.

15) Troubleshooting

  • The tool didn’t trigger:

    • Ensure the tool is enabled for the chatbot and the schema matches what your endpoint expects.
    • Check REST route URL and that permalinks are working (Settings → Permalinks → Save).
  • CORS or 401 errors:

    • If you front the site with Cloudflare/WAF, allow POST /wp-json/rapidtextai/*.
    • If you locked REST to logged-in users, keep a nonce check and generate it in the chatbot embed.
  • Model “refuses” to call a tool:

    • Add explicit instructions in the system prompt (“Always use the tool for…”).
    • Provide examples in the Tool Description to bias the model.

16) Where to go next

  • Add voice (STT/TTS) for a voice concierge.
  • Sync tickets to your helpdesk and mirror status back to users.
  • Add a “My orders” tool (authenticate user, fetch recent Woo orders).
  • Record analytics: top intents, success rate, time-to-action.

References & further reading

  • RapidTextAI WordPress plugin page (features include Chatbots). (WordPress.org)
  • RapidTextAI WordPress integration overview (multi-model & workflow ideas). (app.rapidtextai.com)

If you want, I can adapt these tools to WooCommerce Bookings, Amelia, Freshdesk/HelpScout, or Calendly/Google Calendar with exact API calls—just tell me which stack you’re using and I’ll drop in the precise handlers.