# Parsing text sent from Telegram

**URL:** <https://discourse.nodered.org/t/parsing-text-sent-from-telegram/59230>\
**Category:** General\
**Tags:** node-red-dashboard, telegram\
**Created:** [2 March 2022 11:45 UTC](https://discourse.nodered.org/t/parsing-text-sent-from-telegram/59230 "2022-03-02T11:45:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CerealPort](https://avatars.discourse-cdn.com/v4/letter/c/db5fbb/32.png) [@CerealPort](https://discourse.nodered.org/u/CerealPort)\
**Post date:** [2 March 2022 11:45 UTC](https://discourse.nodered.org/t/parsing-text-sent-from-telegram/59230/1 "2022-03-02T11:45:08Z")

</div>

Hi all, I've been using Node-Red for a few months for a school project, and it's great.

I'm trying to do something that is probably simple, but I don't even know what terms to search for.

I want to write simple text messages on my phone, and have Node-RED record them in a database. I already got the database working, I'm just having trouble using and parsing what I get from Telegram.  
So, for example, I want to record that I just let my cat Plump out (he's old and can't jump, so he stays in front of the door when it's sunny, and he doesn't wander away. He knocks on the door when wants back in)

So, I type "Plump out" on my phone, and a debug node after the Telegram receiver node in Node-RED outputs this:

![Screenshot 2022-03-02 at 11.35.53](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/d/dd5de4f1aecb95e4b5b08eb7daf5e4eda452150e.jpeg)

Object  
chatId: 8xxxxxx0  
messageId: 42  
type: "message"  
content: " **Plump out**"  
date: **1646220823**

The question is: how do I get the "Plump out" and the timestamp parts to use them in say a switch node and in other functions and to log it into my db?

Thanks!

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [2 March 2022 11:56 UTC](https://discourse.nodered.org/t/parsing-text-sent-from-telegram/59230/2 "2022-03-02T11:56:26Z")

</div>

You need to read this page and pay attention to `When you hover over any element, a set of buttons appear on the right:` This will show you how to get the paths to the valuesfrom your object.

[https://nodered.org/docs/user-guide/messages](https://nodered.org/docs/user-guide/messages)

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [2 March 2022 11:57 UTC](https://discourse.nodered.org/t/parsing-text-sent-from-telegram/59230/3 "2022-03-02T11:57:02Z")

</div>

So you need to translate the incoming msg into one suitable for the DB node that you are using.

Sharing the db node you want to use would help here as we could advise on the correct format. If your DB supports "prepared" statements, you should use those so that your input is relatively safe being fed into the table. You should also ALWAYS sanitise any external input before trying to feed it to the table.

To get to the text content in the example you have given, you would need to use `msg.payload.content` since Node-RED uses JavaScript conventions throughout.

---

<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:** [1 May 2022 11:57 UTC](https://discourse.nodered.org/t/parsing-text-sent-from-telegram/59230/4 "2022-05-01T11:57:28Z")

</div>

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