My First Automation:
Schedule Trigger → API Fetch → Webhook Output
1. Workflow Overview
This document covers the complete n8n automation workflow built during the tutorial. The workflow runs fully end-to-end: it automatically fires on a schedule, fetches live data from a public API, transforms that data using JavaScript, and delivers it to a webhook endpoint.
| Node | Type | Purpose |
|---|---|---|
| Schedule Trigger | Trigger | Fires every 1 minute automatically |
| HTTP Request (GET) | Action | Fetches a random joke from public API |
| Code (JavaScript) | Transform | Formats joke into clean message string |
| HTTP Request (POST) | Action | Sends formatted joke to webhook.site |
2. Prerequisites
The following are required before running this workflow:
- Node.js 18 or higher installed on your machine
- n8n running locally via
npx n8nor Docker - A free webhook.site account (no sign-up required)
- Browser access to
http://localhost:5678(the n8n editor)
npx n8nOr with Docker:
docker run -it --rm -p 5678:5678 n8nio/n8n
3. Step-by-Step Explanation
Log into your n8n editor at http://localhost:5678. From the left sidebar, click Workflows and then the + New Workflow button. You will be presented with a blank canvas. This is where your automation pipeline is built visually by connecting nodes.
- Click ‘+ New workflow’ in the top left
- Name the workflow (e.g., ‘Joke Bot’) by clicking the title at the top
- Click Save to create it
The Schedule Trigger is the entry point of the workflow. It fires automatically at a set interval without any manual action. This replaces webhooks or external event triggers when you want a time-based automation.
- Click the large ‘+’ button in the center of the canvas
- Search for ‘Schedule’ in the node panel
- Select Schedule Trigger
- In the node settings, set Trigger Interval to Every 1 Minute
- Click Save
The HTTP Request node is one of n8n’s most versatile nodes. It can call any REST API using GET, POST, PUT, DELETE, and other methods. Here it fetches a random joke from a free, public, no-auth-required endpoint.
- Click ‘+’ on the right side of the Schedule Trigger node
- Search for ‘HTTP Request’ and select it
- Set Method to GET
- Set URL to the following endpoint:
- Click ‘Test step’ — the output panel will show a JSON response
The API returns a JSON object with the following shape:
{
"id": 23,
"type": "general",
"setup": "Why did the scarecrow win an award?",
"punchline": "Because he was outstanding in his field."
}
setup and punchline fields. If you see an error, verify your internet connection and that the URL is entered exactly as shown above.
The Code node allows you to write custom JavaScript to manipulate data between nodes. It receives the output from the previous node via the built-in $input variable and must return an array of objects with a json key.
- Click ‘+’ after the HTTP Request node
- Search for ‘Code’ and select the Code node
- In the code editor, replace all existing code with the following:
const joke = $input.first().json;
return [{
json: {
message: "😂 " + joke.setup + " 👉 " + joke.punchline,
timestamp: new Date().toISOString()
}
}];
- Click ‘Test step’ to verify the output
Key concepts in this code:
$input.first().json— accesses the first item from the previous node’s JSON outputjoke.setupandjoke.punchline— are fields from the HTTP Request response- The
messagefield concatenates both fields with emoji separators timestamprecords when the joke was fetched using ISO 8601 format- The return array format is required by n8n’s Code node
\n inside the message string. Raw newline characters are invalid in JSON body fields and will cause a ‘Bad control character’ error in the HTTP POST node. Use a space or emoji separator instead.
This node sends the formatted joke to an external endpoint using an HTTP POST request. For this demo, webhook.site is used as a free, real-time receiver that confirms delivery without needing a backend server.
- Go to webhook.site in your browser — copy your unique URL from the top of the page
- Click ‘+’ after the Code node and add another HTTP Request node
- Set Method to POST
- Paste your webhook.site URL into the URL field
- Under Body Content Type, select JSON
- Under Specify Body, select Using Fields
- Add a field: Name =
text, Value ={{ $json.message }} - Click ‘Test step’
Your webhook.site dashboard will immediately show a new incoming request with the joke in the body. The request body should look like:
{
"text": "😂 Why did the scarecrow win an award? 👉 Because he was outstanding in his field."
}
{{ $json.message }}. If the message contains special characters, JSON parsing fails. ‘Using Fields’ mode lets n8n handle escaping automatically, making it safer for dynamic content.
Before activating the workflow to run automatically, test the entire pipeline manually to confirm every node executes without errors.
- Click ‘Test workflow’ in the top toolbar (not ‘Test step’)
- Watch all four nodes light up green in sequence
- Click each node to inspect its input and output data
- Verify on webhook.site that a new request appeared with the correct joke
If any node shows a red error indicator:
- Click the red node to read the error message
- For HTTP GET errors: verify the API URL is correct and you have internet access
- For Code node errors: check the JavaScript syntax carefully
- For HTTP POST errors: confirm your webhook.site URL is pasted correctly
Once the full test passes, activate the workflow so it runs automatically on the configured schedule. No manual intervention is required after this point.
- Click the toggle switch in the top-right corner of the editor
- The switch turns green and shows ‘Active’
- n8n will now fire the workflow every 60 seconds automatically
- To view execution history, click ‘Executions’ in the left sidebar
- Each run shows its status, duration, and the data that flowed through each node
4. Troubleshooting Reference
| Error | Fix |
|---|---|
| Bad control character in JSON | Remove \n from the Code node message string. Use a space or emoji separator instead of newlines. |
| This URL has no default content configured | Not an error. webhook.site received your data. Check the left panel of webhook.site for the incoming request. |
| HTTP Request: ENOTFOUND | Cannot reach the API. Check your internet connection and verify the URL spelling. |
| Code node: Cannot read property of undefined | $input.first().json is undefined. Run the HTTP GET node first so data flows in before testing the Code node. |
| Workflow not triggering automatically | Confirm the toggle in the top-right is green (Active). Check the Executions panel for failed runs. |
5. What to Build Next
Now that the first workflow is running, here are ideas to extend it or build new ones:
🔀 Swap the Destination
- Replace webhook.site with a Slack node to post jokes to a channel
- Use the Gmail node to email the joke to yourself daily
- Use the Telegram node to send to a Telegram bot
⚡ Swap the Trigger
- Change to a Webhook Trigger to fire on demand via a URL
- Use the Gmail Trigger to process new emails automatically
- Use the Cron node for complex schedules (e.g., weekdays at 9am)
🧠 Add Logic
- Add an IF node to filter jokes by type
- Add a Google Sheets node to log every joke with its timestamp
- Add error handling with an alert branch on failure
📚 n8n Resources
- Official docs: docs.n8n.io
- Node library (400+ integrations): n8n.io/integrations
- Community templates: n8n.io/workflows
- Community forum: community.n8n.io
