npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@tooly/twilio

v0.0.7

Published

Twilio API tools for OpenAI, Anthropic, and AI SDK

Readme

@tooly/twilio

Twilio API tools for AI applications, compatible with OpenAI function calling, Anthropic tool use, and AI SDK.

Installation

npm install @tooly/twilio
# or
yarn add @tooly/twilio
# or
pnpm add @tooly/twilio

Setup

Get your Twilio Account SID and Auth Token from your Twilio Console.

Usage

Basic Usage

import { TwilioTools } from '@tooly/twilio'

const twilio = new TwilioTools('your-account-sid', 'your-auth-token')

// Get available tools for function calling
const tools = twilio.getTools()

// Execute a function
const result = await twilio.executeFunction('sendSms', {
  to: '+1234567890',
  body: 'Hello from Twilio!',
  from: '+0987654321',
})

AI SDK

import { createAITools } from '@tooly/twilio'

const tools = createAITools('your-account-sid', 'your-auth-token')

// Use with generateText
import { generateText } from 'ai'

const result = await generateText({
  model: openai('gpt-4-turbo'),
  messages: [{ role: 'user', content: 'Send an SMS to +1234567890 saying hello' }],
  tools,
})

OpenAI Function Calling

import { createOpenAIFunctions } from '@tooly/twilio'

const { tools, executeFunction } = createOpenAIFunctions('your-account-sid', 'your-auth-token')

// Use with OpenAI client
const completion = await openai.chat.completions.create({
  model: 'gpt-4-turbo',
  messages: [{ role: 'user', content: 'Make a call to +1234567890' }],
  tools,
})

// Execute function calls
for (const toolCall of completion.choices[0].message.tool_calls || []) {
  const result = await executeFunction(toolCall.function.name, JSON.parse(toolCall.function.arguments))
}

Anthropic Tool Use

import { createAnthropicTools } from '@tooly/twilio'

const { tools, executeFunction } = createAnthropicTools('your-account-sid', 'your-auth-token')

// Use with Anthropic client
const message = await anthropic.messages.create({
  model: 'claude-3-sonnet-20240229',
  messages: [{ role: 'user', content: 'Send a WhatsApp message' }],
  tools,
})

// Execute tool calls
for (const toolUse of message.content.filter((c) => c.type === 'tool_use')) {
  const result = await executeFunction(toolUse.name, toolUse.input)
}

Available Tools

  • sendSms - Send SMS text messages
  • sendWhatsApp - Send WhatsApp messages
  • makeCall - Make phone calls with TwiML
  • getCallStatus - Get call status and details
  • getMessageStatus - Get message status and details
  • listMessages - List messages with filtering
  • listCalls - List calls with filtering
  • getPhoneNumber - Get phone number details and validation

Examples

Send SMS

await twilio.executeFunction('sendSms', {
  to: '+1234567890',
  from: '+0987654321',
  body: 'Hello from Twilio!',
})

Make a Call

await twilio.executeFunction('makeCall', {
  to: '+1234567890',
  from: '+0987654321',
  url: 'https://your-server.com/twiml',
})

Send WhatsApp Message

await twilio.executeFunction('sendWhatsApp', {
  to: 'whatsapp:+1234567890',
  from: 'whatsapp:+0987654321',
  body: 'Hello via WhatsApp!',
})

Get Phone Number Details

await twilio.executeFunction('getPhoneNumber', {
  phoneNumber: '+1234567890',
})

License

MIT