A serverless dictionary hosted on AWS with Twilio account integration that enables SMS communication.
After installation, you can interact with the dictionary using the following syntax:
[command] word [definition]
There are four commands (see list below). If omitted, the command defaults to read
. The word
is the dictionary key 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
r TLA
or just
TLA
reads the value of the TLA
entry
The phone sends an SMS message to the Twilio platform which in turn performs a HTTP request to the serverless dictionary in the AWS cloud. The HTTP response from the serverless dictionary is then translated back to text by the Twilio platform before it sends it back to the phone as another SMS message. Consequently, the Twilio platform is responsible for phone the phone interaction and the AWS part is responsible for the providing HTTP communication, application logic and storage. Consequently, the AWS parrts consists of a HTTP API that forwards the request to a Lambda function, which in turns communicate with a DynamoDB table.
- An AWS account
- AWS CLI installed and configured
- Node.js version 12.x (see .nvmrc) if you are using nvm
- Clone the project
- Install the dependencies:
$ npm install
- Compile the AWS CDK TypeScript to JavaScript:
npm run build
- Synthesize and deploy the infrastructure to AWS CloudFormation:
npx cdk deploy
- Take note of the
ServerlessDictionaryStack.PublicDomainName
output value as this will be used later - Verify that the serverless dictionary was deployed successfully by executing the post.sh script, e.g.
./post.sh "create TLA Three Letter Acronym"
- Go to the https://www.twilio.com and create an account
- Get a Twilio Phone Number
- In the phone number's configuration options, find the
Messaging
part- Find the
A Message Comes In
section - Change the value to
Webhook
- Configure the value of
ServerlessDictionaryStack.PublicDomainName
as mentioned earlier as webhook URL. Hint, if you forgot to copy it, you can find it in the outputs of your CloudFormation stack in the AWS Console Please see details at Configure a Webhook URL.
- Find the
The project infrastructure is based on the AWS CDK. The cdk.json file tells the CDK Toolkit how to execute your app. For more information, execute the npx cdk help
.
npm run build
compile typescript to jsnpm run watch
watch for changes and compilenpm run test
perform the jest unit testscdk deploy
deploy this stack to your default AWS account/regioncdk diff
compare deployed stack with current statecdk synth
emits the synthesized CloudFormation template