@@ -145,9 +145,9 @@ async def send_message(contact, message):
145
145
async def auto_respond_to_unread ():
146
146
"""Click unread tab and respond to messages"""
147
147
print ('\n Auto-responding to unread messages...' )
148
-
148
+
149
149
llm = ChatGoogle (model = 'gemini-2.0-flash-exp' , temperature = 0.3 , api_key = GOOGLE_API_KEY )
150
-
150
+
151
151
task = """
152
152
1. Go to https://web.whatsapp.com
153
153
2. Wait for page to load
@@ -159,13 +159,13 @@ async def auto_respond_to_unread():
159
159
- Move to next unread chat
160
160
5. Report how many messages were responded to
161
161
"""
162
-
162
+
163
163
browser = BrowserSession (
164
164
headless = not args .debug ,
165
165
user_data_dir = str (USER_DATA_DIR ),
166
166
storage_state = str (STORAGE_STATE_FILE ) if STORAGE_STATE_FILE .exists () else None ,
167
167
)
168
-
168
+
169
169
agent = Agent (task = task , llm = llm , browser_session = browser )
170
170
result = await agent .run ()
171
171
print ('✅ Auto-response complete' )
@@ -185,16 +185,16 @@ async def main():
185
185
if args .auto :
186
186
print ('AUTO MODE - Responding to unread messages every ~30 minutes' )
187
187
print ('Press Ctrl+C to stop.\n ' )
188
-
188
+
189
189
while True :
190
190
try :
191
191
await auto_respond_to_unread ()
192
-
192
+
193
193
# Wait 30 minutes +/- 5 minutes randomly
194
194
wait_minutes = 30 + random .randint (- 5 , 5 )
195
195
print (f'\n ⏰ Next check in { wait_minutes } minutes...' )
196
196
await asyncio .sleep (wait_minutes * 60 )
197
-
197
+
198
198
except KeyboardInterrupt :
199
199
print ('\n \n Auto mode stopped by user' )
200
200
break
0 commit comments