Skip to main content
Execute agent tools in the browser via WebSocket. Handle real-time tool requests from the agent and return results — for UI interactions, form manipulation, and client-side state access. What you’ll learn: WebSocket vs webhook tools, tool configuration, request handling, response format, and error handling.
Testing requires a valid API key. Generate a web integration token from your agent’s Web Integrations settings in the Dasha BlackBox dashboard before starting.

When to use WebSocket tools

WebSocket tool execution is designed for tools that need direct access to the user’s browser or application state: Use WebSocket tools for:
  • UI interactions (clicking buttons, navigating tabs, scrolling)
  • Form manipulation (filling inputs, selecting options)
  • Browser actions (opening windows, navigating URLs)
  • Client-side state (localStorage, sessionStorage, DOM access)
  • Real-time user feedback (animations, notifications)
Use webhook tools for:
  • Server-side API calls
  • Database queries
  • Email sending
  • Payment processing
  • Any operation requiring server-side secrets
WebSocket tools execute in the browser. Never use them for operations requiring server-side secrets or authentication credentials.

Step 1: Configure tools for WebSocket

Tools must be explicitly configured for WebSocket execution in your web integration.

Via dashboard

  1. Go to Dashboard → Agents → [Your Agent] → Web Integrations
  2. Select your integration
  3. Navigate to Features tab
  4. Under Tools, add tool names to execute via WebSocket
Include tool names in your web integration’s tools array:
Listen for websocketToolRequest messages and respond with websocketToolResponse:

Step 3: Tool implementation examples

Step 4: Complete implementation

Always return structured error responses:

Best practices

Troubleshooting

Tool not being called

Possible causes:
  • Tool not configured in web integration
  • Tool name mismatch between agent config and handler
  • Agent doesn’t understand when to use the tool
Solution: Verify tool name in dashboard matches exactly, check agent’s tool descriptions are clear.
Possible causes:
  • Handler takes too long to execute
  • Handler never returns
  • DOM operation fails silently
Solution: Add timeouts, logging, and error boundaries:
Possible causes:
  • Result format doesn’t match what agent expects
  • Error in result not clearly communicated
  • Agent prompt doesn’t instruct how to use results
Solution: Use consistent result structure, include descriptive messages:

Next steps

Message Reference

Complete WebSocket message documentation

Error Handling

Handle errors and edge cases