Skip to main content

Sending An Email

๐Ÿ“ค Quickstart Guide - Sending an Emailโ€‹

Learn how to integrate OpenAI with Fiscus SDK in under 5 minutes to send an email through the Gmail API.

How to Use the Fiscus SDKโ€‹

Turn natural language into powerful API operations in minutes. Follow these 5 steps to send a personalized email using AI with the Fiscus SDK:

What youโ€™ll achieve: By the end of this guide, youโ€™ll have an AI agent capable of sending a personalized email using natural language commands.

1. Install Fiscus SDKโ€‹

Install Packages

pip install fiscus

2. Connect Your Email API (e.g., Gmail)โ€‹

Quickly integrate with an email API

from fiscus import FiscusClient

# Initialize the Fiscus client with your API key and user_id
client = FiscusClient(api_key='YOUR_FISCUS_API_KEY', user_id='user_123')

# Add the email connector (e.g., Gmail)
client.user.add_connector('Gmail')

# If the connector requires authentication, this will trigger an authentication flow
client.user.authenticate_connector('Gmail')

3. Initialize OpenAIโ€‹

Set up your LLM or Agent.

from openai import OpenAI

# Initialize OpenAI
openai_client = OpenAI(api_key='YOUR_OPENAI_API_KEY')

4. Fetch Email Connector & Interact with LLMโ€‹

Letโ€™s send a personalized email using natural language:

# Define the natural language task
task = "Send a welcome email to our newest user.'"

# Fetch tools and interact with the LLM
response = openai_client.chat.completions.create(
model="gpt-4-turbo-preview",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": task}
]
)

5. Execute the Fiscus SDK to Send an Emailโ€‹

Finally, letโ€™s execute the email sending action using the Fiscus SDK:

# Execute the action using the Fiscus SDK
result = client.execute(
connector_name='Gmail',
operation='send_email',
params={
'to': 'user@example.com',
'subject': 'Welcome!',
'body': 'This is a personalized welcome email using Fiscus SDK.'
}
)

print(result)

ย 

Look at That! ๐ŸŽ‰

Success! Youโ€™ve now:

๐Ÿ” Authenticated your email API account with Fiscus SDK
๐Ÿ›  Fetched email-sending capabilities via API
๐Ÿง  Passed a natural language command to an AI language model
๐Ÿ“ง Instructed the AI to send a personalized email
โœ… Successfully executed the email-sending action