import { MascotCall, MascotClient, MascotRive } from "@mascotbot-sdk/react";
import { Alignment, Fit, Layout, useRive } from "@rive-app/react-canvas";
// Replace with your API endpoint.
const MASCOT_CALL_API_URL = "your-endpoint-domain";
export default function Call() {
const rive = useRive(
{
src: "your_rive_file_url",
artboard: "YourArtboard",
animations: "YourAnimation",
stateMachines: "YourStateMachine",
autoplay: true,
layout: new Layout({
fit: Fit.FitHeight,
alignment: Alignment.Center,
}),
},
{
shouldResizeCanvasToContainer: true,
}
);
return (
<MascotClient rive={rive} inputs={["thumbs_up"]}>
<div style={{ position: "relative", height: "100%" }}>
<MascotCall
apiUrl={MASCOT_CALL_API_URL}
tts={{ engine: "elevenlabs", voice: "your-voice-id" }}
onStateChange={(state) => console.log("Call state:", state)}
debug
>
{(provided) => (
<>
<MascotRive
onClick={({ inputs }) => {
inputs?.thumbs_up && inputs.thumbs_up.fire();
}}
/>
<div
style={{
position: "absolute",
bottom: 0,
insetInline: 0,
paddingBottom: 16,
zIndex: 50,
}}
>
<div
style={{
display: "flex",
flexDirection: "column",
rowGap: 6,
width: "max-content",
marginInline: "auto",
}}
>
{provided.state === "disconnected" ? (
<button {...provided.startProps}>Start</button>
) : provided.state === "ready" ? (
<button
{...provided.endProps}
style={{ backgroundColor: "red", color: "white", borderColor: "red" }}
>
End
</button>
) : (
<button
style={{ opacity: 0.5, pointerEvents: "none" }}
>
Connecting…
</button>
)}
<button {...provided.muteProps}>
{provided.muted ? "Unmute" : "Mute"}
</button>
</div>
</div>
</>
)}
</MascotCall>
<div
style={{
position: "absolute",
bottom: 0,
insetInline: 0,
height: 150,
background:
"linear-gradient(to top, rgb(255, 255, 255) 15%, rgba(255, 255, 255, 0))",
}}
/>
</div>
</MascotClient>
);
}