Skip to content
Scalekit Docs
Talk to an Engineer Dashboard

Agent Actions - Quickstart Guide

Agent Actions will help enable your AI Agents to take actions in real world applications on behalf of your users. Scalekit automatically handles authorizing your users to grant access to third party applications like Gmail, Calendar, Slack, Notion etc and using our pre-built connectors and tool, lets your AU Agent execute actions like fetching emails, creating calendar events, updating notion pages, sending alerts via Slack etc.

This quickstart guide will show you how to get started with Agent Actions in just a few minutes. You’ll learn how to set up connections, authenticate users, and run your first tools.

In this quickstart, you’ll build a simple tool calling program that:

  1. Authenticates a user with GMail to authenticate their Gmail account via OAuth 2.0
  2. Fetches last 5 unread emails from the user’s inbox

Before you start, make sure you have:

  • Scalekit API credentials (Client ID and Client Secret)
  • Development environment (Node.js, Python, or similar)

First, install the Scalekit Python SDK and initialize the client with your API credentials:

pip install scalekit-sdk-python

import scalekit.client
import os
scalekit = scalekit.client.ScalekitClient(
client_id=os.getenv("SCALEKIT_CLIENT_ID"),
client_secret=os.getenv("SCALEKIT_CLIENT_SECRET"),
env_url=os.getenv("SCALEKIT_ENV_URL"),
)
actions = scalekit.actions

Let’s authorize a user to access their Gmail account by creating a connected account. This represents the user’s connection to their Gmail account:

# Create a connected account for user if it doesn't exist already
connected_account = actions.get_or_create_connected_account(
connection_name="gmail",
identifier="user_123"
)
print(f'Connected account created: {connected_account.id}')

Inorder to execute any tools on behalf of the user, the user first needs to grant authorization to access their gmail account. Scalekit automatically handles the entire OAuth workflow with the Gmail provider, gets the access token, refreshes the access token periodically based on the refresh token etc.

If the user’s access token is expired, Scalekit will automatically refresh the access token using the refresh token. At any time, you can check the authorization status of the connected account and determine if the user needs to re-authorize the connection.

# If the user hasn't yet authorized the gmail connection or if the user's access token is expired, generate a link for them to authorize the connection
if(connected_account.status != "ACTIVE"):
print(f"gmail is not connected: {connected_account.status}")
link_response = actions.get_authorization_link(
connection_name="gmail",
identifier="user_123"
)
print(f"🔗click on the link to authorize gmail", link_response.link)
input(f"⎆ Press Enter after authorizing gmail...")
# In a real app, redirect the user to this URL so that the user can complete the authentication process for their gmail account

Now that the user has successfully authorized the gmail connection, you can execute tools on their behalf. For this example, let’s fetch the last 5 unread emails from the user’s inbox.

# Fetch recent emails
emails = actions.execute_tool(
#connected_account_id= connected_account.id if using multiple connectors
identifier="user_123",
tool='gmail_fetch_mails',
parameters={
'query': 'is:unread',
'max_results': 5
}
)
print(f'Recent emails: {emails.result}')

Congratulations! You’ve successfully implemented a program that executes action in real world applications on behalf of a user.

Let’s make it more interesting by implementing an AI agent that uses large language models from OpenAI or Anthropic and actually help determine which tool to be called with what parameters. Go through our Agentic Tool Calling guide to implement the same usecase using Langchain and Agent Actions.