Code Monkey home page Code Monkey logo

serverless-twilio-dictionary's Introduction

Serverless Twilio Dictionary

A serverless dictionary completely hosted in a Twilio account.

Architecture

architecture

The backend architecture has been implemented using the following four services:

Prerequisites

Setup

  1. Install npm dependencies

    npm install
  2. Install the @twilio-labs/plugin-serverless plugin

    npx twilio plugins:install @twilio-labs/plugin-serverless
  3. Log in to your Twilio account

  4. Buy a Twilio phone number, take note of the number.

  5. Rename the .env.twilio.example file to just .env.twilio

  6. Copy the values of ACCOUNT_SID, AUTH_TOKEN and the TWILIO_NUMBER (i.e. the phone number that you bought earlier) to the .env.twilio file

  7. Important: do not add the .env.twilio file to version control because it contains your Twilio account credentials

  8. Execute the ./scripts/setup.sh script, take note of the url output after

    Setup complete! See landing page url for more instructions: [landing page url]

  9. Optional, you can seed the dictionary with some entries using the ./scripts/upload.sh script

  10. You can verify the deployment by opening the [landing page url] mentioned in step 8 above. You will see your Twilio phone number as well as links to your Twilio Sync Service and Twilio Functions in your Twilio account where these services have been deployed.

After the initial deployment you can execute the following command to update your function:

npx twilio-run deploy

Usage

After installation, you can interact with the dictionary by sending SMS CRUD (create, read update and delete) commands to you Twilio phone number:

[command] key [definition]

  • There are four commands (see list below). You can use either the full command or just a single character abbreviation. If omitted, the command defaults to read.
  • The key is the dictionary entry and one must be provided with all dictionary interactions.
  • The definition part is used when creating or updating the meaning of different words.
Command Abbreviation Comment
create c Creates a new entry in the dictionary
read r Reads an entry from dictionary (default command)
update u Updates a dictionary entry
delete d Deletes a dictionary entry

Examples:

create TLA Three Letter Acronym

Adds the entry TLA with the definition Three Letter Acronym to the dictionary

read TLA

or just

TLA

reads the value of the TLA entry.

For convenience, the service also has a public API endpoint and you can use the ./scripts/post.sh script and the same command syntax as above to send commands, e.g.

./scripts/post.sh delete TLA

Clean Up

Execute the ./scripts/teardown.sh script

References

Developer Resources Online

CLI Tools

Tool Example Reference
Twilio CLI tool npx twilio --help twilio
Twilio Run CLI tool npx twilio-run --help twilio-run
Twilio Serverless CLI plugin npx twilio-run serverless --cwd . plugin-serverless

Acknowledgements

Thanks to Stefan Judis for support. Please also see his GitHub repo for a demo implementation of s Twilio SMS Serverless group chat.

serverless-twilio-dictionary's People

Contributors

matsev avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.