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

@sinch/functions-runtime

v0.1.0-beta.28

Published

Development runtime for Sinch Functions - serverless voice applications

Readme

@sinch/functions-runtime

Development runtime for Sinch Functions - build serverless voice applications with ease.

Installation

npm install @sinch/functions-runtime

Quick Start

Create a function.js file:

import { IceSvamlBuilder, MenuBuilder, MenuTemplates } from '@sinch/functions-runtime';

// Handle incoming calls
export async function ice(context, event) {
  return new IceSvamlBuilder()
    .say('Welcome to our service! Press 1 for sales, 2 for support.')
    .runMenu(MenuTemplates.business('Acme Corp').menus)
    .build();
}

// Handle menu selections
export async function pie(context, event) {
  const selection = event.menuResult?.value;

  if (selection === 'sales') {
    return new IceSvamlBuilder()
      .say('Connecting you to sales.')
      .connectPstn('+15551234567')
      .build();
  }

  return new IceSvamlBuilder()
    .say('Goodbye!')
    .hangup()
    .build();
}

Run locally:

npx sinch-runtime

Features

SVAML Builders

Build voice responses with a fluent API:

import { IceSvamlBuilder, AceSvamlBuilder, PieSvamlBuilder } from '@sinch/functions-runtime';

// ICE (Incoming Call Event) - handle incoming calls
const iceResponse = new IceSvamlBuilder()
  .say('Hello, welcome!')
  .connectPstn('+15551234567', {
    cli: '+15559999999',
    enableAce: true,
    enableDice: true
  })
  .build();

// ACE (Answered Call Event) - handle answered outbound calls
const aceResponse = new AceSvamlBuilder()
  .say('The call has been answered.')
  .continue()
  .build();

// PIE (Prompt Input Event) - handle user input
const pieResponse = new PieSvamlBuilder()
  .say('You pressed ' + selection)
  .hangup()
  .build();

Menu Builder

Create IVR menus with validation:

import { MenuBuilder, MenuTemplates, createMenu } from '@sinch/functions-runtime';

// Use pre-built templates
const businessMenu = MenuTemplates.business('Acme Corp');
const yesNoMenu = MenuTemplates.yesNo('Do you want to continue?');

// Or build custom menus
const customMenu = new MenuBuilder()
  .prompt('Press 1 for English, 2 for Spanish')
  .option('1', 'menu(english)')
  .option('2', 'menu(spanish)')
  .addSubmenu('english')
  .prompt('Press 1 for sales, 2 for support')
  .option('1', 'return(en-sales)')
  .option('2', 'return(en-support)')
  .build();

Cache

Store and retrieve data across function invocations:

import { LocalCache } from '@sinch/functions-runtime';

// In your function
export async function ice(context, event) {
  const cache = context.cache;

  // Store data
  await cache.set('call-count', 1, 3600); // TTL in seconds

  // Retrieve data
  const count = await cache.get('call-count');

  // Check existence
  if (await cache.has('call-count')) {
    // ...
  }
}

Configuration

Access environment variables and secrets:

import { createConfig } from '@sinch/functions-runtime';

export async function ice(context, event) {
  const config = createConfig(context);

  // Get variables
  const companyName = config.getVariable('COMPANY_NAME', 'Default');

  // Get secrets
  const apiKey = config.getSecret('API_KEY');

  // Require variables (throws if missing)
  const required = config.requireVariable('IMPORTANT_VAR');
}

Voice Callbacks

| Callback | Description | Returns | |----------|-------------|---------| | ice | Incoming Call Event - first callback for incoming calls | SVAML | | ace | Answered Call Event - when outbound call is answered | SVAML | | pie | Prompt Input Event - user input (DTMF/voice) | SVAML | | dice | Disconnected Call Event - call ended | None | | notify | Notification events | None |

TypeScript Support

Full TypeScript support with comprehensive types:

import type {
  FunctionContext,
  IceCallbackData,
  AceCallbackData,
  PieCallbackData,
  SvamletResponse
} from '@sinch/functions-runtime';

export async function ice(
  context: FunctionContext,
  event: IceCallbackData
): Promise<SvamletResponse> {
  // Full type safety and IntelliSense!
}

API Reference

Builders

  • IceSvamlBuilder - Build ICE responses
  • AceSvamlBuilder - Build ACE responses
  • PieSvamlBuilder - Build PIE responses
  • MenuBuilder - Build IVR menus
  • MenuTemplates - Pre-built menu templates

Cache

  • IFunctionCache - Cache interface
  • LocalCache - In-memory cache (development)

Configuration

  • UniversalConfig - Configuration utility
  • createConfig() - Create config instance

Types

All callback data types, SVAML types, and handler types are exported for TypeScript users.

License

MIT