Unblu Agent Embedded JS API
    Preparing search index...

    Class UnbluEmbeddedAppElement

    To use the custom element, place a tag named "unblu-embedded-app" somewhere in the web page's body. By default, the element shows the agent's inbox. If a conversation-id attribute is set on the element, it shows that conversation instead.

    ...
    <body>
    ...
    <div>
    <unblu-embedded-app></unblu-embedded-app>
    </div>
    ...
    </body>
    ...

    The size and positioning depend entirely on the styles applied to it by the website that it's embedded in. The styling within the web component, on the other hand, aren't affected by the website's styles,because it uses a shadow root for its content. Unblu provides numerous configuration properties that let you customize the web component's appearance to suit your organizations requirements.

    The example above only adds the embedded app component to the DOM without initializing anything. To initialize and display content, you must create the UnbluAgentEmbeddedApi.

    The Unblu UI inside the custom element always fills the whole content of the element irrespective of the size it's given.

    Note: It is possible to display as many UnbluEmbeddedAppElement and UnbluConversationElement as one likes with the restriction that one conversation can only be displayed in one of them.

    <unblu-embedded-app conversation-id="<CONVERSATION-ID>"></unblu-embedded-app>
    
    const embeddedApp = document.querySelector('unblu-embedded-app');
    embeddedApp.addEventListener('openConversationChanged', (event) => {
    console.log('Open conversation changed:', event.detail); // conversation ID or null
    });

    You can register an interceptor to control what happens when a conversation is opened from the embedded app's inbox view. This is useful when you want to open the conversation in a separate <unblu-conversation> component rather than within the embedded app itself.

    embeddedApp.registerOpenConversationInterceptor(async (conversationId) => {
    // return { action: 'OPEN' } to let the embedded app open the conversation
    // return { action: 'DISCARD' } to handle it yourself (e.g. open it in a separate <unblu-conversation> element)
    return { action: 'DISCARD' };
    });

    Hierarchy

    • HTMLElement
      • UnbluEmbeddedAppElement
    Index

    Constructors

    Properties

    ATTR_CONVERSATION_ID: "conversation-id" = ...

    ID of the conversation currently open in the embedded app. If set, the conversation is opened in the embedded app.

    Accessors

    • get conversationId(): string

      Returns string

    • set conversationId(conversationId: string): void

      Opens the conversation with the given conversation ID.

      This can be set before Unblu is initialized. The conversation is then opened as soon as Unblu is initialized.

      If the conversation doesn't exist, or the user doesn't have permission to access it, a dialog is displayed with the appropriate error message. In such cases, the conversation ID is reset to null.

      Parameters

      • conversationId: string

        The id of the conversation to open

      Returns void

      UnbluEmbeddedAppElement.ATTR_CONVERSATION_ID to set this as an attribute

    Methods

    • Registers an open conversation interceptor that's triggered whenever a conversation should be opened from the embedded app's inbox view.

      Parameters

      • openConversationInterceptor: OpenConversationInterceptor

        The interceptor, which should resolve to an OpenConversationInterceptorResult with action OPEN if the embedded app UI should open the conversation or DISCARD if the embedded app will do nothing and the integrating page must handle the request.

        see #unregisterOpenConversationInterceptor to unregister the interceptor

      Returns Promise<void>

    • Unregisters an open conversation interceptor used previously

      Parameters

      • openConversationInterceptor: OpenConversationInterceptor

        The interceptor to unregister

        see #registerOpenConversationInterceptor to register a new interceptor

      Returns Promise<void>

    Events

    OPEN_CONVERSATION_CHANGED: "openConversationChanged" = ...

    Event emitted every time the currently open conversation changes in the embedded app.