SignalWire NodeJs
This package has been split in multiple packages!
@signalwire/node.
If you are looking for the latest version of SignalWire for Node.js, please visit the packageThis 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 ENVconst RestClient = RestClientconst client = processenvSIGNALWIRE_API_PROJECT processenvSIGNALWIRE_API_TOKEN
Make Call
clientcalls
Send Message
clientmessages
Generating LaML
const RestClient = RestClientconst response = responseresponseprocessstdout
LaML output:
+19999999999 Welcome to SignalWire!
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 = const client = sid token // With ...const signalwire = const client = 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 = const response = // With ..const signalwire = const response = // Now use response like you did before!response
Running tests in Docker
A Dockerfile is provided for testing purposes. Run docker run -it $(docker build -q .)
to execute the test suite.
Copyright
Copyright (c) 2018 SignalWire Inc. See LICENSE for further details.