Public
Customer order form with SMS notifications via Twilio
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

PaperWork — Order System

A customer order form that saves orders to a database and sends you an SMS notification on every new order.

How it works

  1. Customers visit the order form URL and fill in their name, phone, product, quantity, and address.
  2. The order is saved to the val's SQLite database.
  3. You get a text message (SMS) on your phone with the order details.

URLs

RouteDescription
/Customer order form
/orderPOST endpoint that processes orders (called by the form)
/ordersView all saved orders as JSON (admin)

Setup — Twilio SMS (required for notifications)

You need a Twilio account to send SMS. Create one (free trial works) and get these three values, then add them as environment variables:

  1. TWILIO_ACCOUNT_SID — Your Twilio Account SID (found on the Twilio console dashboard)
  2. TWILIO_AUTH_TOKEN — Your Twilio Auth Token (found on the Twilio console dashboard)
  3. TWILIO_PHONE_NUMBER — Your Twilio phone number (the number Twilio assigned you, in E.164 format like +12345678900)

👉 Add TWILIO_ACCOUNT_SID here: https://www.val.town/x/omkar1/PaperWork/environment-variables?key=TWILIO_ACCOUNT_SID

👉 Add TWILIO_AUTH_TOKEN here: https://www.val.town/x/omkar1/PaperWork/environment-variables?key=TWILIO_AUTH_TOKEN

👉 Add TWILIO_PHONE_NUMBER here: https://www.val.town/x/omkar1/PaperWork/environment-variables?key=TWILIO_PHONE_NUMBER

Notification phone number

SMS notifications are sent to +1 (636) 340-2782. To change this, update OWNER_PHONE in main.ts.

Files

FilePurpose
main.tsHono HTTP handler — serves form, saves orders, sends SMS
order-form.htmlCustomer-facing order form (styled with Tailwind via Twind)
sendSMS.tsTwilio REST API helper for sending text messages