microsoft / microsoft/BotFramework-WebChat

How to update Bot avatar image per Activity

Open
#3,768 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

backlog Bot Services customer-replied-to customer-reported feature-request front-burner
Dominant language
HTML
Stars
1.8k
Forks
1.6k
Avg merge
22h 58m
Merged PRs (30d)
2

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the avatarMiddleware shown in the issue and trace how its styleOptions are applied to activities in the React Web Chat integration. Reproduce the handoff transition with old and new activities; done means the current activity uses the agent avatar while earlier activities retain their original bot avatar.

Written by the indexing model from the issue text.

Assessment

Tech stack
react
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.