Web Chat utilizes the Adaptive Cards NPM package to render cards, and, unfortunately, Adaptive Cards does not support adding tooltip descriptions to elements in the card. There are, however, several issues open on GitHub regarding adding tooltip functionality, so hopefully, that feature will be available in Web Chat soon.
Even though Adaptive Cards doesn't support adding tooltips, you can create a custom attachment middleware for Web Chat and implement your own Hero Card renderer. The code snippet below shows a basic Hero Card renderer without any styling.
<script type="text/babel">
const HeroCardAttachment = ({ buttons, images, title, store }) =>
<div className='ac-container'>
<div className='ac-container'>
{ images.map(({ url }, index) =>
<window.React.Fragment key={ index }>
<div>
<img src= { url } />
</div>
<div style={{height: '8px'}}/>
</window.React.Fragment>
)}
<div>{ title }</div>
</div>
<div />
<div >
{ buttons.map(({ title, type, value }, index) => (
<window.React.Fragment key={ index }>
<button
aria-label={ title }
type='button'
title={ title }
onClick={ () => {
switch (type) {
case 'openUrl':
window.open(value)
break;
case 'postBack':
store.dispatch({
type: 'WEB_CHAT/SEND_POST_BACK',
payload: { value }
});
break;
default:
store.dispatch({
type: 'WEB_CHAT/SEND_MESSAGE_BACK',
payload: { value, text: value, displayText: value }
});
}
}}
>
<div title={ title }>
{ title }
</div>
</button>
<div />
</window.React.Fragment>
))}
</div>
</div>;
(async function () {
const res = await fetch('/directline/token', { method: 'POST' });
const { token } = await res.json();
const { createStore, ReactWebChat } = window.WebChat;
const store = createStore();
const attachmentMiddleware = () => next => card => {
switch (card.attachment.contentType) {
case 'application/vnd.microsoft.card.hero':
return <HeroCardAttachment {...card.attachment.content} store={ store }/>;
default:
return next(card);
}
};
window.ReactDOM.render(
<ReactWebChat
attachmentMiddleware={ attachmentMiddleware }
directLine={ window.WebChat.createDirectLine({ token }) }
store={ store }
/>,
document.getElementById('webchat')
);
store.dispatch({
type: 'WEB_CHAT/SET_SEND_BOX',
payload: { text: 'sample:github-repository' }
});
document.querySelector('#webchat > *').focus();
})().catch(err => console.error(err));
</script>
For more details regarding the attachment middleware, take a look at this sample.
Hope this helps.