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 Javascript
  • Prerequisites
  • Install the Javascript 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
  • Browser Compatibility

Was this helpful?

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

Javascript

PreviousAdd Messaging with Core SDKsNextGo

Last updated 2 years ago

Was this helpful?

Robin for Messaging with Javascript

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

Prerequisites

Install the Javascript SDK

npm install robin.io-js --save
yarn add robin.io-js

Sending your first message

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

Step 1: Create a Robin Instance

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

const robin = new Robin('YOUR_API_KEY', true);

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

Step 2: Connect to Robin Server

robin.connect('YOUR_RUT');

Step 3: Create a Conversation

Before sending a message, you need to create a Conversation

const response = await robin.createConversation({
  sender_name: string,
  sender_token: string,
  receiver_token: string,
  receiver_name: string
})

Step 4: Send a message to Conversation

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

robin.sendMessageToConversation(msg: object, conn: WebSocket, channel:string,conversation_id: string, senderToken?: string);

Browser Compatibility

This SDK is supported on the following browser versions.

Browser
Supported Versions

Internet Explorer

10 or higher

Edge

13 or higher

Chrome

16 or higher

Firefox

11 or higher

Safari

7 or higher

Opera

12.1 or higher

iOS Safari

7 or higher

Android Browser

4.4 (Kitkat) or higher

For this integration, you would need an 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
https://github.com/robin-io/robin.io-jsgithub.com