Skip to content

Subscription service for SMS Metro updates using Temporal Workflows

Notifications You must be signed in to change notification settings

Chloe2330/sms-los-angeles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SMS Subscription Workflow (Temporal)

Set up local development environment for Temporal and Go

  1. Install Go

  2. Initialize a Go project in a new directory: go mod init

  3. Install the Temporal Go SDK

  4. Download the Temporal CLI

  5. Start a local Temporal service in a new terminal window: temporal server start-dev

Set up Twilio account, access to Metro API, and secrets

  1. Sign up for Twilio SMS

  2. Create .env file in server directory and set Twilio phone number: TWILIO_PHONE_NUMBER="+1XXXXXXXXXX"

  3. Create .env file in worker directory and set Twilio auth tokens: TWILIO_ACCOUNT_SID="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" TWILIO_AUTH_TOKEN="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

  4. Sign up for access to Metro real-time API through Swiftly, using the agency key la-metro-rail.

  5. In the .env file in worker directory, set the API key: SWIFTLY_API_KEY="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

Run the workflow

  1. Clone the repository: git clone https://github.com/Chloe2330/sms-los-angeles.git

  2. Start the server: cd server go run main.go

  3. Start the worker: cd worker go run main.go

Send requests to the server

cd sms-los-angeles

Endpoints

  1. /subscribe to daily messages, start workflow execution
curl -X POST \
  http://localhost:4000/subscribe \
  -H 'Content-Type: application/json' \
  -d '{
    "phonenumber": "+1XXXXXXXXXX"
  }'
  1. /unsubscribe from daily messages, cancel workflow execution
 curl -X DELETE 'http://localhost:4000/unsubscribe?phonenumber=1XXXXXXXXXX'
  1. /details to query information about an existing workflow
 curl 'http://localhost:4000/details?phonenumber=1XXXXXXXXXX'

About

Subscription service for SMS Metro updates using Temporal Workflows

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages