How to update Bot avatar image per Activity
See original GitHub issueWe are using React app with below version
“botframework-webchat”: “^4.11.0”
Case
We need to show a different bot avatar on Activity basis. Example - We have a handoff feature, where Bot avatar should be an agent icon when the user is chatting with Live Agent and once the chat ended we need to show the old/original bot avatar.
We are using avatarMiddleware
to achieve the above case.
Code Sample
const avatarMiddleware = () => next => ({ fromUser, ...otherArgs }) => {
const renderAvatar = next({ fromUser, ...otherArgs });
if (otherArgs.styleOptions !== null && otherArgs.styleOptions !== undefined) {
otherArgs.styleOptions.userAvatarImage = avatarImg.userAvatarImage;
otherArgs.styleOptions.userAvatarInitials = avatarImg.userAvatarInitials;
otherArgs.styleOptions.botAvatarInitials = avatarImg.botAvatarInitials;
if (isLiveChatStarted) {
otherArgs.styleOptions.botAvatarImage = 'data:image/png;base64,xxxxxx';
}
}
if (!isLiveChatStarted) {
otherArgs.styleOptions.botAvatarImage = eva.imageData;
}
return (
renderAvatar &&
(() => (
<AvatarWithLPStatus lpStatus={isLiveChatStarted} fromUser={fromUser}>
{renderAvatar()}
</AvatarWithLPStatus>
))
);
};
Issue
The above logic is updating the bot avatar image however it is updating the old activities bot avatar also. We are looking for middleware to update bot avatar image per activity.
Thanks, Kundan(Ecolab)
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (3 by maintainers)
Top Results From Across the Web
How to set the User avatar dynamically in BotFramework ...
How to set the User avatar dynamically in BotFramework-WebChat based on logged in user using OAuthCard · Fetch the user icon using the...
Read more >Add avatar images for newly created Support Bot and Alert Bot
Avatar images have been obtained from #210523. This change sets the custom avatars for newly created Alert and Support Bots.
Read more >Change Avatar In my PVA BOT - Power Platform Community
Hi Everyone,. Anyone has problem when changing Avatar image for BOT? I tried different URL it seems doesn't change. const styleOptions = {...
Read more >What Is Instagram's AI Photo Trend & How Can You Join In?
In order to gain access to Lensa AI app's magic avatars functionality, users would have to download the free app and upgrade to...
Read more >Create a bot for your workspace - Slack
What can bots do? · Monitor and help process channel activity · Post automated messages in Slack · Make channel messages interactive with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
FYI, I am working on a prototype of new chat adapter architecture that would allow bot developers to specify per-activity avatar. The mechanism is same as what @stevkan described above, leveraging the
channelData
property.It’s still in prototype phase, the design may change anytime. But here is how it looks:
@SreekanthOAuth are you able to make it ?, if yes, can you please submit the solution?