# Messages

## [sendTextMessageToDevice](https://github.com/BIoTws/biot-core/blob/master/core.js#L191)

Sending text message to device address

**Params:**

&#x20;     device\_address - **{string}** - Device address

&#x20;     text - **{string}** - Message text

{% tabs %}
{% tab title="JS module" %}

```javascript
core.sendTextMessageToDevice('0PZT5VOY5AINZKW2SJ3Z7O4IDQNKPV364', 'Hello!')
```

{% endtab %}

{% tab title="CLI" %}

```bash
biot-core sendTextMessageToDevice 0PZT5VOY5AINZKW2SJ3Z7O4IDQNKPV364 Hello!
```

{% endtab %}

{% tab title="RPC" %}

```javascript
client.request('sendTextMessageToDevice', ['0PZT5VOY5AINZKW2SJ3Z7O4IDQNKPV364', 'Hello!'], (err, data) => {
    if(err)
        throw err;

    console.log(data);
});
```

{% endtab %}

{% tab title="WS" %}

```javascript
let message_id = id++;
socket.send(JSON.stringify({
	id: message_id,
	name: 'sendTextMessageToDevice',
	args: ['0PZT5VOY5AINZKW2SJ3Z7O4IDQNKPV364', 'Hello!']
}));
```

{% endtab %}
{% endtabs %}

## [sendTechMessageToDevice](https://github.com/BIoTws/biot-core/blob/master/core.js#L203)

Sending tech message to device address

**Params:**

&#x20;     device\_address - **{string}** - Device address

&#x20;     object - **{**&#x6F;bjec&#x74;**}** - Message object

{% tabs %}
{% tab title="JS module" %}

```javascript
core.sendTechMessageToDevice('0PZT5VOY5AINZKW2SJ3Z7O4IDQNKPV364', {test: 'Hello!'})
```

{% endtab %}

{% tab title="CLI" %}

```bash
biot-core sendTechMessageToDevice 0PZT5VOY5AINZKW2SJ3Z7O4IDQNKPV364 "{\"test\":\"Hello!\"}"
```

{% endtab %}

{% tab title="RPC" %}

```javascript
client.request('sendTextMessageToDevice', ['0PZT5VOY5AINZKW2SJ3Z7O4IDQNKPV364', {test: 'Hello!'}], (err, data) => {
    if(err)
        throw err;

    console.log(data);
});
```

{% endtab %}

{% tab title="WS" %}

```javascript
socket.send(JSON.stringify({
    id: id++,
    name: 'sendTextMessageToDevice',
    args: ['0PZT5VOY5AINZKW2SJ3Z7O4IDQNKPV364', {test: 'Hello!'}]
}));
```

{% endtab %}
{% endtabs %}

## How to use?

```javascript
const eventBus = require('byteballcore/event_bus');

eventBus.on('text', (from_address, text) => {
	let objMessage;
	try {
		objMessage = JSON.parse(text);
		if (objMessage.id || objMessage.version) objMessage = null;
	} catch (e) {
	}
	
	if (objMessage) {
		// this is tech
	} else {
		// this is text
	}
});
```

{% hint style="warning" %}
In the near future, "tech" will have a separate handler
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://biot-ws.gitbook.io/biot-core/api/messages.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
