Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.
Register on the XiaoZ platform to obtain your unique API key.
Use your API key to authenticate API requests to XiaoZ servers.
Send HTTP requests with appropriate parameters to access chatbot functionalities.
Receive JSON or XML responses containing chatbot replies, data, or actions.
<!-- 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>
Now you can chat with your bot