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.
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
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
.
Now that we a connection to our client, we can start sending messages.
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!"
Next, we'll add quick reply buttons that users can tap:
func send_rcs_with_quick_replies() {
payloadData := map[string]interface{}{
For rich media content, we can create cards with images or videos:
func send_rcs_media_card() {
payloadData := map[string]interface{}{
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.
In the main
function, we initialize our client, set up the webhook endpoint, and start our initial conversation:
func main() {
// Load environment variables
Start your application:
go run main.go
If you're testing locally, use ngrok to expose your webhook endpoint:
ngrok http 8000
Update your webhook URL in the Pinnacle dashboard with your ngrok URL.
We've built a fully functional RCS messaging service that can:
Try adding location requests / sends, different types of media, files, etc!
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