30% extra credits on top-ups within 24 hours of signup.

Integrations / CrewAI

CrewAI tools for phone calls, SMS, and email

CrewAI agents call external services through custom tools. Put the Hail SDK in one tool class. Then each agent with the tool can send SMS.

1. Install

Hail's SDK needs Python 3.11+.

pip install hail-sdk
# .env
HAIL_API_KEY="hl_live_9fa2..."
pip install crewai

2. Write the tool

CrewAI tools are synchronous and the Hail SDK is async. The tool calls the SDK through asyncio.run. The tool sets recipient_consent on each send.

import asyncio
from crewai.tools import BaseTool
from hail import Client

class SendSms(BaseTool):
    name: str = "send_sms"
    description: str = "Text an opted-in recipient."

    def _run(self, to: str, body: str) -> str:
        async def go():
            async with Client() as hail:
                sms = await hail.sms.create(
                    to=to, body=body, recipient_consent=True,
                )
                return f"queued {sms['id']}"
        return asyncio.run(go())

3. Add the tool to an agent

Put the tool in the tools list of the agent. Use the same pattern with hail.emails.create and hail.calls.create.

from crewai import Agent

support = Agent(
    role="Support agent",
    goal="Resolve orders and confirm by SMS",
    backstory="Handles order issues end to end.",
    tools=[SendSms()],
)

Questions

CrewAI tools are sync. Does the async Hail SDK still work?

Yes. Call the SDK through asyncio.run inside _run, as in the example.

Can one crew share one Hail account?

Yes. One API key covers every agent and every channel.

Run the examples

The examples above run as written with a Hail account and an API key. You pay for usage.

Create account

Guides for other frameworks