Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Give a LangChain agent email tools backed by SentFromAI.
@tool
pip install langchain langchain-openai langgraph requests
import os, requests from langchain_core.tools import tool API = "https://api.sentfrom.ai/v1" H = {"Authorization": f"Bearer {os.environ['SENTFROMAI_API_KEY']}"} @tool def create_inbox(local_part: str) -> dict: """Create a new email inbox. Returns its id and address.""" return requests.post(f"{API}/inboxes", headers=H, json={"local_part": local_part}).json() @tool def send_email(inbox_id: str, to: str, subject: str, body: str) -> dict: """Send an email from an inbox to a recipient.""" return requests.post(f"{API}/messages", headers=H, json={"inbox_id": inbox_id, "to": [to], "subject": subject, "text": body}).json() @tool def check_inbox(inbox_id: str) -> list: """List the most recent messages in an inbox.""" return requests.get(f"{API}/messages", headers=H, params={"inbox_id": inbox_id, "limit": 10}).json()["messages"]
from langchain_openai import ChatOpenAI from langgraph.prebuilt import create_react_agent agent = create_react_agent(ChatOpenAI(model="gpt-4o"), [create_inbox, send_email, check_inbox]) result = agent.invoke({"messages": [ ("user", "Create an inbox called concierge and email jane@acme.com a welcome note.") ]}) print(result["messages"][-1].content)
create_inbox
send_email
reply
check_inbox