---
# System prepended metadata

title: Short Code

---

Short Code

### javascript
```javascript!

import sdk from "sendingnetwork-js-sdk";

const base_url = 'https://portal0101.sending.network';
const user_id = "USER_ID";
const access_token = "ACCESS_TOKEN";
const room_id = "THE_ROOM_ID";

// create client
const client = sdk.createClient({
  baseUrl: base_url,
  userId: user_id,
  accessToken: access_token,
})

// send text message
client.sendEvent(room_id, "m.room.message", {
  "body": "Hello World",
  "msgtype": "m.text"
}).then((res) => {
  console.log("send message success");
}).catch((err) => {
  console.log(err);
})
```

### Android(Java)
```java
package com.sending.example;

import com.sending.sdk.Client;
import com.sending.sdk.models.LoginData;

public class Main {
    public static void main(String[] args) {

        var baseUrl = "https://portal0101.sending.network"; // url of the server node
        var userId = "USER_ID"; // current user id
        var accessToken = "ACCESS_TOKEN"; // get access token from login
        var deviceId = ""; // optional device id, can be empty
        var roomId = "THE_ROOM_ID"; // the room id

        // create client and set login data
        Client client = new Client(baseUrl);
        var loginData = new LoginData(
                true, // set login success
                baseUrl,
                userId,
                accessToken,
                deviceId
        );
        client.setLoginData(loginData);

        // send text message
        try {
            String eventId = client.sendMessage(roomId, "Hello World");
            System.out.println("send message success: " + eventId);
        } catch (Exception e) {
            System.err.println("send message error: " + e.getMessage());
        }
    }
}
```

### Golang

```go
package main

import (
	sdnclient "github.com/sending-network/sendingnetwork-bot"
	log "github.com/sirupsen/logrus"
)

const (
	baseUrl     = "https://portal0101.sending.network"
	userId      = "USER_ID"
	accessToken = "ACCESS_TOKEN"
	roomId      = "THE_ROOM_ID"
)

func main() {
	// create client
	client, err := sdnclient.NewClient(&sdnclient.Config{
		Endpoint:    baseUrl,
		UserID:      userId,
		AccessToken: accessToken,
	})
	if err != nil {
		log.Fatal(err)
	}

	// send text message
	resp, err := client.SendText(roomId, "Hello World")
	if err != nil {
		log.Errorf("send message error: %v\n", err)
	} else {
		log.Infof("send message success: %s\n", resp.EventID)
	}
}

```

### js Widget

1. Import the dependency files in your HTML page.
```javascript
<script src="/your url/sdnChatWidget.js"></script>
```

2. Import the widget.
```javascript
<chat-component baseUrl="SERVER URL" />
```
