⏱️ 5 minutes to complete

What You'll Build

By the end of this tutorial, you'll have a working page with:

🔐
User Login
💳
Payments
📦
User Data
🤖
AI Chat

Prerequisites

1

Add the SDK Script

30 seconds

Add this single script tag to your HTML, just before the closing </body> tag:

index.html
<script src="https://api.gammal.tech/sdk-web.js"></script>
That's It!

No API keys, no configuration files, no npm install. The SDK auto-initializes and uses domain whitelisting for security.

2

Add Login

1 minute

Add a login button and handle authentication:

Login button
<button id="loginBtn">Login with Gammal Tech</button>
<p id="userStatus">Not logged in</p>

<script>
// Handle login button click
document.getElementById('loginBtn').addEventListener('click', async () => {
    const token = await GammalTech.login();
    if (token) {
        document.getElementById('userStatus').textContent = 'Logged in! ✓';
    }
});

// Check if already logged in on page load
if (GammalTech.isLoggedIn()) {
    document.getElementById('userStatus').textContent = 'Logged in! ✓';
    document.getElementById('loginBtn').textContent = 'Logged In';
}
</script>
3

Add Payments

1 minute

Accept payments with a single function call:

Payment button
<button id="buyBtn">Buy Premium - 99 EGP</button>

<script>
document.getElementById('buyBtn').addEventListener('click', async () => {
    await GammalTech.pay(99, 'Premium Subscription', async (payment) => {
        // This runs after successful payment
        console.log('Payment ID:', payment.payment_id);
        
        // Deliver the product/service here
        unlockPremiumFeatures();
        
        // Confirm delivery
        await GammalTech.confirmDelivery(payment.payment_id);
        
        alert('Thank you for your purchase!');
    });
});
</script>
⚠️ Payments Require Approval

Contact Gammal Tech to enable payments for your domain. This ensures security and compliance.

4

Save User Data

1 minute

Store and retrieve user preferences:

User data
<select id="themeSelect">
    <option value="light">Light Theme</option>
    <option value="dark">Dark Theme</option>
</select>

<script>
// Load saved preference on page load
async function loadPreferences() {
    if (!GammalTech.isLoggedIn()) return;
    
    const data = await GammalTech.user.get();
    if (data.theme) {
        document.getElementById('themeSelect').value = data.theme;
        document.body.className = data.theme;
    }
}
loadPreferences();

// Save when user changes theme
document.getElementById('themeSelect').addEventListener('change', async (e) => {
    const theme = e.target.value;
    document.body.className = theme;
    
    // Save to Gammal Tech (syncs across devices)
    const data = await GammalTech.user.get();
    data.theme = theme;
    await GammalTech.user.save(data);
});
</script>
5

Add AI

1 minute

Add AI-powered features:

AI assistant
<input type="text" id="question" placeholder="Ask me anything...">
<button id="askBtn">Ask AI</button>
<p id="answer"></p>

<script>
document.getElementById('askBtn').addEventListener('click', async () => {
    const question = document.getElementById('question').value;
    document.getElementById('answer').textContent = 'Thinking...';
    
    const response = await GammalTech.ai.ask(question, {
        system: 'You are a helpful assistant. Keep responses brief.'
    });
    
    document.getElementById('answer').textContent = response;
});
</script>

Complete Example

Here's everything together in one file:

complete-example.html
<!DOCTYPE html>
<html>
<head>
    <title>My Gammal Tech App</title>
    <style>
        body { font-family: sans-serif; padding: 20px; max-width: 600px; margin: 0 auto; }
        button { padding: 10px 20px; margin: 5px; cursor: pointer; }
        input { padding: 10px; width: 100%; margin: 10px 0; }
        .section { margin: 30px 0; padding: 20px; border: 1px solid #ddd; border-radius: 8px; }
    </style>
</head>
<body>
    <h1>🚀 My Gammal Tech App</h1>
    
    <!-- Login Section -->
    <div class="section">
        <h2>🔐 Account</h2>
        <button id="loginBtn">Login</button>
        <span id="userStatus"></span>
    </div>
    
    <!-- AI Section -->
    <div class="section">
        <h2>🤖 AI Assistant</h2>
        <input id="question" placeholder="Ask anything...">
        <button id="askBtn">Ask</button>
        <p id="answer"></p>
    </div>
    
    <!-- Payment Section -->
    <div class="section">
        <h2>💳 Premium</h2>
        <button id="buyBtn">Upgrade - 99 EGP</button>
    </div>
    
    <script src="https://api.gammal.tech/sdk-web.js"></script>
    <script>
        // Login
        document.getElementById('loginBtn').onclick = async () => {
            await GammalTech.login();
            updateUI();
        };
        
        // AI
        document.getElementById('askBtn').onclick = async () => {
            const q = document.getElementById('question').value;
            document.getElementById('answer').textContent = 'Thinking...';
            const a = await GammalTech.ai.ask(q);
            document.getElementById('answer').textContent = a;
        };
        
        // Payment
        document.getElementById('buyBtn').onclick = async () => {
            await GammalTech.pay(99, 'Premium', async (p) => {
                alert('Thanks! Payment: ' + p.payment_id);
                await GammalTech.confirmDelivery(p.payment_id);
            });
        };
        
        // Update UI on load
        function updateUI() {
            const logged = GammalTech.isLoggedIn();
            document.getElementById('loginBtn').textContent = logged ? 'Logged In ✓' : 'Login';
        }
        updateUI();
    </script>
</body>
</html>

Next Steps

🤖

AI Prompt for Vibe Coding

Quick Start

Copy this prompt for help getting started:

I'm starting a new project with Gammal Tech SDK. SDK Setup: <script src="https://api.gammal.tech/sdk-web.js"></script> Available Features: - GammalTech.login() - User authentication - GammalTech.isLoggedIn() - Check auth status - GammalTech.getToken() - Get auth token - GammalTech.pay(amount, desc, callback) - Payments (EGP) - GammalTech.user.get() / .save() - User data storage - GammalTech.ai.ask(prompt) - AI completion My project: [DESCRIBE YOUR APP] I need help with: 1. [SPECIFIC FEATURE OR QUESTION] 2. [ANOTHER QUESTION] Please provide code examples that I can copy and use directly.
Available Features: - GammalTech.login() - User authentication - GammalTech.isLoggedIn() - Check auth status - GammalTech.getToken() - Get auth token - GammalTech.pay(amount, desc, callback) - Payments (EGP) - GammalTech.user.get() / .save() - User data storage - GammalTech.ai.ask(prompt) - AI completion My project: [DESCRIBE YOUR APP] I need help with: 1. [SPECIFIC FEATURE OR QUESTION] 2. [ANOTHER QUESTION] Please provide code examples that I can copy and use directly.`; navigator.clipboard.writeText(prompt).then(() => { event.target.textContent = 'Copied!'; setTimeout(() => event.target.textContent = 'Copy', 2000); }); }