Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support avatar image #1456

Closed
hemachowdary opened this issue Dec 10, 2018 · 7 comments
Closed

Support avatar image #1456

hemachowdary opened this issue Dec 10, 2018 · 7 comments
Assignees
Labels
front-burner p1 Painful if we don't fix, won't block releasing Sample Implement PoC or sample code

Comments

@hemachowdary
Copy link

Hi,
I have developed a bot in sdk4 using nodejs. I wanted to change the default look and feel of the bot. So I am using webchat customization referring to the sample [here](https://github.com/Microsoft/BotFramework-WebChat/blob/master/SAMPLES.md). I am able to add initals to bot and user avatars using the below styling options. botAvatarInitials: 'BOT', userAvatarInitials: 'ME'. How can I add an image instead of having initials. Does bot supports only the stylings mentioned here as of now?
Also whenever you add some new functionality for styling please add comments.

@vmunnuru
Copy link

vmunnuru commented Dec 10, 2018

import { createStyleSet } from 'botframework-webchat;

const styleSet = createStyleSet({});
styleSet.avatar = {...styleSet.avatar,
  backgroundImage: `url(${imageUrl})`
};

<ReactWebChat
  botAvatarInitials= ' '
  userAvatarInitials= ' '
  styleSet={styleSet}`
/>

[edited by @corinagum for text formatting]

@compulim compulim changed the title Webchat customization Support avatar image Dec 10, 2018
@compulim compulim added the 4.3 label Dec 10, 2018
@hemachowdary
Copy link
Author

@vmunnuru i am not usnig react js. I am following the way that is mentioned under "Change font or color" section here

@corinagum corinagum added the p1 Painful if we don't fix, won't block releasing label Dec 11, 2018
@compulim
Copy link
Contributor

@hemachowdary @vmunnuru We have prioritized this work and will implement this feature in the next release of Web Chat.

@corinagum corinagum added the Sample Implement PoC or sample code label Dec 11, 2018
@compulim
Copy link
Contributor

In the meanwhile, @vmunnuru solution is good. You might want to add background-size to cover/contain to make it auto downscale. Plus some accessibility fixes (aria-label for the image).

@compulim
Copy link
Contributor

The work is done in PR #1486.

@corinagum
Copy link
Contributor

In the meantime, for those who wish to have separate images for both avatars, please use the following:

const styleSet = window.WebChat.createStyleSet();
      styleSet.avatar = { 
          ...styleSet.avatar,
         '&.from-user': { 
             backgroundImage:'url(\'https://github.com/compulim.png?size=64\')' 
          },
         '&:not(.from-user)': {     
             backgroundImage:'url(\'https://docs.microsoft.com/en-us/azure/bot-service/v4sdk/media/logo_bot.svg?view=azure-bot-service-4.0\')' }
          };
 
      window.WebChat.renderWebChat({
         directLine: window.WebChat.createDirectLine({ token }),
         styleSet,
         botAvatarInitials: ' ',
         userAvatarInitials: ' '
    }, document.getElementById('webchat'));

@compulim
Copy link
Contributor

The PR is being merged and it will be resolved by @4.2.1-master.d35a7ac and >= @4.2.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
front-burner p1 Painful if we don't fix, won't block releasing Sample Implement PoC or sample code
Projects
None yet
Development

No branches or pull requests

4 participants