Skip to content

Interactive Playground

The playground provides an interactive testing environment for workflows, featuring a chat interface, session management, and real-time execution feedback.

Create sessions, send messages, and watch the simulated workflow execute in real time:

import { mountPlayground } from '@flowdrop/flowdrop/playground';
import '@flowdrop/flowdrop/styles';
const playground = await mountPlayground(container, {
workflowId: 'my-workflow-id',
endpointConfig: createEndpointConfig('/api/flowdrop'),
onSessionStatusChange: (newStatus, previousStatus) => {
console.log(`Session status: ${previousStatus} -> ${newStatus}`);
}
});
// Control the playground
playground.startPolling();
playground.destroy();
<script lang="ts">
import { Playground } from '@flowdrop/flowdrop/playground';
</script>
<Playground workflowId="my-workflow-id" />

The playground supports multiple parallel sessions. Each session represents an independent conversation with the workflow:

  • Create new sessions
  • Switch between active sessions
  • View session history
  • Delete sessions via dropdown menu

The chat panel displays messages from both the user and the workflow execution:

  • User messages are shown on the right
  • System/assistant messages on the left
  • Execution logs inline in the conversation
  • Interrupt prompts rendered as interactive UI elements

The playground polls the backend for new messages during execution. Configure polling behavior:

const playground = await mountPlayground(container, {
playgroundConfig: {
pollingInterval: 1500,
shouldStopPolling: (status) => {
// Stop polling on terminal statuses
return ['completed', 'failed', 'cancelled'].includes(status);
},
isTerminalStatus: (status) => {
return ['completed', 'failed', 'cancelled'].includes(status);
}
}
});
import { defaultShouldStopPolling, defaultIsTerminalStatus } from '@flowdrop/flowdrop/playground';

The awaiting_input status pauses polling automatically — call playground.startPolling() to resume after an interrupt is resolved.

For custom transports (WebSocket, SSE), push poll responses directly:

// Push messages from a WebSocket
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
playground.pushMessages(data);
};

The playground integrates with FlowDrop’s interrupt system. See the Human-in-the-Loop guide for details on interrupt types and configuration.

The playground uses these backend endpoints:

EndpointMethodPurpose
/playground/sessionsPOSTCreate a new session
/playground/sessionsGETList sessions
/playground/sessions/{id}GETGet session details
/playground/sessions/{id}DELETEDelete session
/playground/sessions/{id}/executePOSTExecute workflow
/playground/sessions/{id}/messagesGETPoll for messages