microsoft / BotFramework-WebChat

A highly-customizable web-based client for Azure Bot Services.
https://www.botframework.com/
MIT License
1.6k stars 1.55k forks source link

[Omnichannel] How do I style Adaptive Cards and their children when using Omnichannel Live Chat Widget / BotFramework WebChat? #5340

Closed YayoKB closed 2 weeks ago

YayoKB commented 3 weeks ago

I have a question

What I'm using:

I'm trying to style the adaptive cards and their content (such as the inputs, Action.OpenUrl items, etc.) beyond just basic styling. I want to be able to change the border radius, padding, etc. of these elements.

The most customization I can seem to do easily on adaptive cards' children is inside the webChatStyles prop:

cardEmphasisBackgroundColor: "red",
cardPushButtonTextColor: "green",
cardPushButtonBackgroundColor: "blue",

I know about the middleware, but there are three I've seen on the BotFramework-WebChat repo and have no idea which one to use and how to access it when using Omnichannel:

Here is my script that contains the lcw() function:

    <script>
      function lcw() {
        return {
          styleProps: {
            generalStyles: {
              borderRadius: "12px",
              minWidth: "400px",
            },
          },
          controlProps: {
            hideFooter: true,
          },
          webChatContainerProps: {
            webChatStyles: {
              accent: "magenta !important",
              subtle: "lime !important",
              cardEmphasisBackgroundColor: "red",
              cardPushButtonTextColor: "red",
              cardPushButtonBackgroundColor: "red",
              backgroundColor: "#f3f4f7",
              bubbleBackground: "#e7ecf4",
              bubbleTextColor: "#3C4E6D",
              // other styles
            },
            webChatProps: {
              adaptiveCardsHostConfig: {
                allowCustomStyle: true,
                supportsInteractivity: true,
                containerStyles: {
                  // containerStyles
                },
                adaptiveCard: {
                  allowCustomStyle: true,
                },
              },
            },
            renderingMiddlewareProps: {
              attachmentAdaptiveCardStyles: {
                borderStyle: "solid",
                borderColor: "red",
                borderWidth: "2px",
              },
              userMessageStyleProps: {
                fontSize: "1rem",
                lineHeight: "1.5",
              },
              systemMessageStyleProps: {
                fontSize: "1rem",
                lineHeight: "1.5",
              },
            },
          },
        };
      }
    </script>

And here is the script that contains the Omnichannel bundle:

<script
      v2
      id="Microsoft_Omnichannel_LCWidget"
      src="https://oc-cdn-public-eur.azureedge.net/livechatwidget/scripts/LiveChatBootstrapper.js"
      data-app-id="APP_ID"
      data-lcw-version="prod"
      data-org-id="ORG_ID"
      data-org-url="ORG_URL"
      data-customization-callback="lcw"
      data-font-family-override="system-ui, Segoe UI, Roboto, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"
      data-color-override="#2d8dd2"
    >
</script>

I've already asked this question on Stack Overflow if anyone would rather reply on there. Thank you!

OEvgeny commented 2 weeks ago

Not sure about OmniChannel, but here is how you could do this with vanilla Web Chat: https://stackblitz.com/edit/sb1-ads7jw?file=index.js,components%2FCustomSubmitAction.js

YayoKB commented 2 weeks ago

Not sure about OmniChannel, but here is how you could do this with vanilla Web Chat: https://stackblitz.com/edit/sb1-ads7jw?file=index.js,components%2FCustomSubmitAction.js

Hi, thanks for the reply and the resource :) I think that, unfortunately, the solution involves some other middleware that Omnichannel will have to expose for script-layer users. :(

OEvgeny commented 2 weeks ago

I'd suggest reaching out to OmniChannel team, so they provide feature parity with Web Chat at least on visual customization. Alternatively you could try overriding adaptive cards styles using CSS, but it's not recommended.