Block offensive words when tweeting

Is it possible to block or star offensive words when tweeting?

Can you please explain what you have planned exactly. Would you for example tweet from n8n and then want the workflow to simply stop if it conains any? Or do you want to monitor an account and then delete existing tweets?

1 Like

I’ll explain the whole scenario.

I’m pulling data using HTTP Request. Then with n8n I’m tweeting.

The account is followed by many children. All of sudden. If the incoming data contains any any offensive words. It directly tweeting. I don’t want that.

If it happens. I have to login and delete the tweet.

Hope you got my point.

Can you please post an example output of the HTTP Request node.

1 Like
[ { "word": "Quassia", "definition": "Tropical tree whose bark is used to make a bitter medicinal product " } ]

Here it is.

A very basic solution would be something like this:

{
  "nodes": [
    {
      "parameters": {
        "functionCode": "items[0].json = [ \n  { \"word\": \"Quassia\", \"definition\": \"Tropical tree whose bark is used to make a bitter medicinal product \" },\n  { \"word\": \"House\", \"definition\": \"A place where people live in.\" }  \n];\nreturn items;"
      },
      "name": "Mock HTTP Request",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "const badWords = [\n  'place',\n];\n\nreturn items[0].json.filter(item => {\n  for (const badWord of badWords) {\n    if (item.word.toLowerCase().includes(badWord) || item.definition.toLowerCase().includes(badWord)) {\n      return false;\n    }\n  }\n  return true; \n}).map(item => { return {json: item} });"
      },
      "name": "Filter",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        650,
        300
      ]
    },
    {
      "parameters": {
        "text": "={{$node[\"Filter\"].json[\"word\"]}}: {{$node[\"Filter\"].json[\"definition\"]}}",
        "additionalFields": {}
      },
      "name": "Twitter",
      "type": "n8n-nodes-base.twitter",
      "typeVersion": 1,
      "position": [
        850,
        300
      ]
    }
  ],
  "connections": {
    "Mock HTTP Request": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter": {
      "main": [
        [
          {
            "node": "Twitter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
1 Like