File size: 4,177 Bytes
383cb38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112

import os
import time
import sys
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

def run_demo():
    print("[START] Starting ATOM Computer Use Demo...")
    
    # Configuration
    base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    demo_apps_dir = os.path.join(base_dir, "demo_apps")
    
    chrome_options = Options()
    # chrome_options.add_argument("--headless") # Comment out to see the magic!
    chrome_options.add_argument("--start-maximized")
    chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
    chrome_options.add_experimental_option('useAutomationExtension', False)
    
    driver = webdriver.Chrome(options=chrome_options)
    
    try:
        # 1. GMAIL - Lead Detection
        gmail_path = "file://" + os.path.join(demo_apps_dir, "gmail.html").replace("\\", "/")
        print(f"[GMAIL] Navigating to Gmail: {gmail_path}")
        driver.get(gmail_path)
        time.sleep(2)
        
        # Simulate "Extracting" data
        print("[AI] AI Agent: Identifying lead email...")
        lead_row = driver.find_element(By.ID, "leadEmailRow")
        driver.execute_script("arguments[0].style.border = '3px solid #4285f4';", lead_row)
        time.sleep(1.5)
        
        print("[GMAIL] Opening lead email...")
        lead_row.click()
        time.sleep(2)
        
        # 2. ZOHO CRM - Lead Creation
        zoho_path = "file://" + os.path.join(demo_apps_dir, "zoho.html").replace("\\", "/")
        print(f"[ZOHO] Navigating to Zoho CRM: {zoho_path}")
        driver.get(zoho_path)
        time.sleep(2)
        
        print("[ZOHO] Creating lead in Zoho...")
        driver.find_element(By.ID, "btnNewLead").click()
        time.sleep(1)
        
        driver.find_element(By.ID, "firstName").send_keys("Sarah")
        time.sleep(0.5)
        driver.find_element(By.ID, "lastName").send_keys("Jenkins")
        time.sleep(0.5)
        driver.find_element(By.ID, "company").send_keys("Project X")
        time.sleep(0.5)
        driver.find_element(By.ID, "email").send_keys("sarah.j@projectx.com")
        time.sleep(1)
        
        print("[ZOHO] Saving lead...")
        driver.find_element(By.ID, "submitLeadBtn").click()
        time.sleep(2)
        
        # 3. SLACK - Notification & HITL
        slack_path = "file://" + os.path.join(demo_apps_dir, "slack.html").replace("\\", "/")
        print(f"[SLACK] Navigating to Slack: {slack_path}")
        driver.get(slack_path)
        time.sleep(1.5)
        
        print("[SLACK] Sending notification to Slack...")
        driver.execute_script("window.triggerAlert()")
        time.sleep(2)
        
        print("[SLACK] Waiting for Human-In-The-Loop (HITL) approval...")
        # In a real demo, we wait for the user to click the button in the browser
        # We can poll for the 'approvedMsg' display state
        approved = False
        timeout = 60 # 60 seconds max wait
        start_time = time.time()
        
        while not approved and (time.time() - start_time) < timeout:
            msg = driver.find_element(By.ID, "approvedMsg")
            if msg.is_displayed():
                approved = True
                print("[SLACK] HITL Approved!")
            time.sleep(1)
            
        if not approved:
            print("[WARNING] HITL Timeout. Proceeding anyway for demo...")

        time.sleep(1)
        
        # 4. ZOOM - Meeting Completion
        zoom_path = "file://" + os.path.join(demo_apps_dir, "zoom.html").replace("\\", "/")
        print(f"[ZOOM] Navigating to Zoom: {zoom_path}")
        driver.get(zoom_path)
        time.sleep(4) # Let the user see the confirmation
        
        print("[SUCCESS] Workflow Complete!")
        
    except Exception as e:
        print(f"[ERROR] Demo execution failed: {e}")
    finally:
        print("[FINISH] Closing browser in 3 seconds...")
        time.sleep(3)
        driver.quit()

if __name__ == "__main__":
    run_demo()