# Sending RCS Messages

> Sending your first RCS message with Pinnacle's Ruby SDK

## Prerequisites

Before proceeding, ensure you have obtained a phone number and API key as described in the [prerequisites](/quickstart/rcs).

## Installation

Create a Gemfile in your project root:

```ruby
source "https://rubygems.org"

gem "dotenv"
gem "rcs", "2.0.21"
```

Install the dependencies:

```bash
bundle install
```

**Info:**
  This guide uses version `rcs 2.0.21`. Requires Ruby version &gt;= 3.3.0

**Info:**
  Version `rcs 2.0.21` does not serialize top-level RCS quick replies correctly. These examples use card buttons instead. To send `quickReplies`, use the [REST API](/api-reference/messages/send-rcs) until a corrected SDK version is published.

## Configuration

Create an `.env` file in your project root and add your Pinnacle API key and RCS agent ID:

```bash
PINNACLE_API_KEY="your_api_key" # pnclk_
RECIPIENT_NUMBER="+14155550123" # Replace with your whitelisted test number
AGENT_ID="your_agent_id" # agent_
```

## Sending Your First RCS Message

Create a new Ruby file (e.g., `main.rb`) and use the [complete example](#complete-example).

Quick replies are optional. For sending media URLs, you can also use storage on the dashboard under **System > Storage** or [via our API](/api-reference/tools/upload-file)

Run the script:

```bash
ruby main.rb
```

If successful, the recipient will receive your RCS messages, and they should look something like this:

![RCS message example](/media/rcs-message-example.jpg)

## Complete example

```ruby
require "dotenv/load"
require "rcs"

client = Pinnacle::Client.new(api_key: ENV["PINNACLE_API_KEY"])

# Send a text message
text_message_res = client.messages.rcs.send_(
    text: "Want to build on Pinnacle? Check out our docs below.",
    options: { validate: true },
    from: ENV["AGENT_ID"],
    to: ENV.fetch("RECIPIENT_NUMBER")
)

puts "Text message response:"
puts text_message_res

# Send a rich card message with media and buttons
card_message_res = client.messages.rcs.send_(
    cards: [
      {
        media: "https://server.trypinnacle.app/storage/v1/object/sign/vault/142/bea70540-0596-4f9e-af6a-5b6ad7fa6c00/Golden_Hour_Over_Rural_Landscape_1.png?token=eyJraWQiOiJzdG9yYWdlLXVybC1zaWduaW5nLWtleV9hOGI0YTI0NC00NzY4LTRhOTktYWI4MS1iNmZhNTZhNGQyZWYiLCJhbGciOiJIUzI1NiJ9.eyJ1cmwiOiJ2YXVsdC8xNDIvYmVhNzA1NDAtMDU5Ni00ZjllLWFmNmEtNWI2YWQ3ZmE2YzAwL0dvbGRlbl9Ib3VyX092ZXJfUnVyYWxfTGFuZHNjYXBlXzEucG5nIiwiaWF0IjoxNzYwOTAyMjQ0LCJleHAiOjMxNzEyMDkwMjI0NH0.l0CNvb4Z-tXXEwnGA6vNWnRb4XYxvWVUUSziuqq2TLA",
        title: "Did you know you can send an RCS message in less than 5 minutes?",
        subtitle: "Learn how by tapping an option below",
        buttons: [
          {
            type: "openUrl",
            payload: "https://docs.pinnacle.sh/quickstart/rcs",
            title: "RCS Quickstart Guide"
          },
          {
            type: "openUrl",
            payload: "https://docs.pinnacle.sh/api-reference/messages/send-rcs",
            title: "RCS API Reference"
          }
        ]
      }
    ],
    options: { validate: true },
    from: ENV["AGENT_ID"],
    to: ENV.fetch("RECIPIENT_NUMBER")
)

puts "\nCard message response:"
puts card_message_res
```
