mirror of
https://github.com/browser-use/browser-use
synced 2026-05-13 17:56:35 +02:00
commit92d1732a40Merge:fa4ff47aefcd2b33Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Wed Oct 8 08:18:35 2025 -0700 Merge main commitfa4ff47ae4Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Wed Oct 8 08:03:04 2025 -0700 Laminar info mode commit8625aa9ba9Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Wed Oct 8 08:02:54 2025 -0700 Default to flash for browser use llm commit69a517ad7cAuthor: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Wed Oct 8 08:02:44 2025 -0700 Update example commitc91467c51dAuthor: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Wed Oct 8 08:02:15 2025 -0700 Update example commit4e2b3f1306Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Wed Oct 8 07:54:05 2025 -0700 Linter commite8d6936a47Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Wed Oct 8 07:53:43 2025 -0700 Example commit961d6fc451Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Wed Oct 8 07:52:23 2025 -0700 Update default links commit0b2853859bAuthor: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Wed Oct 8 07:44:59 2025 -0700 Default fast fasle commit9d67594b63Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Tue Oct 7 22:01:24 2025 -0700 Simplify commitf5712bdec0Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Tue Oct 7 21:45:00 2025 -0700 Parsing json commit503af624ddMerge:ef7fa1e40d2522b1Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Tue Oct 7 21:04:31 2025 -0700 Merge branch 'flat-output' of https://github.com/browser-use/browser-use into flat-output commitef7fa1e401Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Tue Oct 7 21:04:28 2025 -0700 Add prompt description handling for browser-use cloud service - Enhanced the Agent class to generate and pass prompt descriptions to the LLM when using the browser-use provider. - Updated the ChatBrowserUse class to accept an optional prompt_description parameter in the ainvoke method. - Modified the tracked_ainvoke function in TokenCost to forward additional keyword arguments. - Adjusted example model to initialize Laminar for tracing. commit0d2522b1f9Author: Gregor Žunič <36313686+gregpr07@users.noreply.github.com> Date: Tue Oct 7 20:23:39 2025 -0700 updated default base url commit0a2e6d6520Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Tue Oct 7 18:50:56 2025 -0700 Hide api key commit96bba9692bAuthor: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Tue Oct 7 18:49:05 2025 -0700 Add env var loading and validation to ChatBrowserUse, update example commitc2e57a3babAuthor: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Tue Oct 7 18:36:31 2025 -0700 Linter commit3d4cc1dbecAuthor: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Tue Oct 7 16:28:10 2025 -0700 Rename commit14ab0b75feAuthor: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Tue Oct 7 16:21:52 2025 -0700 Rename super_fast to fast parameter in ChatBrowserUse commit7fab3c47d3Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Tue Oct 7 16:08:10 2025 -0700 Update system prompt commit2066e77b98Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Tue Oct 7 16:07:51 2025 -0700 Del claude file commit297b767e91Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Tue Oct 7 16:01:50 2025 -0700 Revert flash system prompt to JSON format - Reverted system_prompt_flash.md to main (JSON format) - Added examples/models/browser_use_cloud.py for llm-use cloud service - llm-use service will inject unstructured format on the server side commit99af55f8e9Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Tue Oct 7 15:58:40 2025 -0700 Example commit657ff0d352Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Tue Oct 7 15:54:23 2025 -0700 Remove unused commita42123d8e5Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Tue Oct 7 15:49:54 2025 -0700 ignore commitde4fe19020Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Tue Oct 7 15:48:01 2025 -0700 Example commit27e5ab9947Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Tue Oct 7 14:29:01 2025 -0700 Add llm-use cloud client example - ChatLLMUseCloud: Browser-use compatible client for llm-use service - Implements BaseChatModel protocol with proper typing - Includes credit checking before/after tasks - Error handling for 401/402/500 responses - Converts messages between browser-use and HTTP API formats - Returns ChatInvokeCompletion with usage stats Usage: export LLM_USE_URL='https://your-app.railway.app' export LLM_USE_API_KEY='your-key' python examples/llm_use_cloud_client.py commita47a448005Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Tue Oct 7 13:03:59 2025 -0700 Enhance response parsing in ChatBrowserUse to handle structured data from the API, including debug logging for received data keys. commite79c7dc633Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Mon Oct 6 19:39:29 2025 -0700 Include browser-use llm commit584d977154Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Mon Oct 6 17:55:31 2025 -0700 Linter commitb0ac87076aMerge:1183b8fe0076775fAuthor: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Mon Oct 6 15:01:37 2025 -0700 merge main commit1183b8fe6bAuthor: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Sun Oct 5 16:26:34 2025 -0700 Fix done output action model commit852449b1bcAuthor: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Sun Oct 5 16:23:31 2025 -0700 More debug info commita57ba25d36Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Sun Oct 5 16:07:15 2025 -0700 Multiline parser commit2153dbe6aaAuthor: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Sun Oct 5 15:50:14 2025 -0700 Fix custom output commitec5c08ba0fAuthor: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Sun Oct 5 15:36:54 2025 -0700 Fix files in output commit7444048e8fAuthor: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Sun Oct 5 15:28:09 2025 -0700 Update codebase with unstructured output commita8f05b4611Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Sun Oct 5 14:55:20 2025 -0700 Save systemprompt commitd7d112c569Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com> Date: Sun Oct 5 14:51:24 2025 -0700 new parser
146 lines
5.1 KiB
Plaintext
146 lines
5.1 KiB
Plaintext
---
|
|
title: "Webhooks"
|
|
description: "Learn how to integrate webhooks with Browser Use Cloud API"
|
|
icon: "code"
|
|
mode: "wide"
|
|
---
|
|
|
|
Webhooks allow you to receive real-time notifications about events in your Browser Use tasks. This guide will show you how to set up and verify webhook endpoints.
|
|
|
|
## Prerequisites
|
|
|
|
<Note>
|
|
You need an active subscription to create webhooks. See your billing page
|
|
[cloud.browser-use.com/dashboard/billing](https://cloud.browser-use.com/dashboard/billing)
|
|
</Note>
|
|
|
|
## Setting Up Webhooks
|
|
|
|
To receive webhook notifications, you need to:
|
|
|
|
1. Create an endpoint that can receive HTTPS POST requests
|
|
2. Configure your webhook URL in the Browser Use dashboard
|
|
3. Implement signature verification to ensure webhook authenticity
|
|
|
|
<Note>
|
|
When adding a webhook URL in the dashboard, it must be a valid HTTPS URL that can receive POST requests.
|
|
On creation, we will send a test payload `{"type": "test", "timestamp": "2024-03-21T12:00:00Z", "payload": {"test": "ok"}}` to verify the endpoint is working correctly before creating the actual webhook!
|
|
</Note>
|
|
|
|
## Webhook Events
|
|
|
|
Browser Use sends various types of events. Each event has a specific type and payload structure.
|
|
|
|
### Event Types
|
|
|
|
Currently supported events:
|
|
|
|
| Event Type | Description |
|
|
| -------------------------- | -------------------------------- |
|
|
| `agent.task.status_update` | Status updates for running tasks |
|
|
|
|
### Task Status Updates
|
|
|
|
The `agent.task.status_update` event includes the following statuses:
|
|
|
|
| Status | Description |
|
|
| -------------- | -------------------------------------- |
|
|
| `initializing` | A task is initializing |
|
|
| `started` | A Task has started (browser available) |
|
|
| `paused` | A task has been paused mid execution |
|
|
| `stopped` | A task has been stopped mid execution |
|
|
| `finished` | A task has finished |
|
|
|
|
## Webhook Payload Structure
|
|
|
|
Each webhook call includes:
|
|
|
|
- A JSON payload with event details
|
|
- `X-Browser-Use-Timestamp` header with the current timestamp
|
|
- `X-Browser-Use-Signature` header for verification
|
|
|
|
The payload follows this structure:
|
|
|
|
```json
|
|
{
|
|
"type": "agent.task.status_update",
|
|
"timestamp": "2025-05-25T09:22:22.269116+00:00",
|
|
"payload": {
|
|
"session_id": "cd9cc7bf-e3af-4181-80a2-73f083bc94b4",
|
|
"task_id": "5b73fb3f-a3cb-4912-be40-17ce9e9e1a45",
|
|
"status": "finished",
|
|
"metadata": {
|
|
"campaign": "q4-automation",
|
|
"team": "marketing"
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
The webhook payload now includes a `metadata` field containing any custom key-value pairs that were provided when the task was created. This allows you to correlate webhook events with your internal tracking systems.
|
|
|
|
## Implementing Webhook Verification
|
|
|
|
To ensure webhook authenticity, you must verify the signature. Here's an example implementation in Python using FastAPI:
|
|
|
|
```python
|
|
import uvicorn
|
|
import hmac
|
|
import hashlib
|
|
import json
|
|
import os
|
|
|
|
from fastapi import FastAPI, Request, HTTPException
|
|
|
|
app = FastAPI()
|
|
|
|
SECRET_KEY = os.environ['SECRET_KEY']
|
|
|
|
def verify_signature(payload: dict, timestamp: str, received_signature: str) -> bool:
|
|
message = f'{timestamp}.{json.dumps(payload, separators=(",", ":"), sort_keys=True)}'
|
|
expected_signature = hmac.new(SECRET_KEY.encode(), message.encode(), hashlib.sha256).hexdigest()
|
|
return hmac.compare_digest(expected_signature, received_signature)
|
|
|
|
@app.post('/webhook')
|
|
async def webhook(request: Request):
|
|
body = await request.json()
|
|
|
|
timestamp = request.headers.get('X-Browser-Use-Timestamp')
|
|
signature = request.headers.get('X-Browser-Use-Signature')
|
|
if not timestamp or not signature:
|
|
raise HTTPException(status_code=400, detail='Missing timestamp or signature')
|
|
|
|
if not verify_signature(body, timestamp, signature):
|
|
raise HTTPException(status_code=403, detail='Invalid signature')
|
|
|
|
# Handle different event types
|
|
event_type = body.get('type')
|
|
if event_type == 'agent.task.status_update':
|
|
# Handle task status update
|
|
print('Task status update received:', body['payload'])
|
|
elif event_type == 'test':
|
|
# Handle test webhook
|
|
print('Test webhook received:', body['payload'])
|
|
else:
|
|
print('Unknown event type:', event_type)
|
|
|
|
return {'status': 'success', 'message': 'Webhook received'}
|
|
|
|
if __name__ == '__main__':
|
|
uvicorn.run(app, host='0.0.0.0', port=8080)
|
|
```
|
|
|
|
## Best Practices
|
|
|
|
1. **Always verify signatures**: Never process webhook payloads without verifying the signature
|
|
2. **Handle retries**: Browser Use will retry failed webhook deliveries up to 5 times
|
|
3. **Respond quickly**: Return a 200 response as soon as you've verified the signature
|
|
4. **Process asynchronously**: Handle the webhook payload processing in a background task
|
|
5. **Monitor failures**: Set up monitoring for webhook delivery failures
|
|
6. **Handle unknown events**: Implement graceful handling of new event types that may be added in the future
|
|
|
|
<Note>
|
|
Need help? Contact our support team at support@browser-use.com or join our
|
|
[Discord community](https://link.browser-use.com/discord)
|
|
</Note>
|