Skip to main content

SpaceStep Tool Call

AI-powered call center automation and appointment scheduling library. Designed specifically for use with AI-based voice agents.

Features

  • Call management (transfer, end call)
  • Time slot availability checking
  • Appointment booking
  • Date and time utilities

Installation

# Installation from local directory
pip install -e ./spacestep_tool_call

# Or installation from PyPI (when published)
# pip install spacestep-tool-call

Basic Usage

import asyncio
from spacestep_tool_call import book_appointment, get_available_time_slots

# Check available time slots
async def check_slots():
    dates = ["2023-06-01", "2023-06-02", "2023-06-03"]
    slots = await get_available_time_slots(dates)
    print(slots)

# Book an appointment
async def make_booking():
    result = await book_appointment(
        name="John Smith",
        email="smith@example.com",
        phone_number="+12345678901",
        selected_time_slot="2023-06-01, 14:00 - 14:30"
    )
    print(result)

asyncio.run(check_slots())
asyncio.run(make_booking())

Integration with Existing AI Voice Agent

Method 1: Direct Import Replacement (Minimal Changes)

This method allows you to use the library with minimal changes to existing code, simply by changing imports.

# Before:
from voice_agent.agent_zero.MainAgent.tools import (
    transfer_call, get_available_time_slots, book_appointment, 
    get_weekday, end_call, FUNCTION_CALLING_TOOLS
)

# After:
from spacestep_tool_call import (
    transfer_call, get_available_time_slots, book_appointment, 
    get_weekday, end_call, FUNCTION_CALLING_TOOLS
)

# The rest of the code remains unchanged

Method 2: Adapter for Voice Agent

This method uses an adapter that preserves the old interaction interface:

# voice_agent/agent_zero/MainAgent/tools.py

from spacestep_tool_call import (
    transfer_call as lib_transfer_call,
    get_available_time_slots as lib_get_available_time_slots,
    book_appointment as lib_book_appointment,
    get_weekday as lib_get_weekday,
    end_call as lib_end_call,
    FUNCTION_CALLING_TOOLS
)

# For full compatibility, we maintain the same function signatures
async def transfer_call():
    return await lib_transfer_call()

async def get_weekday(date: str):
    return await lib_get_weekday(date)

async def end_call():
    return await lib_end_call()

async def get_available_time_slots(dates):
    # Use environment variable as in the original code
    return await lib_get_available_time_slots(dates)

async def book_appointment(name, email, phone_number, selected_time_slot):
    # Use environment variable as in the original code
    return await lib_book_appointment(name, email, phone_number, selected_time_slot)

# FUNCTION_CALLING_TOOLS is already imported from the library above

Method 3: Direct Integration into Voice Agent

For maximum flexibility, you can directly integrate the library into the voice agent's code:

# voice_agent/agent_zero/MainAgent/agent.py
from spacestep_tool_call import (
    get_available_time_slots, book_appointment, 
    transfer_call, end_call, get_weekday, FUNCTION_CALLING_TOOLS
)

class VoiceAgent:
    def __init__(self):
        # Agent initialization
        self.tools = FUNCTION_CALLING_TOOLS
        
    async def handle_call(self, query):
        # Call handling logic
        # ...
        
        if "schedule appointment" in query:
            dates = ["2023-06-01", "2023-06-02", "2023-06-03"]
            available_slots = await get_available_time_slots(dates)
            # Further logic...
            
        elif "book slot" in query:
            result = await book_appointment(
                name="Client Name",
                email="client@example.com",
                phone_number=query.get("phone", ""),
                selected_time_slot=query.get("slot", "")
            )
            # Process result...
            
        elif "transfer" in query:
            await transfer_call()
            
        elif "goodbye" in query:
            await end_call()

Configuring Webhook URLs

The library supports two methods for configuring webhooks:

  1. Through environment variables (as in the original code):
import os

# Set environment variables
os.environ["TOOL_CHECK_SLOT_AVAILABILITY_WEBHOOK_URL"] = "https://example.com/check-availability"
os.environ["TOOL_BOOKING_WEBHOOK_URL"] = "https://example.com/book-appointment"

# Now functions will use these URLs
slots = await get_available_time_slots(dates)
  1. By directly passing URLs to functions:
# Direct URL passing
slots = await get_available_time_slots(
    dates=["2023-06-01", "2023-06-02"],
    webhook_url="https://example.com/check-availability"
)

# Direct URL passing for booking
result = await book_appointment(
    name="Client",
    email="client@example.com",
    phone_number="+1234567890",
    selected_time_slot="2023-06-01, 14:00 - 14:30",
    webhook_url="https://example.com/book-appointment"
)

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spacestep_tool_call-0.1.0.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spacestep_tool_call-0.1.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file spacestep_tool_call-0.1.0.tar.gz.

File metadata

  • Download URL: spacestep_tool_call-0.1.0.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for spacestep_tool_call-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d38e79c25ac4c99f998967fa39a56fec195c888f21f2dd8ea2a9d90796f1de39
MD5 46cec4e646a349b897c595c0c53d58db
BLAKE2b-256 33f3b33edbe46bdc3aa862840a88d8e6cae9a6d35d0f24ec958f3ae53b67422e

See more details on using hashes here.

File details

Details for the file spacestep_tool_call-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for spacestep_tool_call-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7696713a252641caf983d417954f12c320472050fc581216bf3ad22df6cf2a1c
MD5 fd700f365656d70eb8a7a81a5a38fbe6
BLAKE2b-256 56c6fbfe3ca235a7f65ad1eb5489643787a0be8fc579de2f084d64b06a0256e2

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page