DocsAI Agent
Back to Docs

AI Agent

Configure your AI assistant to handle customer support automatically.

Setting Up the AI Agent

1. Go to Dashboard β†’ Settings β†’ AI Agent.
2. Toggle Enable AI Agent to ON.
3. Choose your AI Provider:
   β€’ Google Gemini β€” Recommended. Fast and cost-effective.
     Get your API key from: https://aistudio.google.com
   β€’ OpenAI (ChatGPT) β€” Get your API key from: https://platform.openai.com
4. Select a Model:
   β€’ Gemini: gemini-2.0-flash (recommended), gemini-1.5-pro
   β€’ OpenAI: gpt-4o, gpt-4o-mini, gpt-3.5-turbo
5. Paste your API Key.
6. Write your System Prompt (see next section).
7. Adjust Temperature (0 = precise, 1 = creative) and Max Tokens (response length).
8. Click Save Configuration.

Writing an Effective System Prompt

The System Prompt is the most important part of your AI setup. It defines who the AI is, what it knows, how it should behave, and what it should NOT do.

Example System Prompt:
---
You are Sarah, a friendly customer support agent for TechStore Pakistan.

BUSINESS INFO:
- We sell laptops, phones, and accessories.
- Store hours: Mon-Sat 10am-8pm PKT
- WhatsApp: +92-300-1234567
- Address: Main Boulevard, Lahore

YOUR JOB:
- Answer questions about our products and prices.
- Help track orders using the order number the customer provides.
- Recommend products based on the customer's budget and needs.
- Always respond in the same language the customer uses (Urdu or English).

RULES:
- Never make up prices. Say "Please contact us for the latest price."
- If asked something outside your knowledge, say "Let me connect you with our team."
- Keep responses short and clear (max 3-4 sentences).
- Be warm and professional at all times.
---

Settings Guide:
β€’ Temperature 0.3 β€” More precise, consistent answers (recommended for support).
β€’ Temperature 0.8 β€” More creative, varied responses (good for marketing bots).
β€’ Max Tokens 500 β€” Good for short conversational replies.

Controlling AI in Flows

Use the AI Control node in your Flow Builder to enable or disable the AI at specific points.

Common pattern:
1. User sends message β†’ Fallback trigger fires.
2. Flow sends a greeting and collects their name.
3. AI Control node β†’ ENABLE β€” AI takes over the conversation.

In Live Chat:
β€’ Click the brain icon in the top chat toolbar to toggle AI ON/OFF for that specific chat.
β€’ When AI is OFF, the agent handles the conversation manually.
β€’ When you re-enable it, AI resumes from where it left off.

Note: If a flow session is active, the AI will not interfere until the session ends.

Google Calendar & AI Booking

Automate appointment booking and scheduling with your Google Calendar through the AI agent.

How to set up:
1. Go to Dashboard β†’ Integrations and connect your Google Workspace account.
2. Go to Settings β†’ AI Agent β†’ Function Calling (Tools) and toggle "Google Calendar Tools" ON.
3. Choose the default Google Calendar ID from your connected account settings.

How it works:
When Google Calendar Tools are enabled, the AI is auto-equipped with two built-in functions:
1. check_availability:
   β€’ Checks the connected calendar for busy periods using Google's Free/Busy API.
   β€’ Scans 30-minute intervals during working hours (9:00 AM to 6:00 PM PKT/Pakistan Time).
   β€’ Returns free slots to the AI, which presents them as interactive buttons or text options.
2. book_appointment:
   β€’ Confirms the chosen date (YYYY-MM-DD) and time slot (e.g., "3:00 PM").
   β€’ Collects the customer's name and automatically extracts their WhatsApp phone number.
   β€’ Creates the event in Google Calendar, setting the duration to 30 minutes.

Automated Reminders:
To prevent no-shows, the system automatically schedules WhatsApp reminders using follow-up cron jobs:
β€’ 1 Day Before: Sends an automated reminder 24 hours prior to the slot.
β€’ 3 Hours Before: Sends a follow-up reminder 3 hours prior.
β€’ 1 Hour Before: Sends a final reminder 1 hour prior.
β€’ Users can reply "CANCEL" to cancel the event, which deletes it from your Google Calendar automatically.

Shopify E-Commerce AI Tools

Equip your AI Agent with official Shopify tools to handle e-commerce queries, track packages, check catalogs, and handle cancellations.

Setup:
1. Connect your shop domain (e.g. yourstore.myshopify.com) at Dashboard β†’ Integrations β†’ Shopify.
2. Go to Settings β†’ AI Agent β†’ Shopify and enable your preferred mode:
   β€’ Beginner Mode: Runs simple order checks and product queries.
   β€’ Pro Mode: Unlocks advanced catalog lookup and cancellation capabilities.

Available AI Shopify Tools:
β€’ shopify_get_order: Retrieves order status, item details, and total price. Requires the user to provide an order number (e.g. #1024) AND the phone number associated with the order.
β€’ shopify_track_order: Fetches shipping carrier details and live tracking URLs.
β€’ shopify_find_my_orders: Searches recent orders automatically using the customer's active WhatsApp phone number (no manual input required).
β€’ shopify_search_product: Searches products by name/keyword and sends results with interactive reply buttons.
β€’ shopify_cancel_order: Cancels the customer's order. Requires order number, phone number, and a confirmed cancellation reason.

Security & Handover Rules:
β€’ Phone Verification: For security, checking orders or cancellations requires matching the phone number on the Shopify order.
β€’ Failed Handover: If a customer fails phone number verification twice (2 times), the AI Agent will automatically disable itself for the chat session and assign the conversation to a human support agent (Handover).
β€’ Cancellation Confirmation: The AI is restricted from canceling orders unless the customer explicitly confirms the action.

Custom AI Tools (Function Calling)

Create custom automated actions (tools) that your AI Agent can trigger based on customer intent.

How to create a Custom Tool:
1. Go to Settings β†’ AI Agent β†’ Function Calling (Tools).
2. Click Create Custom Tool.
3. Fill in the tool configuration:
   β€’ Tool Name: A unique identifier (use lowercase and underscores, e.g. assign_vip_tag).
   β€’ Tool Description: Explain exactly when the AI should call this tool. Example: "Call this when the user says they are a premium member or want VIP support."
   β€’ Parameter Fields: Define inputs the AI must collect from the user (e.g., parameter name: customer_email, type: string, description: "The email address of the customer", required: check true).
4. Link Actions to the Tool:
   - When the AI calls this tool, it can trigger a multi-action chain in sequence:
     β€’ Send Media: Auto-send a PDF, audio, or image.
     β€’ Assign Agent: Assign the conversation to a specific teammate.
     β€’ Change Funnel Stage: Move the contact in your CRM pipeline.
     β€’ Add Tag: Apply marketing/CRM tags (e.g. VIP).
     β€’ Add Note: Log internal team notes.
     β€’ Update Custom Fields: Populate contact fields with collected parameters.
     β€’ Schedule Follow-up: Schedule a message to be sent after N hours/days.

Example use case:
Create a tool named "schedule_consultation". Define parameters: "full_name", "company". Set actions: "Add Tag: Lead", "Schedule Follow-up: Send pricing PDF in 2 hours". When the customer says "I want to book a consultation", the AI collects their name and company, runs the tool, and triggers the actions automatically.