question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to update Bot avatar image per Activity

See original GitHub issue

We 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:open
  • Created 3 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
compulimcommented, Mar 25, 2021

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:

type BaseActivity = {
  channelData: Expando<{
    /** Avatar initials of the sender. */
    'webchat:avatar:initials'?: string;

    /** Avatar image of the sender. */
    'webchat:avatar:image'?: string;
  }>;
}
0reactions
CodeguruEdisoncommented, Aug 12, 2022

@SreekanthOAuth are you able to make it ?, if yes, can you please submit the solution?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found