How to Use XiaoZ Chatbot API

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

Step 1: Get API Key

Register on the XiaoZ platform to obtain your unique API key.

Step 2: Authenticate

Use your API key to authenticate API requests to XiaoZ servers.

Step 3: Send Requests

Send HTTP requests with appropriate parameters to access chatbot functionalities.

Step 4: Receive Responses

Receive JSON or XML responses containing chatbot replies, data, or actions.

Step 5: demo html code

<!-- Sample HTML form for interacting with XiaoZ API -->
<form id="chat-form">
    <input type="text" id="user-input" placeholder="Type your message...">
    <button type="submit">Send</button>
</form>

<!-- Display area for chat messages -->
<div id="chat-messages"></div>

<!-- JavaScript code for handling API requests -->
<script>
    const chatForm = document.getElementById('chat-form');
    const userInput = document.getElementById('user-input');
    const chatMessages = document.getElementById('chat-messages');

    chatForm.addEventListener('submit', async (e) => {
        e.preventDefault();
        const message = userInput.value.trim();
        if (message === '') return;

        // Send message to XiaoZ API
        const response = await fetch('https://api.xiaoz.com/chatbot', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'Authorization': 'Bearer YOUR_API_KEY',
            },
            body: JSON.stringify({ text: message, userId: 'user123' }),
        });

        const data = await response.json();
        const botMessage = document.createElement('div');
        botMessage.classList.add('bot-message');
        botMessage.textContent = data.message;
        chatMessages.appendChild(botMessage);
        userInput.value = '';
    });
</script>
                    

Step 6: Done!!!

Now you can chat with your bot