rsf-textable
TypeScript icon, indicating that this package has built-in type declarations

1.0.19 • Public • Published

rsf-textable

A class that can send and receive text messages via twilio, that has a clean and simple speak/listen API.

In order to make this work, not only do you need to set up a twilio account, and number, but you also need to use an ngrok tunnel to your temp server, to receive webhook events. It is possible to do free of charge testing with Twilio, it just appends a little message into the text messages that it sends, which is fine for testing. This is all explained here: https://www.twilio.com/docs/sms/quickstart/node#sign-up-for-twilio-and-get-a-twilio-phone-number

Installation

npm install --save rsf-textable

Usage

You must be running an instance of rsf-twilio-bot to connect to via websockets in order for the following to work.

const { init, shutdown, Textable } = require('rsf-textable')
 
const config = {
  socketUrl: 'ws://localhost:3022'
}
init(config).then(() => {
  const person = new Textable('+12223334444')
  // log anything that we hear from them
  person.listen(console.log)
  person.speak('hello!')
 
  // after 5 seconds, shutdown/disconnect
  // person methods will no longer work, or be fired
  setTimeout(() => {
    shutdown()
  }, 5000)
})
 

Readme

Keywords

none

Package Sidebar

Install

npm i rsf-textable

Weekly Downloads

1

Version

1.0.19

License

GPL-3.0

Unpacked Size

47.1 kB

Total Files

7

Last publish

Collaborators

  • connoropolous