Quotes from api to apitemplate to Twitter

Hi there,
I´m new to n8n, so maybe I will ask some beginner questions, but hopefully you can help me. As mentioned in the title, I want to buold some visual quotes and post them to Twitter.

I send a HTTP request to a free quotes api. I get “quote” and “author” back from the api. So I wanted to pass these two variables to my template in apitemplate. But I don´t know how. The textfields in the visual template have also the name “quote” and “author”. I thought the data will be passed automatically to the two textfields in my template.

Here is what I have done so far. Please be a bit patient with me, I´m not a programmer :wink: Thanks in advance for your help.

{
  "nodes": [
    {
      "parameters": {
        "url": "http://quotes.rest/qod.json",
        "responseFormat": "string",
        "options": {}
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        660,
        400
      ]
    },
    {
      "parameters": {
        "imageTemplateId": "09b77b2b123532ee",
        "download": true,
        "overridesUi": {
          "overrideValues": [
            {
              "propertiesUi": {
                "propertyValues": [
                  {
                    "key": "={{$json[\"data\"][\"contents\"][\"quotes\"][0][\"quote\"]}}",
                    "value": "quote,text"
                  }
                ]
              }
            }
          ]
        },
        "options": {
          "fileName": ""
        }
      },
      "name": "APITemplate.io",
      "type": "n8n-nodes-base.apiTemplateIo",
      "typeVersion": 1,
      "position": [
        960,
        400
      ],
      "credentials": {
        "apiTemplateIoApi": {
          "id": "3",
          "name": "APITemplate.io account"
        }
      }
    }
  ],
  "connections": {
    "HTTP Request": {
      "main": [
        [
          {
            "node": "APITemplate.io",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Hi @Floyd, welcome to the community :tada:

I have not used the create image operation of the APITemplate.io node and to be honest, it confused me a bit when I tried this. I could only get this to work when using the JSON Parameters setting:

Here’s my example workflow:

Example Workflow
{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "url": "http://quotes.rest/qod.json",
        "responseFormat": "string",
        "options": {}
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "imageTemplateId": "32977b2b12f835c6",
        "jsonParameters": true,
        "download": true,
        "overridesJson": "=[{\"name\": \"mytext\", \"text\": \"{{$json[\"quote\"]}}\" }]",
        "options": {
          "fileName": ""
        }
      },
      "name": "APITemplate.io",
      "type": "n8n-nodes-base.apiTemplateIo",
      "typeVersion": 1,
      "position": [
        900,
        300
      ],
      "credentials": {
        "apiTemplateIoApi": {
          "id": "35",
          "name": "APITemplate.io account"
        }
      }
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "quote",
              "value": "={{$json[\"data\"][\"contents\"][\"quotes\"][0][\"quote\"]}}"
            }
          ]
        },
        "options": {}
      },
      "name": "Set Quote",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        680,
        300
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Set Quote",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Quote": {
      "main": [
        [
          {
            "node": "APITemplate.io",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

In my example, the template ID used in the APITemplate.io node would be different from yours, so you’d need to select the correct one. Also, my example field in APITemplate.io is called mytext, so you would need to update this as well in the APITemplate.io node when testing my example workflow:

Hope this example nevertheless helps :slight_smile:

2 Likes

Wow @MutedJam ! Thanks for your quick response. Your reply helped me on my way. It all works so far.

Thank you in advance for all your help. Great community.

1 Like