Header
The Header component sits at the top of the Webchat UI. It displays the bot’s name, avatar, and description. It also provides access to key actions like restarting the conversation or closing the chat window.
import { Header, useWebchat } from '@botpress/webchat'
// Every attribute that the header component can take
const headerConfig = {
botName: 'SupportBot',
botAvatar: 'https://cdn.botpress.cloud/bot-avatar.png',
botDescription: 'Your virtual assistant for all things support.',
phone: {
title: 'Call Support',
link: 'tel:+1234567890',
},
email: {
title: 'Email Us',
link: 'mailto:support@example.com',
},
website: {
title: 'Visit our website',
link: 'https://www.example.com',
},
termsOfService: {
title: 'Terms of Service',
link: 'https://www.example.com/terms',
},
privacyPolicy: {
title: 'Privacy Policy',
link: 'https://www.example.com/privacy',
},
}
function App() {
const [isWebchatOpen, setIsWebchatOpen] = useState(false)
const { newConversation } = useWebchat({
clientId: '$CLIENT_ID$', // Insert your client id here
})
return (
<Header
onOpenChange={() => console.log('Override the header open change')}
defaultOpen={true}
closeWindow={() => setIsWebchatOpen(false)}
restartConversation={newConversation}
disabled={false}
configuration={headerConfig}
/>
)
} Although you can use the Header as a standalone component, we recommend using it within the Container
component and alongside the Composer and MessageList components.
Props
defaultOpen boolean
open boolean
onOpenChange (open: boolean) => void
disabled boolean
restartConversation () => void
closeWindow () => void
configuration Pick<Configuration, 'email' | 'phone' | 'privacyPolicy' | 'website' | 'termsOfService' | 'botAvatar' | 'botDescription' | 'botName'>
required