Skip to content
MessageOS.ai

Developers

The Kitchen Sink: Every Kind of RCS Message in One Example App

Text it and it sends a menu. Tap a card and that kind of message arrives on your phone, with a line that names the part of the API that made it.

By MessageOS Team4 min read
Three phone screens from a conversation with the MessageOS Kitchen Sink agent: a carousel menu of demos, a vertical and a horizontal rich card, and a carousel of color cards with a Pick Teal button

The MessageOS Kitchen Sink is a small working app for a business whose own system answers its customers. Text it, and it answers with a menu. Each card on the menu runs one demo, and every demo shows one more kind of message the MessageOS API can send.

It hears each message as reply.received at a signed webhook and answers with POST /v1/messages. The Kitchen Sink showcase in the docs, now open to everyone, has a screenshot of every demo and a card for everything the app can do. The code is in a public repository at github.com/messageos/Kitchen-Sink-API-Example. Clone it, or copy what you need.

Watch it on a phone

These clips were recorded on an Android phone, in a conversation with the Kitchen Sink agent. Nothing plays until you press play, and no clip has sound.

A tap on Menu brings a carousel with one card for each demo, and one swipe moves along it.
A question with suggested replies, then the answer to a tap on Small, which carries that button's postbackData.
One message with a button for each suggested action. The row is swiped to its end, and nothing is tapped.
A vertical rich card arrives, then a horizontal one, each a message of its own.
Three cards sent as a carousel, swiped from the first to the last. Each button names its own item.
The typing dots show while the app waits two seconds, then the answer arrives.

Ten demos, one tour

Every demo ends with a Next: <name> button for the demo after it and a Menu button, so you can walk all ten in order. The last one ends with Menu alone.

DemoWhat arrives on the phoneThe API behind it
TextA plain text messagetext
RepliesText with buttons to tap as an answersuggestions of type reply, each with its own postbackData
ActionsText with a button for every actionopenUrl (webview and browser), dial, viewLocation, shareLocation, createCalendarEvent
CardA vertical rich card, then a horizontal onecard with orientation and thumbnailAlignment
CarouselThree cards to swipe, each with its own buttoncarousel with cards
FilesAn image, a video, an audio file, or a PDFfile.url, and file.thumbnailUrl for the video
LocationA button that asks for a locationA shareLocation suggestion, answered as reply.received with location
TypingThe typing indicator, then a messagePOST /typing, a two second pause, POST /messages
ExpiryA text that expires, with a declared traffic typettlSeconds and trafficType
Device checkA short list of what this phone supportsGET /capabilities

It also answers what a person sends on their own. A typed word brings the menu or runs a demo, a photo or a file is answered with what arrived, a shared place is answered with its coordinates and a View on map button, and anything else is echoed back. STOP, START, HELP, and the other keywords get nothing from the app, because MessageOS answers them itself.

The hard parts of a receiver, done for you to copy

The receiver is one route, and it follows five rules in order, each marked in the code:

  1. Read the raw body. The signature covers the exact bytes MessageOS sent.
  2. Check the signature in constant time. HMAC-SHA256 of the timestamp, a period, and the raw body, keyed with the webhook's signing secret.
  3. Refuse a timestamp more than 300 seconds off, so a captured request cannot be played back later.
  4. Never act twice on one event. Every send carries an Idempotency-Key built from the person's message, so a redelivered event sends nothing new.
  5. Answer 2xx only when the work is done. It sends first and answers 200 after. When a send is worth another try, it answers 500 and MessageOS delivers the event again, which rule 4 makes safe.

Every answer names the person's message in inReplyTo, so it counts as a reply, and no demo sends more than three messages. The last message of every answer carries at least a Menu button, so a person always has something to tap.

The app also reads GET /v1/whoami and adapts to your agent. Where rich messages or the extra features are not turned on, it says so in one plain line instead of failing.

Run it yourself

It is plain JavaScript for Node 20 or newer, with no runtime dependencies. You need three things:

  • Node 20 or newer.
  • A MessageOS client key, made by an owner or admin of your brand in the dashboard under Developers, with messages:write, contacts:read, contacts:write, conversations:read, webhooks:manage, and usage:read.
  • A phone the agent can reach. Until your agent is launched, it reaches only the phones MessageOS has added as its testers.

The app answers every message itself, so the MessageOS assistant must not answer too. Ask MessageOS to set your agent to API only, or pause the assistant on the Agent page of the dashboard.

Then, from the repository:

  1. npm install, then copy .env.example to .env and put your key in it.
  2. npm run check calls GET /whoami and prints what your key and your agent offer.
  3. Give the app a public https address, such as a tunnel to your own computer, and set it as PUBLIC_URL.
  4. npm start runs the app.
  5. npm run setup:webhook registers the webhook and prints its signing secret once. Put it in .env and start the app again.
  6. npm run send:menu -- +15555550123, with your own number in place of the sample one, sends the menu to your phone.

npm test runs every test with no network and no key. The example app page has the full setup.

See your own brand next

The Kitchen Sink shows what the API can send. To see what your own brand looks like in RCS, with your logo, your name, and a card drafted from your website, enter your website and the preview arrives on your own phone.

About a minute

See your branded text message on your own phone.

Enter your website. We draft a verified business profile and a first message from what your site says, and send it to your phone.