[n8n] ์์ ์ฌ์ง์ผ๋ก ์๋จ ๊ธฐ๋กํ๋ AI ํ ๋ ๊ทธ๋จ ๋ด ๋ง๋ค๊ธฐ
๐ฏ ์ํฌํ๋ก์ฐ ๋ชฉํ
- ํ ๋ ๊ทธ๋จ ๋ด์ผ๋ก ์์ ์ฌ์ง ์ ๋ก๋
- AI๊ฐ ์นผ๋ก๋ฆฌ, ํ์ํ๋ฌผ, ๋จ๋ฐฑ์ง, ์ง๋ฐฉ ๋ถ์
- ๋ถ์ ๊ฒฐ๊ณผ ๊ตฌ๊ธ ์ํธ์ ๊ธฐ๋ก > ํ ๋ ๊ทธ๋จ์ผ๋ก ์๋ต
- ํ์ ์ ๊ตฌ๊ธ ์ํธ ๋ฐ์ดํฐ ์กฐํ > ์ญ์ทจ๋ ์์ฝ

ํ ๋ ๊ทธ๋จ ํธ๋ฆฌ๊ฑฐ ๋ ธ๋
๋จผ์ ํ ๋ ๊ทธ๋จ @BotFather์์ ์นผ๋ก๋ฆฌ ํธ๋์ปค ์ ์ฉ ๋ด์ ๋ง๋ค์ด๋๋ค(๋ด ์์ฑ ์ฐธ๊ณ ๋ด์ฉ).
๋ค์ n8n์ผ๋ก ๋์์์ ๋จ์ถํค n > Telegram > On message ํธ๋ฆฌ๊ฑฐ ๋
ธ๋๋ฅผ ์ถ๊ฐํ๋ค. ํธ๋ฆฌ๊ฑฐ ์ค์ ์ฐฝ์ ์ด๊ณ Credential ์ฐฝ > Access Token ํ๋์๋ ์นผ๋ก๋ฆฌ ํธ๋์ปค ๋ด์ ํ ํฐ ๊ฐ์ ์
๋ ฅํ๋ค.

Trigger On ํญ๋ชฉ์ Message๋ฅผ ์ ํํ ํ, ์ฒจ๋ถํ์ผ ๋ฐ์ดํฐ๋ฅผ ๋ฐ์์ฌ ์ ์๋๋ก Add Field > Download Image/Files ํ๋๋ฅผ ์ถ๊ฐํ๊ณ ํ์ฑํํ๋ค. ์ด์ ํ ๋ ๊ทธ๋จ ๋ด์ผ๋ก ์ด๋ฏธ์ง๋ฅผ ๋ณด๋ธ ๋ค Execute step ๋ฒํผ์ ๋๋ฌ ๋ณด์. ์ฐ์ธก OUTPUT ์ฐฝ์ Binary ํ์ผ์ด ํ์๋๋ค๋ฉด ์ฑ๊ณต์ด๋ค.

AI Agent ๋ ธ๋
ํ
๋ ๊ทธ๋จ์์ ๋ฐ์์จ ์์ ์ฌ์ง์ AI๊ฐ ๋ถ์ํ์ฌ ์์ ์ฑ๋ถ์ ๊ณ์ฐํ ๋จ๊ณ๋ค. ์ด๋ฏธ์ง๋ฅผ ์ธ์ํด์ผ ํ๋ฏ๋ก Vision ๊ธฐ๋ฅ์ ์ง์ํ๋ ๋ชจ๋ธ์ ์ฌ์ฉํด์ผ ํ๋ค. ๋จ์ถํค n > AI Agent ๋
ธ๋ ์ถ๊ฐ ํ, ์ค์ ์ฐฝ์์ Source for Prompt๋ Define below๋ฅผ ์ ํํ๋ค.

Prompt (User Message) ์ ๋ ฅ๋์๋ ์๋ ๋ด์ฉ์ ๋ณต์ฌ/๋ถ์ฌ๋ฃ๋๋ค. ์ด ํ๋กฌํํธ๋ โ ์์ ์ด๋ฏธ์ง ๋ถ์/์์ ์ฑ๋ถ ๊ณ์ฐ, โก๊ตฌ๊ธ ์ํธ ๊ธฐ๋ก(write_sheet ํด), โข๊ตฌ๊ธ ์ํธ์์ ์ ๋ณด ์กฐํ(read_sheet ํด)๊น์ง ์ธ ๊ฐ์ง ์ฃผ์ ํ๋ ์ง์นจ์ ๋ด๊ณ ์๋ค.
You are **Calorie Tracker Bot**, a friendly assistant that helps the user monitor their daily calorie and macro intake.
You have three main responsibilities:
1. **Analyze images of food** sent by the user (via Telegram).
- If the user sends an image, you can find it below.
- Use your vision capabilities to identify the food items, estimate portion sizes, and calculate approximate calories and macronutrients (protein, carbs, fat).
2. **Log the data** using the `write_sheet` tool.
- The tool must always be called when an image contains identifiable food.
- Log the following fields:
- `date`: current date and time (ISO format)
- `food`: food name(s)
- `calories`: estimated total calories
- `protein`, `carbs`, `fat`: grams of each macronutrient
- `notes`: optional observations (like "approximation" or "mixed dish")
โ ๏ธ Never just say the data was logged — always call the write_sheet tool.
Confirm and summarize the result back to the user in a short, friendly message after the tool call completes.
Example:
"Logged: Chicken salad — 420 kcal (Protein 35g, Carbs 20g, Fat 18g). โ
Added to your tracker!"
Additionally, you should:
Answer the user’s questions about their daily, weekly, or overall calorie intake and nutrition trends.
Use the read_sheet tool to retrieve and summarize data.
Be concise and encouraging — think of yourself as a helpful health companion, not a strict diet coach.
If the image is unclear or incomplete, politely ask for clarification or a text description.
When an image is added and you can identify ingredients, calories, and macros, always log it with write_sheet.
Use this context to keep a consistent and helpful tone across all interactions.
When logging food items, make sure to separate them, that means, instead of logging: Pizza with coke, you first log the Pizza and then the coke.
Current date and time is {{ $now }}
<USER MESSAGE>
Username: {{ $json.message.from.first_name }}
Image: {{ $binary.data || "No image provided" }}
Text: {{ $json.message.text || "No message provided." }}
</USER MESSAGE>
ํ
๋ ๊ทธ๋จ์ผ๋ก ๋ณด๋ธ ๋ฉ์์ง(ํ
์คํธ)๋ $json.message.text ์์ฑ์ผ๋ก ์ฐธ์กฐํ ์ ์๊ณ , ์ฒจ๋ถํ์ผ์ $binary.data๋ก ์ฐธ์กฐํ ์ ์๋ค. $json์ ํ์ฌ ๋
ธ๋๋ก ์ ๋ฌ๋ ์
๋ ฅ ์์ดํ
์ JSON ๋ฐ์ดํฐ์ด๊ณ , $binary๋ ์
๋ ฅ ์์ดํ
์ ๋ฐ์ด๋๋ฆฌ ๋ฐ์ดํฐ๋ฅผ ๊ฐ๋ฆฌํจ๋ค. $json, $binary ๊ด๋ จ ๋ ์์ธํ ๋ด์ฉ์ ๋งํฌ๋ฅผ ์ฐธ๊ณ ํ์.
๋
ธ๋ ์ค์ ์ฐฝ ํ๋จ Chat Model์ ํด๋ฆญํ๊ณ Model์ ์ ๋ ดํ gpt-4.1-mini๋ฅผ ์ ํํ๋ค.

ํ ๋ ๊ทธ๋จ ๋ฉ์์ง ์ ์ก ๋ ธ๋
AI๊ฐ ์์ฑํ ๋ต๋ณ ๋ ธ๋๋ฅผ ํ ๋ ๊ทธ๋จ ๋ด์ผ๋ก ๋ณด๋ด๊ธฐ ์ํด Telegram > Send a text message ๋ ธ๋๋ฅผ ์ถ๊ฐํ๋ค. ํ ๋ ๊ทธ๋จ ๋ด์ ์ฌ์ฉ์๊ฐ ๋จผ์ ๋ฉ์์ง๋ฅผ ๋ณด๋ด์ผ ๋ํ๊ฐ ์์๋๋ ๊ตฌ์กฐ์ด๋ฏ๋ก, ์ด ๋จ๊ณ์์ ํ ๋ ๊ทธ๋จ ํธ๋ฆฌ๊ฑฐ ๋ ธ๋์ ๊ธฐ๋ก๋ ์ฌ์ฉ์์ Chat ID๋ฅผ ์ฐธ์กฐํ์ฌ ๋ฉ์์ง๋ฅผ ๋ณด๋ผ ์ ์๋ค.

- Resource (๋์): Message
- Operation (๋์): Send Message
- Chat ID (๋ฐ๋ ์ฌ๋):
{{ $('trigger').item.json.message.chat.id }} - Text (๋ณด๋ผ ๋ด์ฉ):
{{ $json.output }}
๊ตฌ๊ธ ์ํธ ์์ฑ
AI Agent๊ฐ ๋ถ์ํ ์์ ์ฑ๋ถ ๋ฐ์ดํฐ๋ฅผ ์ ์ฅ/์กฐํํ๊ธฐ ์ํด ์๋ก์ด ๊ตฌ๊ธ ์ํธ๋ฅผ ๋ง๋ค๊ณ , ์ฒซ ๋ฒ์งธ ํ(A1~F1)์ ์๋ ์ปฌ๋ผ(ํค๋)์ ๋ฏธ๋ฆฌ ์ถ๊ฐํด ๋๋ค.

- name_of_food: ์์ ์ด๋ฆ
- portion_size: ์ญ์ทจ๋
- calories: ์นผ๋ก๋ฆฌ
- protein: ๋จ๋ฐฑ์ง
- carbs: ํ์ํ๋ฌผ
- fat: ์ง๋ฐฉ
- date: ๋ ์ง/์๊ฐ
๊ตฌ๊ธ ์ํธ ์ฐ๊ธฐ ๋๊ตฌ ์ถ๊ฐ
AI Agent๊ฐ ๋ถ์ํ ์์ ์ฑ๋ถ ๋ฐ์ดํฐ๋ฅผ ๊ตฌ๊ธ ์ํธ์ ๊ธฐ๋กํ๊ธฐ ์ํด Google Sheets ๋๊ตฌ๋ฅผ ์ถ๊ฐํ ์ฐจ๋ก๋ค. AI Agent ๋ ธ๋ ํ๋จ์ Tool ์์ญ์์ [+] ๋ฒํผ์ ํด๋ฆญํ ๋ค Google Sheets Tool์ ์ ํํ๋ค. ์์ฑ๋ ๊ตฌ๊ธ ์ํธ ๋ ธ๋ ์ค์ ์ฐฝ์ ์ด๊ณ ๋ค์๊ณผ ๊ฐ์ด ์ค์ ํ๋ค.

- Resource: Sheet Within Document (๋ฌธ์ ๋ด ์ํธ๋ฅผ ํ๊ฒ์ผ๋ก ์ง์ )
- Operation: Append Row (๊ธฐ์กด ๋ฐ์ดํฐ ์๋์ ์๋ก์ด ํ์ผ๋ก ์ถ๊ฐ)
- Document > From list: ๋ฐ์ดํฐ๋ฅผ ๊ธฐ๋กํ ๊ตฌ๊ธ ์ํธ ํ์ผ ์ ํ
- Sheet > From list: ๋ฐ์ดํฐ๊ฐ ์ ๋ ฅ๋ ์ํธ ์ ํ
- Mapping Column Mode: Map Each Column Manually (๊ฐ ์ปฌ๋ผ์ ๊ฐ ์ง์ ๋งคํ)
- Values to Send: ๋ชจ๋ ํ๋์ โจ ์ฐ์ธก ๋ง๋ฒ ๋ฒํผ ํด๋ฆญ (AI Agent๊ฐ ๊ฐ์ ์๋์ผ๋ก ์ฑ์ฐ๋๋ก ์ค์ )
๊ตฌ๊ธ ์ํธ ์ฝ๊ธฐ ๋๊ตฌ ์ถ๊ฐ
AI Agent๊ฐ ๊ตฌ๊ธ ์ํธ์ ๊ธฐ๋ก๋ ๋ฐ์ดํฐ๋ฅผ ํ์ธํ๊ณ ์ฝ์ด์ฌ ์ ์๋๋ก Google Sheets ๋๊ตฌ๋ฅผ ํ๋ ๋ ์ถ๊ฐํด์ผ ํ๋ค. ์ด์ ๊ณผ ๋์ผํ๊ฒ AI Agent ๋
ธ๋ ํ๋จ์ Tool ์์ญ์์ [+] ๋ฒํผ์ ํด๋ฆญํ ๋ค Google Sheets Tool์ ์ ํํ๋ค. ์์ฑ๋ ๊ตฌ๊ธ ์ํธ ๋
ธ๋์ ์ด๋ฆ์ read_sheet๋ก ๋ณ๊ฒฝํ๊ณ ์ค์ ์ฐฝ์ ์ด์ด ์๋ ์ด๋ฏธ์ง์ ๊ฐ์ด ์ค์ ํ๋ค.

- Resource: Sheet Within Document (๋ฌธ์ ๋ด ์ํธ๋ฅผ ํ๊ฒ์ผ๋ก ์ง์ )
- Operation: Get Row (์ํธ์์ ํ ๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ)
- Document > From list: ๋ฐ์ดํฐ๋ฅผ ์กฐํํ ๊ตฌ๊ธ ์ํธ ํ์ผ ์ ํ
- Sheet > From list: ๋ฐ์ดํฐ๋ฅผ ์กฐํํ ์ํธ ์ ํ
ํน์ ๋ฐ์ดํฐ๋ง ๊ณจ๋ผ์ ๋ถ๋ฌ์ค๊ณ ์ถ๋ค๋ฉด ํ๋จ Filters ์์ญ > Add Filter๋ฅผ ํด๋ฆญํด์ ์กฐ๊ฑด์ ์ค์ ํ ์ ์๋ค. ์ด๋ฒ ์์ ์์ ๋ฐ๋ก ํํฐ๋ฅผ ์ง์ ํ์ง ์์์ผ๋ฏ๋ก ์ํธ์ ์๋ ์ ์ฒด ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์จ๋ค.
์ด์ Execute workflow๋ฅผ ํด๋ฆญํ๊ณ ํ ๋ ๊ทธ๋จ ๋ด์ ์์ ์ฌ์ง์ด๋ ๋ฉ์์ง๋ฅผ ๋ณด๋ด์ ์ ์๋ํ๋์ง ํ์ธํด๋ณด์.
๋ฉ๋ชจ๋ฆฌ ์ถ๊ฐ
ํ ๋ ๊ทธ๋จ ๋ด ์ฑํ ์ฐฝ์๋ ์ด์ ๋ํ๊ฐ ๊ทธ๋๋ก ๋จ์ ์๊ธฐ ๋๋ฌธ์, ๋ด๋ ์ด๋ฅผ ๊ธฐ์ตํ ๊ฒ ๊ฐ์ง๋ง, ์ค์ ๋ก๋ ๊ทธ๋ ์ง ์๋ค(Stateless). n8n ์ํฌํ๋ก์ฐ๋ ๊ธฐ๋ณธ์ ์ผ๋ก ๋ฉ์์ง๋ฅผ ๋ฐ๊ณ ์๋ต์ ์์ฑํ ๋ค ์คํ์ ์ข ๋ฃํ๋ค. ๋ค์ ๋ฉ์์ง๊ฐ ๋ค์ด์ค๋ฉด ์๋ก์ด ์คํ์ผ๋ก ์ฒ๋ฆฌ๋๊ธฐ ๋๋ฌธ์ ์ด์ ๋ํ ๋ด์ฉ์ ์ ์ ์๋ค.

์ฌ์ฉ์์์ ๋ํ ๋งฅ๋ฝ์ ์ ์งํ๋ ค๋ฉด ๋ณ๋์ ๋ฉ๋ชจ๋ฆฌ ์ค์ ์ด ํ์ํ๋ค. n8n์์ ์ธ์คํด์ค ๋ก์ปฌ ๋ฉ๋ชจ๋ฆฌ์ ์ ์ฅ๋๋ Simple Memory์ MongoDB/Redis/Postgres ๊ฐ์ ์ธ๋ถ ์ ์ฅ์ ๊ธฐ๋ฐ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ฌ์ฉํ ์ ์๋ค.
๊ฐ๋จํ ์ฐ์ต์ฉ์ด๋ผ๋ฉด Simple Memory๋ก๋ ์ถฉ๋ถํ์ง๋ง ๋ก์ปฌ ๋ฉ๋ชจ๋ฆฌ์ ์ ์ฅ๋๊ธฐ ๋๋ฌธ์ ์๋ฒ๋ฅผ ์ฌ์์ํ๋ฉด ๋ชจ๋ ๋ด์ฉ์ด ์ด๊ธฐํ๋๊ณ , ์ฌ๋ฌ ๊ฐ์ ์์ปค(Worker) ๋ ธ๋๋ผ๋ฆฌ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ๊ณต์ ํ์ง ๋ชปํ๋ ๋จ์ ์ด ์๋ค. ์ค์ ์ด์ ํ๊ฒฝ์์ Redis ๊ฐ์ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ฐ๋์ ๊ถ์ฅํ๋ค.
AI Agent ๋ ธ๋ ํ๋จ์ Memory ์์ญ์์ [+] ๋ฒํผ์ ํด๋ฆญํ ๋ค Simple Memory๋ฅผ ์ถ๊ฐํ๊ณ ๋ค์๊ณผ ๊ฐ์ด ์ค์ ํ๋ค.

- Session ID: Define below
- Key (๋ฉ๋ชจ๋ฆฌ ์๋ณ์):
{{ $('trigger').item.json.message.chat.id }}
๋ฉ๋ชจ๋ฆฌ๋ฅผ ๊ตฌ๋ถํ๋ ๊ณ ์ ๊ฐ. ํ ๋ ๊ทธ๋จ Chat ID๋ฅผ ๋ฃ์ด๋๋ฉด ์ฌ์ฉ์๋ณ๋ก ๋ค๋ฅธ ๋ฉ๋ชจ๋ฆฌ ๊ณต๊ฐ์ ์ฌ์ฉํ ์ ์๋ค. - Context Window Length (์ฐธ๊ณ ํ ๋ํ ๊ธฐ๋ก ์):
5
AI์๊ฒ ์ ๋ฌํ ์ด์ ๋ํ ๊ฐ์. 5๋ก ์ค์ ํ๋ฉด ์ต๊ทผ 5๊ฐ์ ๋ํ ๊ธฐ๋ก์ ์ฐธ๊ณ ํ์ฌ ๋ต๋ณ์ ์์ฑํ๋ค.
์ํฌํ๋ก์ฐ ์์ฑ ํ๋ฉด
๋ชจ๋ ๋ ธ๋ ์ค์ ๊ณผ ๋ฉ๋ชจ๋ฆฌ ์ฐ๊ฒฐ๊น์ง ์๋ฃํ๋ค๋ฉด ์๋์ ๊ฐ์ AI ๊ธฐ๋ฐ ์นผ๋ก๋ฆฌ ํธ๋์ปค ์ํฌํ๋ก์ฐ๊ฐ ์์ฑ๋๋ค.

์ด์ ํ
๋ ๊ทธ๋จ ๋ด์ผ๋ก ์์ ์ฌ์ง์ ๋ณด๋ด๋ฉด AI Agent๊ฐ ๋น์ (Vision) ๊ธฐ๋ฅ์ผ๋ก ์์์ ๋ถ์ํ๊ณ , write_sheet ๋๊ตฌ๋ฅผ ํตํด ๊ตฌ๊ธ ์ํธ์ ์์ ์ฑ๋ถ์ ๊ธฐ๋กํ๋ค. ๋ฐ๋๋ก "์ค๋ ์ด ๋ช ์นผ๋ก๋ฆฌ ๋จน์์ด?"์ฒ๋ผ ์ง๋ฌธํ๋ฉด read_sheet ๋๊ตฌ๋ก ์ํธ ๋ฐ์ดํฐ๋ฅผ ์กฐํํ๊ณ ๊ธฐ๋ก๋ ๋ฐ์ดํฐ๋ฅผ ๋ฐํ์ผ๋ก ์ญ์ทจ๋์ ์์ฝํด์ค๋ค.
'๐ช Programming' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| [n8n] AI ์ด๋ฉ์ผ ์๋ ๋ต๋ณ ์ํฌํ๋ก์ฐ ๋ง๋ค๊ธฐ (0) | 2026.05.21 |
|---|---|
| [n8n] AI ์์ด์ ํธ๋ก ์์์ฆ ์ง์ถ ๋ด์ญ(๊ฐ๊ณ๋ถ) ์๋ ๊ธฐ๋กํ๊ธฐ (0) | 2026.05.20 |
| [n8n] ๊ตฌ๊ธ ๋๋ผ์ด๋ธ ํ์ผ/ํด๋ ์ ๋ฆฌ AI ์์ด์ ํธ ๋ง๋ค๊ธฐ (0) | 2026.05.19 |
| [n8n] ์ ํ๋ธ ๊ตฌ๋ ์ฑ๋ ์ ์์ ์ด๋ฉ์ผ๋ก ๋ฐ์๋ณด๊ธฐ (0) | 2026.05.18 |
| [n8n] ์์ผ ์๋ฆผ ์ด๋ฉ์ผ ๋ณด๋ด๊ธฐ (0) | 2026.05.17 |
๋๊ธ
์ด ๊ธ ๊ณต์ ํ๊ธฐ
-
๊ตฌ๋
ํ๊ธฐ
๊ตฌ๋ ํ๊ธฐ
-
์นด์นด์คํก
์นด์นด์คํก
-
๋ผ์ธ
๋ผ์ธ
-
ํธ์ํฐ
ํธ์ํฐ
-
Facebook
Facebook
-
์นด์นด์ค์คํ ๋ฆฌ
์นด์นด์ค์คํ ๋ฆฌ
-
๋ฐด๋
๋ฐด๋
-
๋ค์ด๋ฒ ๋ธ๋ก๊ทธ
๋ค์ด๋ฒ ๋ธ๋ก๊ทธ
-
Pocket
Pocket
-
Evernote
Evernote
๋ค๋ฅธ ๊ธ
-
[n8n] AI ์ด๋ฉ์ผ ์๋ ๋ต๋ณ ์ํฌํ๋ก์ฐ ๋ง๋ค๊ธฐ
[n8n] AI ์ด๋ฉ์ผ ์๋ ๋ต๋ณ ์ํฌํ๋ก์ฐ ๋ง๋ค๊ธฐ
2026.05.21 -
[n8n] AI ์์ด์ ํธ๋ก ์์์ฆ ์ง์ถ ๋ด์ญ(๊ฐ๊ณ๋ถ) ์๋ ๊ธฐ๋กํ๊ธฐ
[n8n] AI ์์ด์ ํธ๋ก ์์์ฆ ์ง์ถ ๋ด์ญ(๊ฐ๊ณ๋ถ) ์๋ ๊ธฐ๋กํ๊ธฐ
2026.05.20 -
[n8n] ๊ตฌ๊ธ ๋๋ผ์ด๋ธ ํ์ผ/ํด๋ ์ ๋ฆฌ AI ์์ด์ ํธ ๋ง๋ค๊ธฐ
[n8n] ๊ตฌ๊ธ ๋๋ผ์ด๋ธ ํ์ผ/ํด๋ ์ ๋ฆฌ AI ์์ด์ ํธ ๋ง๋ค๊ธฐ
2026.05.19 -
[n8n] ์ ํ๋ธ ๊ตฌ๋ ์ฑ๋ ์ ์์ ์ด๋ฉ์ผ๋ก ๋ฐ์๋ณด๊ธฐ
[n8n] ์ ํ๋ธ ๊ตฌ๋ ์ฑ๋ ์ ์์ ์ด๋ฉ์ผ๋ก ๋ฐ์๋ณด๊ธฐ
2026.05.18