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 🙏

© 2024 – Pkg Stats / Ryan Hefner

secret-santa-twilio

v2.0.2

Published

Secret Santa over SMS with Twilio.

Downloads

18

Readme

secret-santa-twilio

Blog Post!

Secret Santa over SMS with Twilio.

Prereqs

  1. Buy a Twilio number for $1 from your console
  2. Get your API credentials from your console
  3. Make sure your Twilio account is funded enough to send your messages

Usage

# Or put this all in a config file and do either:
# `cat config.json | npx secret-santa-twilio`
# `npx secret-santa-twilio --config config.json`

npx secret-santa-twilio \
  --accountSid "ACCOUNT_SID" \
  --accountToken "ACCOUNT_TOKEN" \
  --from "+15005550006" \
  --message "Hey {{name}}, get a gift for {{recipient}}" \
  --participants '[{"name":"Alice","number":"500-555-1111"},{"name":"Bob","number":"500-555-2222"}]' \
  --dry

> Dry run: true
> Participants:
> -- Alice +15005551111
> -- Bob +15005552222
> Results:
> [
>   {
>     "status": "sent",
>     "message": {
>       "from": "+15005550006",
>       "to": "+15005551111",
>       "body": "Hey Alice, get a gift for Bob"
>     }
>   },
>   {
>     "status": "sent",
>     "message": {
>       "from": "+15005550006",
>       "to": "+15005552222",
>       "body": "Hey Bob, get a gift for Alice"
>     }
>   }
> ]

Only the resulting message sid and to phone number will be output and written to a file, so there's no chance of the person running this program seeing the results.

Env Vars

If you don't want to supply your accountSid and accountToken in the CLI args, you can set them via the TWILIO_SID and TWILIO_TOKEN environment variables or as keys in a config json file.

Config

Here's a sample of what your configuration file should look like. Use --config to specify a path to this file or pass it via stdin and it will be merged with any options from the CLI.

{
  "accountSid": "SID", // Twilio SID
  "accountToken": "TOKEN" // Twilio auth token
  "from": "+15551234567" // Twilio number to send SMS from
  // Optional message, see lib/messages.js for the default
  "message": "Hey {{name}} buy something for {{recipient}}!",
  "participants": [
    {
      "name": "Luke", // Name, must be unique
      "number": "+15005550006", // Mobile number to send SMS to
      "skip": ["Bob"] // (Optional) Array of other participant names which they cant be assigned
    },
    {
      "name": "Bob",
      "number": "+15005550006"
    },
    ...
  ]
}

Whoops, you put in a wrong phone number...

Let's say someone changed their phone number and you sent the message to their old number. Look in the results file created during your run (it should be in whatever directory you ran the program from) and find the sid associated with their old number. If you don't have the file, then you can get the sid from from the Twilio message logs. Then you can run this command to send the same message to their new number. Thank you Austin for inspiring this feature in 2019.

npx secret-santa-twilio \
  --accountSid "ACCOUNT_SID" \
  --accountToken "ACCOUNT_TOKEN" \
  --sid "MESSAGE_SID" \
  --to "+15551234567"

Tests

If you want to run the tests locally, you will need to create a .env file with TWILIO_SID and TWILIO_TOKEN test credential values.

LICENSE

MIT