Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
Get notification when task is done
magmueller268e34239b37
diff --git a/examples/notification.py b/examples/notification.pyindex 20ff4f7ad..56a8bfede 100644--- a/examples/notification.py+++ b/examples/notification.py@@ -1,10 +1,46 @@-import yagmail--# STEP 1: go to https://support.google.com/accounts/answer/185833-# STEP 2: Create an app password-# STEP 3: Use the app password in the code below for the password-yag = yagmail.SMTP('[email protected]', 'your_app_password')-yag.send(- to='[email protected]', subject='Test Email', contents='Hello from Python using yagmail!'-)-print('Email sent!')+import os+import sys++sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))++import asyncio++from dotenv import load_dotenv+from langchain_openai import ChatOpenAI+from pydantic import BaseModel++from browser_use import ActionResult, Agent, Controller++load_dotenv()++controller = Controller()++[email protected]('Done with task ')+async def done(text: str):+ import yagmail++ # To send emails use+ # STEP 1: go to https://support.google.com/accounts/answer/185833+ # STEP 2: Create an app password (you cant use here your normal gmail password)+ # STEP 3: Use the app password in the code below for the password+ yag = yagmail.SMTP('[email protected]', 'your_app_password')+ yag.send(+ to='[email protected]',+ subject='Test Email',+ contents=f'result\n: {text}',+ )++ return ActionResult(is_done=True, extracted_content='Email sent!')+++async def main():+ task = 'go to brower-use.com and then done'+ model = ChatOpenAI(model='gpt-4o')+ agent = Agent(task=task, llm=model, controller=controller)++ await agent.run()+++if __name__ == '__main__':+ asyncio.run(main())