# Matrix chatbot to process commands

**URL:** <https://discourse.nodered.org/t/matrix-chatbot-to-process-commands/85552>\
**Category:** General\
**Created:** [15 February 2024 08:57 UTC](https://discourse.nodered.org/t/matrix-chatbot-to-process-commands/85552 "2024-02-15T08:57:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![m2ts](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@m2ts](https://discourse.nodered.org/u/m2ts)\
**Post date:** [15 February 2024 08:57 UTC](https://discourse.nodered.org/t/matrix-chatbot-to-process-commands/85552/1 "2024-02-15T08:57:16Z")

</div>

Hello

Every family member has a matrix.org-account and we share a chatroom to communicate. I would like to add a chatbot to that room.

That chatbot could take action via Node-Red if some 'commands' are given. But I don't know where to start. If I search for 'matrix' I get:

- node-red-contrib-matrix, but that one was active 4 years ago and the documentation isn't that much.
- [node-red-contrib-matrix-chat](https://flows.nodered.org/node/node-red-contrib-matrix-chat) is updated 5 months ago and seems to have better documentation with examples. As a description it mentions 'Matrix chat server client', but I think I only need a Matrix client as I don't want to run my own server. It seems like overkill for my purpose. Or do I misinterpret that?
- [node-red-contrib-matrixbot](https://flows.nodered.org/node/node-red-contrib-matrixbot) is updated 3 years ago and mentions 'Matrix bot nodes for Node-RED'. The documentation isn't very elaborate, but it seems to mention the things I need:  
\*\* Matrix sender: sends messages from your Node-RED flow to the chatroom  
\*\* Matrix receiver: listens to messages in a chatroom and sends them to your Node-RED flow  
\*\* Matrix command: listens only to messages starting with a specific command and sends them to your Node-RED flow
- node-red-contrib-matrixbot-markdown is updated 3 years ago and is a fork of the previous.

What would offer me the easist way of doing things? I have Node-RED 3.0.2, node.JS v16.20.2 and npm v8.19.4.

The first thing I would like to do is my chatbot to ask every evening if I want 'domestic hot water' in the morning. Standard it would be 'no', but if one of the family members answers with yes the flow would set the desired temperature to 51 °C. The reason is that I would like to experiment with getting my 'self use' of PV power a bit higher.

---

<div class="post-metadata">

**Author:** ![Gibbz](https://avatars.discourse-cdn.com/v4/letter/g/dc4da7/32.png) [@Gibbz](https://discourse.nodered.org/u/Gibbz)\
**Post date:** [7 March 2024 12:17 UTC](https://discourse.nodered.org/t/matrix-chatbot-to-process-commands/85552/2 "2024-03-07T12:17:00Z")

</div>

Hi,

Did you find a solution? I'm looking for something similar myself. But mostly for notifications for me.

---

<div class="post-metadata">

**Author:** ![m2ts](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@m2ts](https://discourse.nodered.org/u/m2ts)\
**Post date:** [10 March 2024 08:58 UTC](https://discourse.nodered.org/t/matrix-chatbot-to-process-commands/85552/3 "2024-03-10T08:58:16Z")

</div>

@Gibbz, not yet ☹ . I'm still hoping somebody could provide some instructions...

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [10 March 2024 11:10 UTC](https://discourse.nodered.org/t/matrix-chatbot-to-process-commands/85552/4 "2024-03-10T11:10:20Z")

</div>

> [@m2ts](#):
>
> node-red-contrib-matrixbot

Did you look at the docs in that repo?

> <https://github.com/mlopezr/node-red-contrib-matrixbot/blob/master/docs/README.md#how-to-use-the-matrix-nodes-in-node-red>

There are payload examples and a flow screenshot too.

  

Also, the nodes have a little built in help:

#### matrix sender

> An output Matrix node that sends a message to a chatroom. This can be text of an image.
> 
> Sends the `msg.payload` property as text to the chatroom.
> 
> - `msg.payload`: Text to be sent
> 
> When sending an image, `msg.payload` needs the following values:
> 
> - `msg.payload["content"]`: Binary data containing the image
> - `msg.payload["raw"]`: Empty sting "" works (TODO: Not sure what this value does)
> - `msg.payload["imgType"]`: mime type of the image eg. `image/jpeg`
> - `msg.payload["type"]`: String "image"
> - `msg.payload["text"]`: String for the filename
> 
> An example:
> 
> ```
> // This should be the picture in binary format
> var binbuffer = msg.payload
> var mimetype = "image/jpeg"
> var filename = "test.jpg"
> msg.payload = { content: binbuffer,
> raw: "",
> imgType: mimetype,
> type: "image",
> text: filename
> };
> ```
> 
> In both cases, `msg.roomId` can be specified (which is filled by receiver nodes) or in the configuration node.
> 
> - `msg.roomId`: ID of the room where it was sent

#### matrix receiver

> An input Matrix node that outputs messages received in a chatroom.
> 
> Outputs a message with the properties:
> 
> - `msg.payload`: text of the received message
> - `msg.sender`: ID of the sender
> - `msg.roomId`: ID of the room where it was sent
> 
> Note: When an image is sent to the room, `msg.payload` will only contain the filename, the image itself is not received. TODO??

#### matrix command

> An input Matrix node that triggers the output when a command is received from the chatroom.
> 
> Outputs a message with the properties:
> 
> - `msg.payload`: rest of the received text (excluding the command)
> - `msg.sender`: ID of the sender
> - `msg.roomId`: ID of the room where it was sent
> - `msg.originalMessage`: text sent in the chat (including the command)

---

<div class="post-metadata">

**Author:** ![m2ts](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@m2ts](https://discourse.nodered.org/u/m2ts)\
**Post date:** [29 March 2024 19:44 UTC](https://discourse.nodered.org/t/matrix-chatbot-to-process-commands/85552/5 "2024-03-29T19:44:40Z")

</div>

@Steve-Mcl, thanks for pointing me to the docs in the repo of node-red-contrib-matrixbot. I managed to setup a quick test to send to a matrix room. I also tested 'matrix receiver' and although it seems to pick up most of the messages, it doesn't pick up every message.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [27 June 2024 19:45 UTC](https://discourse.nodered.org/t/matrix-chatbot-to-process-commands/85552/6 "2024-06-27T19:45:24Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
