Robin Docs
  • Overview
  • Fundamentals
  • Messaging with Robin
    • Guides
      • How does Robin Messaging work?
      • Setting up your Robin account
      • Integrating Robin in your Nuxt.js app
      • Adding Users to your Robin App
      • What is the Robin User Token (RUT)?
      • The What and Why: Robin Keys
      • Customizing Robin for your Brand
    • SDKs for UI Kit
      • Robin with Vue
      • Robin with React
      • Robin with Flutter
    • Add Messaging with Core SDKs
      • Javascript
      • Go
      • Python
  • API Reference
  • Robin Messaging Events
  • Samples and Resources
Powered by GitBook
On this page
  • Robin for Messaging with Go
  • Prerequisites
  • Install the Go SDK
  • Sending your first message
  • Step 1: Create a Robin Instance
  • Step 2: Connect to Robin Server
  • Step 3: Create a Conversation
  • Step 4: Send a message to Conversation

Was this helpful?

  1. Messaging with Robin
  2. Add Messaging with Core SDKs

Go

PreviousJavascriptNextPython

Last updated 2 years ago

Was this helpful?

Robin for Messaging with Go

Add live messaging to your Go applications with the Core Go SDK. Take advantage of the Robin API and deploy messaging solutions in very little time.

Prerequisites

The following are required to use the SDK:

  1. Go 1.1.6 or greater is required

Install the Go SDK

go get robin.io-go

Sending your first message

Follow the step-by-step instructions below to send your first message using the Go SDK

Step 1: Create a Robin Instance

To create a Robin instance, pass the Secret as the first argument, and the optional Tls argument as the second in the Robin(Secret, Tls) constructor.

robin := Robin{
    Secret: "YOUR_API_KEY",
    Tls:    true,
}

Initializing the Chat SDK at the top of your Go file is recommended.

Step 2: Connect to Robin Server

// call back for a successful connection
func connected(socket gowebsocket.Socket) {}

// call back for an unsuccessful connection
func disconnected(err error, socket gowebsocket.Socket) {}

// call back for when a message is recieved via the connection
func text_recieved(msg string, socket gowebsocket.Socket) {}

conn, err := robin.Connect(connected, nil, disconnected, text_recieved, nil, nil, nil)

if err != nil {
    println(err)
}

Step 3: Create a Conversation

Before sending a message, you need to create a Conversation

conv, err := robin.CreateConversation("SENDER_NAME", "SENDER_TOKEN", "RECEIVER_TOKEN", "RECEIVER_NAME")

if err != nil {
    fmt.Println(err)
}

Step 4: Send a message to Conversation

Now, you can send a message to a conversation with the robin.SendMessage() method.

err := robin.SendMessage("CHANNEL_NAME", map[string]interface{} {
    "name":"SENDER_NAME",
    "user_token":"SENDER_TOKEN",
    "msg":"MSG CONTENT",
})

API Key - Learn about how to get your API Keys in

You can connect to the Robin server using the Connect(user_token) method from the Robin instance. If you do not have a (user_token), you would have to create one. (specific link to create user token) is a good place to start.

All messages sent on Robin go through channels, you can learn more about channels on

Setting up your Robin account
Robin User Token
What is the Robin User Token (RUT)?
Robin Fundamentals
GitHub - robin-io/robin.io-go: Go SDK for robinGitHub
Logo