For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
SupportDashboard
DocsAPI ReferenceWebhooksMethodsUI ComponentsMCP ServerChangelog
  • Documentation
    • Introduction
    • Authentication
    • RCS Support
  • Quickstart
    • SMS
    • RCS
      • Python
      • TypeScript
        • Send
        • Receive
      • Ruby
  • Guides
    • Purchase Phone Numbers
    • Brands
    • Campaigns
    • Messages
    • Branded Test Agents
    • Handling Expired URLs
LogoLogo
SupportDashboard
QuickstartRCSTypeScript

Receiving RCS Messages

1import express from "express";
2import { Pinnacle, PinnacleClient } from "rcs-js";
3import { config } from "dotenv";
4
5config();
6
7const port = 3000;
8const app = express();
9const client = new PinnacleClient({ apiKey: process.env.PINNACLE_API_KEY });
10
11app.get("/send-rcs/:phoneNumber", async (req, res) => {
12 const { phoneNumber } = req.params;
13
14 const result = await client.messages.rcs.send({
15 options: {
16 validate: true, // Will let you know if your RCS message will fail to be sent ahead of making the request to carriers
17 },
18 from: process.env.AGENT_ID || "",
19 to: phoneNumber,
20 cards: [
21 {
22 media:
23 "https://server.trypinnacle.app/storage/v1/object/sign/vault/3/67330f56-8fc4-4d9e-882d-161b84fc8e31/Your_image_here.png?token=eyJraWQiOiJzdG9yYWdlLXVybC1zaWduaW5nLWtleV9hOGI0YTI0NC00NzY4LTRhOTktYWI4MS1iNmZhNTZhNGQyZWYiLCJhbGciOiJIUzI1NiJ9.eyJ1cmwiOiJ2YXVsdC8zLzY3MzMwZjU2LThmYzQtNGQ5ZS04ODJkLTE2MWI4NGZjOGUzMS9Zb3VyX2ltYWdlX2hlcmUucG5nIiwiaWF0IjoxNzYwOTg0OTEwLCJleHAiOjMxNzEyMDk4NDkxMH0.bcIMtiBAvV8C7Gw7uYaR5TMGsCep7w1TvRMjoRlP_-g",
24 title: "Hello, world!",
25 subtitle: "This is an example RCS message with rich content.",
26 buttons: [
27 {
28 type: "trigger",
29 metadata: "",
30 payload: "HELLO",
31 title: "Say hello back",
32 },
33 {
34 type: "sendLocation",
35 latLong: {
36 lat: 36.7749,
37 lng: -122.4194,
38 },
39 metadata: "",
40 title: "View example location",
41 },
42 ],
43 },
44 {
45 media:
46 "https://server.trypinnacle.app/storage/v1/object/sign/vault/3/67330f56-8fc4-4d9e-882d-161b84fc8e31/Your_image_here.png?token=eyJraWQiOiJzdG9yYWdlLXVybC1zaWduaW5nLWtleV9hOGI0YTI0NC00NzY4LTRhOTktYWI4MS1iNmZhNTZhNGQyZWYiLCJhbGciOiJIUzI1NiJ9.eyJ1cmwiOiJ2YXVsdC8zLzY3MzMwZjU2LThmYzQtNGQ5ZS04ODJkLTE2MWI4NGZjOGUzMS9Zb3VyX2ltYWdlX2hlcmUucG5nIiwiaWF0IjoxNzYwOTg0OTEwLCJleHAiOjMxNzEyMDk4NDkxMH0.bcIMtiBAvV8C7Gw7uYaR5TMGsCep7w1TvRMjoRlP_-g",
47 title: "Your second card",
48 subtitle:
49 "This subtitle is optional. Each card can have different buttons, like this one allowing you to share your location instead of view a location.",
50 buttons: [
51 {
52 type: "requestUserLocation",
53 metadata: "",
54 title: "Share your location",
55 },
56 ],
57 },
58 ],
59 // Quick replies are available across all cards while buttons are specific to certain cards, and only show when a user swipes to that particular card
60 quickReplies: [
61 {
62 type: "scheduleEvent",
63 title: "Add example event to cal",
64 metadata: "",
65 eventTitle: "Sample Event",
66 eventStartTime: "2025-12-11T00:00:00Z",
67 eventEndTime: "2025-12-11T23:59:59Z",
68 eventDescription: "This is an example calendar event.",
69 },
70 {
71 type: "call",
72 metadata: "",
73 payload: "+14152321234",
74 title: "Call example number",
75 },
76 {
77 type: "openUrl",
78 metadata: "",
79 payload: "https://docs.pinnacle.sh/api-reference/messages/send-rcs",
80 title: "View RCS docs",
81 },
82 ],
83 });
84
85 res.json(result);
86});
87
88app.post("/inbound-rcs", express.json(), async (req, res) => {
89 try {
90 // Process and validate the webhook
91 // Returns a fully typed MessageEvent object
92 const messageEvent: Pinnacle.MessageEvent | Pinnacle.UserEvent =
93 await client.messages.process(req);
94
95 console.log(messageEvent);
96
97 // messageEvent is now typed as Pinnacle.MessageEvent
98 // Your business logic here
99 await handleInboundMessage(messageEvent);
100
101 res.status(200).json({ message: "You received a message" });
102 } catch (error) {
103 console.error("Error occurred processing webhook message", error);
104 res.status(200).json({ message: "You received a message" });
105 }
106});
107
108async function handleInboundMessage(
109 event: Pinnacle.MessageEvent | Pinnacle.UserEvent
110) {
111 // event is fully typed with autocomplete support
112 // Your message handling logic
113 // Check if the message contains a button click with HELLO payload
114 // View full docs on processing events here: https://docs.pinnacle.sh/methods/process
115 if (event.type === "MESSAGE.RECEIVED") {
116 if (event.direction === "INBOUND") {
117 console.log("event:", event.message);
118
119 const message = event.message;
120 // Check if this is RCS button data (discriminated by type field)
121 if (
122 message.type === "RCS_BUTTON_DATA" &&
123 message.button.payload === "HELLO"
124 ) {
125 await sendHello(event.conversation.from);
126 }
127 }
128 }
129}
130
131async function sendHello(to: string) {
132 const result = await client.messages.rcs.send({
133 text: "Hello! Button clicked successfully.",
134 from: process.env.AGENT_ID || "",
135 to: to,
136 quickReplies: [],
137 });
138 console.log(result);
139}
140
141app.listen(port, () => {
142 console.log(`Server is listening on port ${port}`);
143});
Was this page helpful?
Previous

Ruby SDK Quickstart

Next
Built with

Prerequisites

Before proceeding, ensure you have obtained an RCS sandbox agent and API key as described in the prerequisites.

Installation

Initialize a new Node.js project:

$npm init -y

Install the Pinnacle TypeScript SDK, Express, and dotenv:

$npm install rcs-js express dotenv

Install development dependencies:

$npm install --save-dev @types/express @types/node tsx

This guide uses version rcs-js>=2.0.3. It’s compatible with the following runtimes: Node.js 18+, Vercel, Cloudflare Workers, Deno v1.25+, Bun 1.0+, and React Native.

Configuration

Create an .env file in your project root and add your Pinnacle API key and signing secret:

PINNACLE_API_KEY="your_api_key" # pnclk_
AGENT_ID="your_agent_id" # agent_
PINNACLE_SIGNING_SECRET="your_signing_secret" # pss_

Setting Up a Webhook

To receive inbound RCS messages, you need to configure a webhook in the Pinnacle dashboard:

  1. Navigate to Development > Webhooks in the Pinnacle dashboard
  2. Click Create new webhook
  3. Give your webhook a descriptive name
  4. Enter your webhook endpoint URL
    • For local development, use an ngrok tunnel pointing to localhost:3000/inbound-rcs
    • For production, use your deployed server URL
  5. After creation, copy the signing secret and add it to your .env file
  6. Add your RCS sandbox agent to your webhook for it to receive messages. You must also whitelist the devices you want to test with by navigating to your sandbox agent and adding test device phone numbers.

Optionally, you can configure custom HTTP headers (e.g. X-API-KEY) to be sent on every webhook delivery. Add them in the dashboard or via the headers field on POST /webhooks/attach. The PINNACLE-SIGNING-SECRET header is reserved.

Creating Your Webhook Endpoint

Create a new TypeScript file (e.g., index.ts) and add the following snippet to the right.

The code above creates an Express endpoint that:

  • Receives webhook POST requests at /inbound-rcs
  • Verifies the webhook signature using your signing secret
  • Processes incoming message events and replies to a button press by the user

Running Your Server

Start the Express server:

$npx tsx index.ts

Your server will start on http://localhost:3000. If you’re using ngrok for local development, start it in a separate terminal:

$ngrok http 3000

Use the ngrok URL (e.g., https://abc123.ngrok.io/inbound-rcs) as your webhook endpoint in the Pinnacle dashboard.

Testing Your Webhook

Go to localhost:3000/send-rcs/+12345678910 (e.g., to your whitelisted number). If there are no errors, you should see something like

1{
2 "message_ids": null,
3 "segments": 1,
4 "total_cost": 0.03,
5 "sender": "agent_exampleId",
6 "recipient": "+12345678910",
7 "status": "queued",
8 "messageId": 6828
9}

and receive a message on your whitelisted device like this: rcs message

If you’re not receiving any messages, make sure you have

  • Your RCS sandbox agent associated with your webhook
  • Your test device is whitelisted

If you tap “Say hello back”, your whitelisted device should receive a text saying “Hello! Button clicked successfully.”

With that, your webhook should now be successfully receiving inbound RCS messages as well message status updates for outbound messages! You can monitor these statuses by filtering events by their message direction set to outbound:

1if (event.type === "MESSAGE.RECEIVED" && event.direction === "OUTBOUND") {
2 console.log(event);
3}

For more detail about processing the message payload received, please view the process method.