Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

signalwire

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

signalwire

Client library for connecting to SignalWire.

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

SignalWire NodeJs


This package has been split in multiple packages!

If you are looking for the latest version of SignalWire for Node.js, please visit the package @signalwire/node.

This library provides a client for the Signalwire LaML and REST services.

It allows you to create calls, send messages, and generate LAML responses.

Installation

Install the package using NPM:

npm install signalwire

Usage

In order to use the client you must set the environment variable SIGNALWIRE_API_HOSTNAME!

Puts in your .env file your SignalWire host, project and token:

SIGNALWIRE_API_HOSTNAME=changeme.signalwire.com
SIGNALWIRE_API_PROJECT=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
SIGNALWIRE_API_TOKEN=PTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Setup Client

// Here we are using Project and Token from ENV
const RestClient = require('signalwire').RestClient
const client = new RestClient(process.env.SIGNALWIRE_API_PROJECT, process.env.SIGNALWIRE_API_TOKEN)

Make Call

client.calls.create({
  to: '+19999999999', // Call this number
  from: '+18888888888', // From a valid SignalWire number
  url: 'https://example.com/laml/voice.xml' // Valid LaML
}).then(call => {
  process.stdout.write('Call ID: ' + call.sid)
}).catch(error => {
  // Inspecting error...
})

Send Message

client.messages.create({
  body: 'Welcome to SignalWire!',
  to: '+19999999999', // Text this number
  from: '+18888888888' // From a valid SignalWire number
}).then(message => {
  process.stdout.write('Message ID: ' + message.sid)
}).catch(error => {
  // Inspecting error...
})

Generating LaML

const RestClient = require('signalwire').RestClient
const response = new RestClient.LaML.VoiceResponse()
response.dial({ callerId: '+18888888888' }, '+19999999999')
response.say("Welcome to SignalWire!")
process.stdout.write(response.toString())

LaML output:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Dial callerId="+18888888888">+19999999999</Dial>
  <Say>Welcome to SignalWire!</Say>
</Response>

Migration

Do you want to start using SignalWire in your current application? You can easily migrate the code with minimal changes!

Make sure you've set the env variable SIGNALWIRE_API_HOSTNAME as described in Usage and then:

To use the Rest client:

// Replace these lines:
const twilio = require('twilio')
const client = new twilio(sid, token)

// With ...
const signalwire = require('signalwire')
const client = new signalwire.RestClient(project, token)

// Now use client variable like you did before!

For calls and messages you should also change the from numbers with a valid SignalWire number!

To generate LaML:

// Replace these lines..
const twilio = require('twilio')
const response = new twilio.twiml.VoiceResponse()

// With ..
const signalwire = require('signalwire')
const response = new signalwire.RestClient.LaML.VoiceResponse()

// Now use response like you did before!
response.say('Hey, Welcome at SignalWire!')

Running tests in Docker

A Dockerfile is provided for testing purposes. Run docker run -it $(docker build -q .) to execute the test suite.

Copyright (c) 2018 SignalWire Inc. See LICENSE for further details.

Keywords

FAQs

Package last updated on 14 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc