Make a string and save

Hello guys.
I want to make a string from inputs but … .
i have set twitter api to get tweets.then extract title, date, user and make a string.then save it as a txt file.
but i don’t know what to put after twitter node.
i want to make something like this for output :

There is tweet from {{$json["user"]["screen_name"]}} :
text : {{$json["full_text"]}}
link : https://twitter.com/{{$json["user"]["screen_name"]}}/status/{{$json["id_str"]}}

thanks.

Information on your n8n setup

  • n8n version: latest
  • Database you’re using (default: SQLite): dafault
  • Running n8n with the execution process [own(default), main]: own
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: Docker, ubuntu 20

Hi @rhodesgod

You can use the Write Binay File node to save the text into the file.

Please note that, I have used Set node instead of Twitter Node (Just for the example)

This node needs two parameters.

image

You can edit the file path under the Final Name and leave the Property Name as it is. (Which can be later used, If you want to access the file in other nodes within the Workflow.)

Hope it helps.

1 Like

thanks.but i know how to save the file.

i don’t know how to make string from twitter output and make it as input for txt file.
which node should i use?
it gets some data from twitter output. put the information in a sentence and send the result as output for saving in txt file

thats the problem

1 Like

What exactly you wanna save as string? You will need to manipulate data probably with function node. Share your workflow and let us know what needs to be save as txt file

Hey @rhodesgod,

Looking at what you want to do the example at the bottom should cover it.

So I have a set node to Fake the data to match what you are sending so consider that your Twitter node, The Next set node uses the data to build out the message to save in the text file. Next up is to convert the JSON data to Binary data using the Move Binary Data node then we end by using the Write Binary Data node to save the file wherever you want it.

Example Workflow
{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        240,
        280
      ]
    },
    {
      "parameters": {
        "mode": "jsonToBinary",
        "convertAllData": false,
        "sourceKey": "textToSave",
        "options": {
          "useRawData": true
        }
      },
      "name": "Move Binary Data",
      "type": "n8n-nodes-base.moveBinaryData",
      "typeVersion": 1,
      "position": [
        800,
        280
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "user.screen_name",
              "value": "joffcom"
            },
            {
              "name": "full_text",
              "value": "here is my text"
            },
            {
              "name": "id_str",
              "value": "some-id"
            }
          ],
          "boolean": []
        },
        "options": {}
      },
      "name": "Fake Data",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        420,
        280
      ]
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "textToSave",
              "value": "=There is tweet from {{$json[\"user\"][\"screen_name\"]}} :\ntext : {{$json[\"full_text\"]}}\nlink : https://twitter.com/{{$json[\"user\"][\"screen_name\"]}}/status/{{$json[\"id_str\"]}}"
            }
          ]
        },
        "options": {}
      },
      "name": "Create file data",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        600,
        280
      ]
    },
    {
      "parameters": {
        "fileName": "/files/data;txt"
      },
      "name": "Write Binary File",
      "type": "n8n-nodes-base.writeBinaryFile",
      "typeVersion": 1,
      "position": [
        1000,
        280
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Fake Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Move Binary Data": {
      "main": [
        [
          {
            "node": "Write Binary File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fake Data": {
      "main": [
        [
          {
            "node": "Create file data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create file data": {
      "main": [
        [
          {
            "node": "Move Binary Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

The only problem you may have depending on your setup is if the Path you use for the Write Binary File exists and is available to your docker container.

1 Like

thanks.
Create file data node is what i wanted.
solved

1 Like