Building an Interactive RCS Messaging Service with Go and Pinnacle RCS

Building an Interactive RCS Messaging Service with Go and Pinnacle RCS
Sean Roades
Sean Roades
Dec 12, 20243 min read

Rich Communication Services (RCS) is the next evolution of SMS messaging, offering enhanced features like rich media, interactive buttons, and quick replies. In this tutorial, we'll build a Go application that implements RCS messaging using the Pinnacle API, complete with media cards, quick replies, and webhook handling for interactive responses.

Pre-reqs

  • Go installed on your system
  • Basic understanding of Go programming
  • (Optional, but recommended) Your own registered agent (Register here)
  • A Pinnacle API key (Get yours here)
  • (optional) ngrok or similar tool for webhook testing

Project Setup

First, let's set up our project structure and dependencies. We'll need to install the godotenv package for environment variable management:

go mod init rcs-demo go get github.com/joho/godotenv # Used to load our .env

Create a .env file in your project root:

PINNACLE_API_KEY=your_api_key_here

Creating the Pinnacle Client

We'll start by creating a client struct to handle our API interactions:

type PinnacleClient struct {
apiKey string

I'd recommend loading your api key from the .env file using the package godotenv.

Implementing RCS Message Types

Now that we a connection to our client, we can start sending messages.

Sending a Basic Text Message

Let's start with a simple text message:

func send_basic_rcs() {
url := client.baseURL + "/send/rcs"

Once we send this, we should see a text from our agent that says "Hello, World!"

2. Quick Reply Buttons

Next, we'll add quick reply buttons that users can tap:

func send_rcs_with_quick_replies() {
payloadData := map[string]interface{}{

3. Media Cards

For rich media content, we can create cards with images or videos:

func send_rcs_media_card() {
payloadData := map[string]interface{}{

Handling Webhooks

To make our program interactive, we'll implement a webhook handler to process user responses:

func webhookHandler(w http.ResponseWriter, r *http.Request) {
// Parse incoming webhook data

If you haven't already, you'll want to start a tunnel to your local server with ngrok or something similar. For ngrok, you can run:

ngrok http 8000 # temporary ngrok http --url=your-domain.ngrok.app 8000 # permanent

You can get your free domain here with ngrok or use your domain domain.

Putting It All Together

In the main function, we initialize our client, set up the webhook endpoint, and start our initial conversation:

func main() {
// Load environment variables

Testing it out

  1. Start your application:

    go run main.go
  2. If you're testing locally, use ngrok to expose your webhook endpoint:

    ngrok http 8000
  3. Update your webhook URL in the Pinnacle dashboard with your ngrok URL.

Now what?

We've built a fully functional RCS messaging service that can:

  • Send basic text messages
  • Send messages with interactive quick reply buttons
  • Display rich media cards
  • Handle user interactions through webhooks

Try adding location requests / sends, different types of media, files, etc!

Learning more

If you want to learn more--you can check out our docs here: Pinnacle RCS docs or reach out to us via email at founders@trypinnacle.app

Join our newsletter for RCS updates