Skip to main content

REFERENCE

SDK Demos

How to use @asgard-js/core and @asgard-js/react, with demos you can try on the page.

Custom Renderer

Use renderMessageContent to take over how specific messages are rendered. You can detect custom payload types and return any React node, with or without the default avatar + bubble wrapper.

  1. Modes​

    ModeUse when
    with-avatarCustom content but keep the default avatar and bubble
    no-avatarFully custom rendering, bypass MessageContainer
    wrapperAdd timestamps / metadata around the default content
    defaultFall back to built-in rendering
  2. Code Example​

    <Chatbot
    renderMessageContent={({ message, renderDefaultContent, MessageContainer }) => {
    if (message.type === "bot") {
    const payload = message.message.payload;
    if (payload?.customType === "order_card") {
    return (
    <MessageContainer>
    <OrderCard payload={payload} />
    </MessageContainer>
    );
    }
    }
    return renderDefaultContent();
    }}
    />
  3. See Also​

Ready to get started?

Want to see how Asgard fits your team? Talk to us.

Contact us