Initialize the client with your API key, search threads, then reply to the newest email in the newest thread:
Copy
import osfrom aiinbx import AIInbxclient = AIInbx( api_key=os.environ.get("AI_INBX_API_KEY"), # default when unset too)# Search threads (newest first by default)search = client.threads.search()newest_thread = search.threads[0]# Retrieve full thread with emailsthread = client.threads.retrieve(newest_thread.id)newest_email = thread.emails[-1]# Reply to the emailclient.emails.reply(newest_email.id, { "from": "support@your-domain.com", "html": "<p>This is a test reply email</p>",})
Tip: Prefer environment variables (e.g., with python-dotenv) instead of hardcoding your API key.