Let a chat reaction wear the sender’s face

A friend laughs at one particular message. A compact “Maya · Laugh” button tells the reader who reacted and why. Tapping it plays the laugh on Maya’s 3D avatar.

Read the guide
Noor · Laugh

Attach the reaction to the message

Keep the message ID, the sender’s profile ID and the action ID with each reaction. Resolve the sender’s appearance separately. With that split, someone can change their avatar without rewriting the conversation.

Decide how history should look. A live profile reference shows today’s hairstyle on yesterday’s reaction. If the original look matters, store a recipe snapshot with the reaction when it is sent. Either approach can replay the same recorded gesture.

Give the reader a replay button

The function below builds one button for a reaction after your app has mounted the sender’s avatar. Read the action label from the installed catalog and keep a text fallback for an older client that does not recognize the ID. Each press starts the selected gesture again.

JavaScript
function reactionButton(avatar, senderName, actionID) {
  const button = document.createElement("button");
  const action = avatar.actions.find(item => item.id === actionID);
  button.type = "button";
  button.textContent = senderName + " · " + (action?.name ?? "Reaction");
  button.disabled = !action;
  if (action) {
    button.setAttribute("aria-label", "Replay " + action.name + " from " + senderName);
    button.onclick = () => avatar.play(action.id).catch(console.warn);
  }
  return button;
}

const reaction = reactionButton(avatar, "Maya", "face_with_tears_of_joy");
document.querySelector("#message-reactions").append(reaction);

Keep a busy thread readable

Render text buttons when the conversation first opens. Loading an old conversation then stays quiet, and a reader can deliberately choose which expression to watch. If your design uses one shared stage, finish applying the selected sender’s recipe before calling play. A completed appearance change interrupts the current performance.

Try alternating between two senders, then tap the same reaction twice. Check that the right face appears each time, the second tap restarts the gesture, and scrolling back through history leaves the thread still.

Reference

Related guides

Animate a 3D faceA profile avatar that remembers its owner