Yapay Zeka Ajanları
n8n Learning Path
CHAPTER 08Intermediate ~60 min

Email, Messaging and Communication

Building notification and messaging flows with Gmail, SMTP, Slack, Telegram, WhatsApp and Discord.

In this chapter

Most automations end with a message: an email, a Slack note, a WhatsApp message. In this chapter you will set up n8n's 5 main communication channels (Gmail, SMTP, Slack, Telegram, WhatsApp and Discord); you will learn both directions (catch incoming messages and send outgoing ones), how to set up bots, and how to stay compliant on marketing opt-ins.

Topics

  • Gmail: reading, sending, labelling
  • Generic SMTP / IMAP configuration
  • Slack: messages, channel management
  • Telegram bots for notifications
  • WhatsApp Business API integration
  • Discord webhooks and bots

Gmail: read, send, label

The Gmail node connects via OAuth2 (an OAuth app + Gmail scopes in Google Cloud Console). Three main operations: Message → Send (great for personal/transactional emails — DMARC/SPF must be set), Send and Wait For Approval (adds an approve button to the body and branches on the reply), Get Many (use Gmail Search syntax — e.g. from:billing@... newer_than:7d). To label, use Label → Add. Gmail's rate limit is generous but Google's per-user daily 500-email cap applies — for bulk sending prefer SES/Mailgun.

Gmail Trigger
AI Agent
Gmail (Send Reply)
Label (Replied)

Generic SMTP / IMAP: your own mail server

For corporate/custom email (info@company.com), use SMTP/IMAP instead of the Gmail node. SMTP node sends messages (host: smtp.gmail.com etc., port 587/465, TLS); IMAP Email Trigger catches incoming messages (mailbox, search criteria, attachment download). Use an 'App Password' (not your real password) — the safest option since you don't spread your actual password.

Slack: message + channel + reaction + thread

The Slack node connects to a workspace via OAuth. Common operations: Message → Send (channel or DM, formatted with blocks/markdown), Send and Wait For Approval (approve/reject buttons — human-in-the-loop pattern), Thread → Reply, Reaction → Add (✅ as a silent approval signal). Skip the '#' in channel names; for mentions use the user ID format <@U12345>. For production bots remember to add 'chat:write' + 'reactions:write' scopes.

Telegram bot: trigger + send

A Telegram bot takes 5 minutes: get a token from @BotFather (/newbot) and paste it into n8n Credentials. The Telegram Trigger catches every message to your bot (text, photo, voice). Send Message replies — chat_id comes through automatically ({{ $json.message.chat.id }}). Use Markdown or HTML formatting. When voice arrives, download by file_id and pass to Whisper for transcription — the most loved chatbot pattern.

WhatsApp Business API

WhatsApp integration goes through the official path (WhatsApp Business Platform Cloud API, not personal WhatsApp). You'll need a Meta Business account + a verified phone number + an approved 'message template.' n8n's WhatsApp Business Cloud node sends messages; if the customer hasn't initiated contact you must start with a template (the 24-hour 'customer window' rule). Catch incoming with the webhook, run through AI Agent + escalate to Slack — the most common CX pattern.

Discord: webhook + bot

Discord offers two paths. Webhook (easiest): in a channel go Integration → Webhook, grab the URL and POST to it from n8n HTTP Request — no bot needed, perfect for one-way announcements. Bot (more powerful): create a bot in the Discord Developer Portal and connect via the Discord node — join channels, DM users, respond to slash commands, track reactions. Discord's embedded message format (title, color, fields, footer) gives rich visuals — great for status dashboards.

Compliance in messaging (GDPR / CAN-SPAM)

If you send marketing email or SMS in bulk, consent management is mandatory. Practical rules: (1) Every email needs an unsubscribe link — run an 'incoming unsubscribe webhook → DB status = unsub' workflow and filter with IF before subsequent sends. (2) Ads must say so ('This is a marketing message') and comply with local rules. (3) For bot messages, always identify the brand and purpose clearly to avoid impersonation. Putting these checks at the top of the flow with IF removes the 'I accidentally messaged opt-outs' risk.

This chapter's workflow (n8n editor view)

Webhook
AI Agent
Gmail
Slack