import React, { useState } from 'react'; import axios from 'axios'; const Chatbot = () => { const [input, setInput] = useState(''); const [conversation, setConversation] = useState([]); const handleInputChange = (e: React.ChangeEvent) => { setInput(e.target.value); }; const handleSendMessage = () => { const newMessage = { text: input, sender: 'user' }; setConversation((prevConversation) => [...prevConversation, newMessage]); axios.post('https://example.com/api/chatbot', { input }) .then((response) => { const botResponse = { text: response.data, sender: 'bot' }; setConversation((prevConversation) => [...prevConversation, botResponse]); }) .catch((error) => { console.error(error); }); setInput(''); }; return (

Chatbot

); }; export default Chatbot;