slack-texts
Receive text messages for conversations on Slack channels via Twilio. Available on npm.
Contents
Usage
Gettin started is really easy. Install slack-texts via npm:
$ npm install --save slack-texts
Use it in your project:
// app.js
var slack_texts = require('slack-texts');
// Specify your Slack and Twilio keys
var keys = {
slack: { token : "<SLACK-TOKEN>" },
twilio: {
sid: "<TWILIO-SID>",
token: "<TWILIO-TOKEN>",
phone: "<TWILIO-PHONE>"
}
};
// Configuration
var options = {
team_name: 'go-team',
ignore_case_keywords: true,
print_intro: false,
keywords: [ 'economy', 'responsive' ],
channel_names_to_monitor: [ 'announcements', 'development' ],
send_to_contacts:
[ { phone: '+10000000000' },
{ phone: '+19999999999' },
{ phone: '+15555555555' } ]
};
// Initialize & start
var st = slack_texts.init(keys, options);
st.start();
// Do other things ...
Run:
$ node app.js --harmony
Since the module uses es6 features, please use the --harmony
flag to run until node supports es6 features by default.
Features
- Specify phone numbers to send messages to.
- Monitor a specific list (or all) channels
- Allow only messages that contain specific keywords
Documentation
Methods:
slack_texts.init(..)
Initializes and returns a slack_texts instance. (It is a wrapper around a new slack_texts(..)
call). The methods has two arguments:
keys
The first argument ofslack_texts.init(..)
should contain Twilio and Slack API keys as in the example above. All properties in the keys object from the example are required.options
The second argument ofslack_texts.init(..)
has more interesting properties:team_name
String of the team name to mention in the text messages. (optional, default: "")ignore_case_keywords
Boolean indicating whether to ignore case when filtering messages by keyword. (optional, default: true)print_intro
Boolean indicating whether to print introductory information on start up. (optional, default: false)keywords
Array of Strings of the keywords to filter messages by. If a message contains at least one of the keywords, it will be used for text notifications. To disable keyword filtering, either ignore the property or pass in an empty array. (optional, default: [])channel_names_to_monitor
Array of Strings of the keywords of the channels to listen to. If a new message is sent on these channels, it will be used for text notifications. To listen to all channels, either ignore the property or pass in an empty array. (optional, default: [])send_to_contacts
Array of Objects, with each object containing aphone
property that is a phone number String. Any messages that meet the criteria above are sent as text messages to these phone numbers.
slack_texts.start()
Starts listening for messages asynchronously. The method has no arguments.
Dependencies
The following modules are required and are pulled automatically by installing slack-texts:
- ws
- querystring
- twilio
- request
Contributing
Pull requests are welcome.
- Fork the repository
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create new Pull Request
You can also create an issue for new features and bug fixes.
License
The MIT License. Please see the LICENSE file at the root of this repository.
Log in or sign up for Devpost to join the conversation.