@xnkee/n8n-nodes-instagram 1.7.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{LICENSE.md → LICENSE} +21 -21
- package/README.md +132 -437
- package/dist/credentials/InstagramApi.credentials.d.ts +10 -0
- package/dist/credentials/InstagramApi.credentials.js +55 -0
- package/dist/credentials/InstagramApi.credentials.js.map +1 -0
- package/dist/credentials/InstagramOAuth2Api.credentials.d.ts +2 -2
- package/dist/credentials/InstagramOAuth2Api.credentials.js +33 -113
- package/dist/credentials/InstagramOAuth2Api.credentials.js.map +1 -1
- package/dist/credentials/InstagramUnifiedLoginOAuth2Api.credentials.d.ts +17 -0
- package/dist/credentials/InstagramUnifiedLoginOAuth2Api.credentials.js +116 -0
- package/dist/credentials/InstagramUnifiedLoginOAuth2Api.credentials.js.map +1 -0
- package/dist/credentials/instagram.svg +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/nodes/Instagram/GenericFunctions.d.ts +27 -23
- package/dist/nodes/Instagram/GenericFunctions.js +182 -223
- package/dist/nodes/Instagram/GenericFunctions.js.map +1 -1
- package/dist/nodes/Instagram/Instagram.node.d.ts +1 -1
- package/dist/nodes/Instagram/Instagram.node.js +109 -2353
- package/dist/nodes/Instagram/Instagram.node.js.map +1 -1
- package/dist/nodes/Instagram/Instagram.node.json +17 -0
- package/dist/nodes/Instagram/InstagramChatTrigger.node.d.ts +17 -0
- package/dist/nodes/Instagram/InstagramChatTrigger.node.js +415 -0
- package/dist/nodes/Instagram/InstagramChatTrigger.node.js.map +1 -0
- package/dist/nodes/Instagram/InstagramChatTrigger.node.json +16 -0
- package/dist/nodes/Instagram/descriptions/comment/Comment.fields.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/comment/Comment.fields.js +161 -0
- package/dist/nodes/Instagram/descriptions/comment/Comment.fields.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/comment/Comment.operations.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/comment/Comment.operations.js +62 -0
- package/dist/nodes/Instagram/descriptions/comment/Comment.operations.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/comment/index.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/comment/index.js +8 -0
- package/dist/nodes/Instagram/descriptions/comment/index.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/custom/Custom.fields.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/custom/Custom.fields.js +65 -0
- package/dist/nodes/Instagram/descriptions/custom/Custom.fields.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/custom/Custom.operations.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/custom/Custom.operations.js +26 -0
- package/dist/nodes/Instagram/descriptions/custom/Custom.operations.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/custom/index.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/custom/index.js +8 -0
- package/dist/nodes/Instagram/descriptions/custom/index.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/index.d.ts +7 -0
- package/dist/nodes/Instagram/descriptions/index.js +24 -0
- package/dist/nodes/Instagram/descriptions/index.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/insight/AccountInsight.fields.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/insight/AccountInsight.fields.js +164 -0
- package/dist/nodes/Instagram/descriptions/insight/AccountInsight.fields.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/insight/Insight.operations.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/insight/Insight.operations.js +32 -0
- package/dist/nodes/Instagram/descriptions/insight/Insight.operations.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/insight/MediaInsight.fields.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/insight/MediaInsight.fields.js +87 -0
- package/dist/nodes/Instagram/descriptions/insight/MediaInsight.fields.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/insight/index.d.ts +4 -0
- package/dist/nodes/Instagram/descriptions/insight/index.js +12 -0
- package/dist/nodes/Instagram/descriptions/insight/index.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/media/Media.operations.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/media/Media.operations.js +62 -0
- package/dist/nodes/Instagram/descriptions/media/Media.operations.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/media/MediaGet.fields.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/media/MediaGet.fields.js +163 -0
- package/dist/nodes/Instagram/descriptions/media/MediaGet.fields.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/media/MediaPublish.fields.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/media/MediaPublish.fields.js +285 -0
- package/dist/nodes/Instagram/descriptions/media/MediaPublish.fields.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/media/index.d.ts +4 -0
- package/dist/nodes/Instagram/descriptions/media/index.js +12 -0
- package/dist/nodes/Instagram/descriptions/media/index.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/mention/Mention.fields.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/mention/Mention.fields.js +122 -0
- package/dist/nodes/Instagram/descriptions/mention/Mention.fields.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/mention/Mention.operations.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/mention/Mention.operations.js +38 -0
- package/dist/nodes/Instagram/descriptions/mention/Mention.operations.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/mention/index.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/mention/index.js +8 -0
- package/dist/nodes/Instagram/descriptions/mention/index.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/message/Message.fields.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/message/Message.fields.js +123 -0
- package/dist/nodes/Instagram/descriptions/message/Message.fields.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/message/Message.operations.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/message/Message.operations.js +44 -0
- package/dist/nodes/Instagram/descriptions/message/Message.operations.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/message/index.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/message/index.js +8 -0
- package/dist/nodes/Instagram/descriptions/message/index.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/user/User.operations.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/user/User.operations.js +38 -0
- package/dist/nodes/Instagram/descriptions/user/User.operations.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/user/UserInsights.fields.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/user/UserInsights.fields.js +164 -0
- package/dist/nodes/Instagram/descriptions/user/UserInsights.fields.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/user/UserProfile.fields.d.ts +2 -0
- package/dist/nodes/Instagram/descriptions/user/UserProfile.fields.js +83 -0
- package/dist/nodes/Instagram/descriptions/user/UserProfile.fields.js.map +1 -0
- package/dist/nodes/Instagram/descriptions/user/index.d.ts +4 -0
- package/dist/nodes/Instagram/descriptions/user/index.js +12 -0
- package/dist/nodes/Instagram/descriptions/user/index.js.map +1 -0
- package/dist/nodes/Instagram/handlers/CommentHandler.d.ts +2 -0
- package/dist/nodes/Instagram/handlers/CommentHandler.js +63 -0
- package/dist/nodes/Instagram/handlers/CommentHandler.js.map +1 -0
- package/dist/nodes/Instagram/handlers/CustomHandler.d.ts +2 -0
- package/dist/nodes/Instagram/handlers/CustomHandler.js +28 -0
- package/dist/nodes/Instagram/handlers/CustomHandler.js.map +1 -0
- package/dist/nodes/Instagram/handlers/InsightHandler.d.ts +2 -0
- package/dist/nodes/Instagram/handlers/InsightHandler.js +42 -0
- package/dist/nodes/Instagram/handlers/InsightHandler.js.map +1 -0
- package/dist/nodes/Instagram/handlers/MediaHandler.d.ts +2 -0
- package/dist/nodes/Instagram/handlers/MediaHandler.js +172 -0
- package/dist/nodes/Instagram/handlers/MediaHandler.js.map +1 -0
- package/dist/nodes/Instagram/handlers/MentionHandler.d.ts +2 -0
- package/dist/nodes/Instagram/handlers/MentionHandler.js +48 -0
- package/dist/nodes/Instagram/handlers/MentionHandler.js.map +1 -0
- package/dist/nodes/Instagram/handlers/MessageHandler.d.ts +2 -0
- package/dist/nodes/Instagram/handlers/MessageHandler.js +57 -0
- package/dist/nodes/Instagram/handlers/MessageHandler.js.map +1 -0
- package/dist/nodes/Instagram/handlers/UserHandler.d.ts +2 -0
- package/dist/nodes/Instagram/handlers/UserHandler.js +48 -0
- package/dist/nodes/Instagram/handlers/UserHandler.js.map +1 -0
- package/dist/nodes/Instagram/instagram.svg +1 -0
- package/package.json +34 -46
- package/API_REFERENCE.md +0 -907
- package/AUTHENTICATION_GUIDE.md +0 -718
- package/CHANGELOG.md +0 -391
- package/dist/credentials/InstagramUnifiedLoginApi.credentials.d.ts +0 -9
- package/dist/credentials/InstagramUnifiedLoginApi.credentials.js +0 -481
- package/dist/credentials/InstagramUnifiedLoginApi.credentials.js.map +0 -1
- package/dist/nodes/Instagram/InstagramTrigger.node.d.ts +0 -17
- package/dist/nodes/Instagram/InstagramTrigger.node.js +0 -398
- package/dist/nodes/Instagram/InstagramTrigger.node.js.map +0 -1
- package/dist/nodes/Instagram/instagram-large.svg +0 -27
- package/dist/nodes/Instagram/instagram-small.svg +0 -14
- package/dist/nodes/Instagram/types.d.ts +0 -171
- package/dist/nodes/Instagram/types.js +0 -3
- package/dist/nodes/Instagram/types.js.map +0 -1
- package/dist/package.json +0 -76
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/index.js +0 -0
package/AUTHENTICATION_GUIDE.md
DELETED
|
@@ -1,718 +0,0 @@
|
|
|
1
|
-
# Instagram API Authentication Guide
|
|
2
|
-
|
|
3
|
-
Complete guide for setting up Instagram API authentication with @xnkee/n8n-nodes-instagram.
|
|
4
|
-
|
|
5
|
-
## Table of Contents
|
|
6
|
-
|
|
7
|
-
- [Instagram API with Unified Login (Recommended, v1.7.0+)](#instagram-api-with-unified-login-recommended-v170)
|
|
8
|
-
- [Overview](#overview)
|
|
9
|
-
- [Prerequisites](#prerequisites)
|
|
10
|
-
- [Authentication Methods](#authentication-methods)
|
|
11
|
-
- [Step-by-Step Setup](#step-by-step-setup)
|
|
12
|
-
- [OAuth2 Flow](#oauth2-flow)
|
|
13
|
-
- [Access Token Method](#access-token-method)
|
|
14
|
-
- [Troubleshooting](#troubleshooting)
|
|
15
|
-
- [Security Best Practices](#security-best-practices)
|
|
16
|
-
- [FAQs](#faqs)
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
## Instagram API with Unified Login (Recommended, v1.7.0+)
|
|
21
|
-
|
|
22
|
-
The [Instagram API with Unified Login](https://developers.facebook.com/documentation/instagram-platform/instagram-api-with-unified-login) lets your clients connect their Instagram professional account by logging in with **Instagram or Facebook**. No Facebook Page is required. Meta releases new Instagram API features only for this setup.
|
|
23
|
-
|
|
24
|
-
| | Unified Login (credential **Instagram Unified Login API**) | Instagram Login (credential **Instagram OAuth2 API**, legacy) |
|
|
25
|
-
|---|---|---|
|
|
26
|
-
| Client logs in with | Instagram or Facebook | Instagram |
|
|
27
|
-
| Access token | Business Integration System User Access Token (belongs to the client's business portfolio) | Instagram User access token |
|
|
28
|
-
| API host | `graph.facebook.com/v27.0` | `graph.instagram.com/v27.0` |
|
|
29
|
-
| Account in request paths | Instagram professional account ID | Instagram account ID or `/me` |
|
|
30
|
-
| Token renewal | Automatic, persisted in the credential | — |
|
|
31
|
-
|
|
32
|
-
Node version 2 of **Instagram** and **Instagram Trigger** uses Unified Login by default. Existing workflows (node version 1) keep using Instagram Login until you switch the **Authentication** parameter.
|
|
33
|
-
|
|
34
|
-
### 1. Meta App Dashboard
|
|
35
|
-
|
|
36
|
-
1. Your Meta app must be owned by a business portfolio.
|
|
37
|
-
2. Open **Use cases → Manage messaging & content on Instagram → Customize → API setup with Unified login** and create a configuration (**Create new configuration**). It defines the permissions and assets requested from the client and gets a `config_id`.
|
|
38
|
-
3. Permissions (Unified Login names):
|
|
39
|
-
|
|
40
|
-
| Feature | Permission |
|
|
41
|
-
|---|---|
|
|
42
|
-
| Profile, media, `/me/assigned_instagram_accounts` | `instagram_basic` |
|
|
43
|
-
| Messages and private replies | `instagram_manage_messages` |
|
|
44
|
-
| Comments and mentions | `instagram_manage_comments` |
|
|
45
|
-
| Publishing (posts, reels, stories, carousels) | `instagram_content_publish` |
|
|
46
|
-
| **Automatic token renewal** | `business_management` |
|
|
47
|
-
|
|
48
|
-
The old `instagram_business_*` scopes map to `instagram_basic`, `instagram_manage_messages`, `instagram_manage_comments`, `instagram_content_publish` and `instagram_manage_insights`.
|
|
49
|
-
4. Choose the **token expiration** of the configuration. Tokens never expire by default; with a 60-day expiration, add `business_management` so the node can renew the token.
|
|
50
|
-
5. Set the **Redirect URL** and save. Copy the **Login URL**:
|
|
51
|
-
|
|
52
|
-
```
|
|
53
|
-
https://www.facebook.com/dialog/oauth?client_id=<META_APP_ID>&config_id=<CONFIG_ID>&redirect_uri=<REDIRECT_URL>&response_type=code
|
|
54
|
-
```
|
|
55
|
-
6. Clients without a role in your app need **Advanced Access** for each permission (App Review) and the app in **Live** mode.
|
|
56
|
-
|
|
57
|
-
### 2. Connect the client account
|
|
58
|
-
|
|
59
|
-
1. The client opens the Login URL, logs in with Instagram or Facebook, selects the business portfolio and the Instagram account, and approves the permissions.
|
|
60
|
-
2. Meta redirects to your Redirect URL with `?code=...`. The page at the Redirect URL does not need to do anything: you only need the `code` value from the address bar.
|
|
61
|
-
3. In n8n: **Credentials → New → Instagram Unified Login API**:
|
|
62
|
-
- **Meta App ID** / **Meta App Secret**: from the Meta app (*App settings → Basic*), not the Instagram app ID/secret.
|
|
63
|
-
- **Connection Method**: *Authorization Code*.
|
|
64
|
-
- **Authorization Code**: the `code` value. **Redirect URL**: exactly the one in the Login URL.
|
|
65
|
-
- **Instagram Account ID**: only if the client shared more than one account.
|
|
66
|
-
4. Save and **run a node that uses the credential right away**. Codes are single-use and expire after a few minutes: the first execution exchanges the code and stores the token in the credential.
|
|
67
|
-
|
|
68
|
-
Alternatively, choose *Access Token* and paste a Business Integration System User Access Token you already have (for example, from **Generate token** in the App Dashboard while the app is in Development mode).
|
|
69
|
-
|
|
70
|
-
> The credential has no "Test" step on purpose: n8n does not save data produced during a credential test, so the test would consume the single-use code without keeping the token. Errors are reported on the first execution.
|
|
71
|
-
|
|
72
|
-
### 3. How the token is managed
|
|
73
|
-
|
|
74
|
-
On the first execution the credential:
|
|
75
|
-
|
|
76
|
-
1. Exchanges the code at `GET https://graph.facebook.com/v27.0/oauth/access_token`.
|
|
77
|
-
2. Reads the expiration and scopes with `GET /debug_token` (app token `APP_ID|APP_SECRET`).
|
|
78
|
-
3. Gets the client business ID (`GET /me?fields=client_business_id`) and the shared accounts (`GET /me/assigned_instagram_accounts`).
|
|
79
|
-
4. Stores everything in hidden credential fields.
|
|
80
|
-
|
|
81
|
-
Before each request it checks the expiration. When the token expires in less than **Renew Days Before Expiration** (default 7), it calls the Business Integration System User Access Token Management API:
|
|
82
|
-
|
|
83
|
-
```
|
|
84
|
-
POST https://graph.facebook.com/v27.0/<CLIENT_BUSINESS_ID>/system_user_access_tokens
|
|
85
|
-
?access_token=<CURRENT_TOKEN>&appsecret_proof=<HMAC_SHA256(token, app_secret)>&set_token_expires_in_60_days=true
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
The new token is saved in the credential and the request continues with it. n8n persists it, so it survives restarts. If renewal fails, the current token keeps being used and renewal is retried every 6 hours; the last error is kept in the credential. Tokens that never expire are never renewed.
|
|
89
|
-
|
|
90
|
-
Every request is sent with `Authorization: Bearer <token>` and `appsecret_proof`, so apps with **Require App Secret** enabled work.
|
|
91
|
-
|
|
92
|
-
The token stops working if the client removes your app from their business portfolio or moves the Instagram account to another portfolio. The node then reports *"The Instagram Unified Login access token is invalid, expired or revoked"*: open the Login URL again and paste the new code.
|
|
93
|
-
|
|
94
|
-
### 4. Webhooks (Instagram Trigger)
|
|
95
|
-
|
|
96
|
-
1. In the App Dashboard, open **Webhooks** of the **Meta app**, select the **Instagram** object and set the Callback URL to the Instagram Trigger webhook URL, with the **Verify Token** of the credential. (Not the webhook settings under *API setup with Instagram login*.)
|
|
97
|
-
2. Select the fields: `messages`, `messaging_postbacks`, `comments`, `mentions`. `messaging_optins` is not available for Unified Login.
|
|
98
|
-
3. Each client account must be subscribed with `POST /<INSTAGRAM_ACCOUNT_ID>/subscribed_apps?subscribed_fields=...`. The trigger does this when the workflow is activated (**Subscribe Account Automatically**). It adds the selected fields to the ones already subscribed and does not unsubscribe on deactivation, because other workflows may use the same account.
|
|
99
|
-
4. Payloads are signed with the **Meta App Secret** (`X-Hub-Signature-256`). The app must be **Live** to receive notifications from client accounts.
|
|
100
|
-
|
|
101
|
-
Known Meta limitation: if the client shares the Instagram account but not its linked Facebook Page, `messages` notifications may not be delivered. Meta's workaround is a separate configuration that also requests the Page and `pages_show_list`.
|
|
102
|
-
|
|
103
|
-
### 5. Endpoint changes
|
|
104
|
-
|
|
105
|
-
| Operation | Instagram Login | Unified Login |
|
|
106
|
-
|---|---|---|
|
|
107
|
-
| Send message / private reply | `POST graph.instagram.com/me/messages` | `POST graph.facebook.com/<IG_ID>/messages` |
|
|
108
|
-
| Get my profile | `GET /me` | `GET /<IG_ID>` (`/me` is the business system user) |
|
|
109
|
-
| Instagram account ID | `GET /me` | `GET /me/assigned_instagram_accounts` |
|
|
110
|
-
| Media, publishing, comments | same paths on `graph.instagram.com` | same paths on `graph.facebook.com` |
|
|
111
|
-
| Webhook subscription | — | `POST /<IG_ID>/subscribed_apps` |
|
|
112
|
-
|
|
113
|
-
The Instagram account ID is the same in both setups. Message IDs use a different format, so do not reuse message IDs stored from the Instagram Login integration.
|
|
114
|
-
|
|
115
|
-
### 6. Limitations
|
|
116
|
-
|
|
117
|
-
- **Queue mode / several n8n instances**: concurrent renewals are de-duplicated inside one process only. Renewal happens a few days before expiration and takes one request, so collisions are unlikely.
|
|
118
|
-
- **Stale credential dialog**: if you keep the credential dialog open while the first execution runs and then save it again, the token stored by that execution may be overwritten (the used code cannot be exchanged again). Close and reopen the dialog before editing the credential.
|
|
119
|
-
- n8n's experimental **Engine v2** (`N8N_ENABLED_MODULES=engine-v2`) does not support credentials with an expirable field yet; this applies to both credentials of this package.
|
|
120
|
-
|
|
121
|
-
---
|
|
122
|
-
|
|
123
|
-
## Overview
|
|
124
|
-
|
|
125
|
-
This package supports **OAuth2 authentication** for seamless integration with Instagram's Messaging API. The authentication process connects your n8n workflows to Instagram Business Accounts through the Meta Graph API.
|
|
126
|
-
|
|
127
|
-
### Key Features (v1.5.7+)
|
|
128
|
-
|
|
129
|
-
- ✅ **Automatic Token Persistence** - Long-lived tokens are stored in n8n's database and survive restarts
|
|
130
|
-
- ✅ **Automatic Token Exchange** - Short-lived OAuth tokens are automatically exchanged for 60-day tokens
|
|
131
|
-
- ✅ **Automatic Token Refresh** - Tokens are refreshed when near expiration (< 7 days remaining)
|
|
132
|
-
- ✅ **No Manual Intervention** - Everything is handled transparently by n8n's credential system
|
|
133
|
-
|
|
134
|
-
### Supported Credential Types
|
|
135
|
-
|
|
136
|
-
| Type | Recommended | Use Case | Auto-Refresh | Survives Restart |
|
|
137
|
-
|------|-------------|----------|--------------|------------------|
|
|
138
|
-
| **Instagram OAuth2 API** | ✅ Yes | Production, long-term | Yes | ✅ Yes |
|
|
139
|
-
|
|
140
|
-
---
|
|
141
|
-
|
|
142
|
-
## Prerequisites
|
|
143
|
-
|
|
144
|
-
### Required Accounts
|
|
145
|
-
|
|
146
|
-
1. **Facebook Account** - Personal or business account
|
|
147
|
-
2. **Facebook Page** - Must be an admin/owner
|
|
148
|
-
3. **Instagram Business Account** - Professional account linked to Facebook Page
|
|
149
|
-
4. **Meta Developer Account** - Free registration at [developers.facebook.com](https://developers.facebook.com)
|
|
150
|
-
|
|
151
|
-
### Required Permissions
|
|
152
|
-
|
|
153
|
-
Your Meta app needs these permissions:
|
|
154
|
-
|
|
155
|
-
- ✅ `instagram_basic` - Basic profile information
|
|
156
|
-
- ✅ `instagram_manage_messages` - Send and receive messages
|
|
157
|
-
- ✅ `pages_manage_metadata` - Subscribe to webhooks
|
|
158
|
-
- ✅ `pages_read_engagement` - Read page engagement data
|
|
159
|
-
|
|
160
|
-
### Technical Requirements
|
|
161
|
-
|
|
162
|
-
- n8n version 0.196.0+
|
|
163
|
-
- Node.js 18.15+ or 20.10+
|
|
164
|
-
- HTTPS domain (for OAuth2 callback and webhooks)
|
|
165
|
-
|
|
166
|
-
---
|
|
167
|
-
|
|
168
|
-
## Authentication Methods
|
|
169
|
-
|
|
170
|
-
### Method 1: OAuth2 (Recommended) ⭐
|
|
171
|
-
|
|
172
|
-
**Advantages:**
|
|
173
|
-
- ✅ Automatic token exchange (short-lived → 60-day long-lived)
|
|
174
|
-
- ✅ Automatic token refresh when near expiration
|
|
175
|
-
- ✅ **Token persists through n8n/Docker restarts** (v1.5.7+)
|
|
176
|
-
- ✅ Secure authorization flow
|
|
177
|
-
- ✅ No manual token management
|
|
178
|
-
- ✅ Best for production
|
|
179
|
-
|
|
180
|
-
**How It Works (v1.5.7+):**
|
|
181
|
-
1. User clicks "Connect my account"
|
|
182
|
-
2. Popup opens Meta login
|
|
183
|
-
3. User authorizes permissions
|
|
184
|
-
4. n8n receives short-lived access token (1 hour)
|
|
185
|
-
5. **First API call**: Token is automatically exchanged for 60-day long-lived token
|
|
186
|
-
6. **Token is persisted** to n8n's database (survives restarts)
|
|
187
|
-
7. **When token nears expiration** (< 7 days): Automatically refreshed
|
|
188
|
-
8. Workflow continues working indefinitely without manual intervention
|
|
189
|
-
|
|
190
|
-
### ~~Method 2: Manual Access Token~~ (Deprecated)
|
|
191
|
-
|
|
192
|
-
**Advantages:**
|
|
193
|
-
- ⚡ Quick setup for testing
|
|
194
|
-
- 🔧 Full control over token lifecycle
|
|
195
|
-
- 🛠️ Useful for debugging
|
|
196
|
-
|
|
197
|
-
**Disadvantages:**
|
|
198
|
-
- ⏰ Manual token renewal required
|
|
199
|
-
- 🔄 No automatic refresh
|
|
200
|
-
|
|
201
|
-
**Process:**
|
|
202
|
-
1. Generate token in Meta Developer Console
|
|
203
|
-
2. Copy and paste into n8n credentials
|
|
204
|
-
3. Instagram Account ID auto-discovered
|
|
205
|
-
4. Manually refresh when expired
|
|
206
|
-
|
|
207
|
-
---
|
|
208
|
-
|
|
209
|
-
## Step-by-Step Setup
|
|
210
|
-
|
|
211
|
-
### Part A: Create Meta Developer App
|
|
212
|
-
|
|
213
|
-
#### Step 1: Register as Developer
|
|
214
|
-
|
|
215
|
-
1. Go to [Meta for Developers](https://developers.facebook.com/)
|
|
216
|
-
2. Click **Get Started** (top right)
|
|
217
|
-
3. Complete registration with your Facebook account
|
|
218
|
-
4. Verify email if prompted
|
|
219
|
-
|
|
220
|
-
#### Step 2: Create New App
|
|
221
|
-
|
|
222
|
-
1. Click **My Apps** → **Create App**
|
|
223
|
-
2. Select use case:
|
|
224
|
-
- **Business** (recommended for most users)
|
|
225
|
-
- Or **Consumer** for personal projects
|
|
226
|
-
3. Fill in app details:
|
|
227
|
-
```
|
|
228
|
-
App Name: My Instagram n8n Integration
|
|
229
|
-
App Contact Email: your-email@example.com
|
|
230
|
-
Business Account: (select or create)
|
|
231
|
-
```
|
|
232
|
-
4. Click **Create App**
|
|
233
|
-
5. Complete security check if prompted
|
|
234
|
-
|
|
235
|
-
#### Step 3: Add Instagram Product
|
|
236
|
-
|
|
237
|
-
1. In App Dashboard, scroll to **Add Products**
|
|
238
|
-
2. Find **Instagram** → Click **Set Up**
|
|
239
|
-
3. Instagram product added to left sidebar ✅
|
|
240
|
-
|
|
241
|
-
#### Step 4: Configure Instagram Basic Display
|
|
242
|
-
|
|
243
|
-
1. Click **Instagram** → **Basic Display**
|
|
244
|
-
2. Click **Create New App**
|
|
245
|
-
3. Fill in:
|
|
246
|
-
```
|
|
247
|
-
Display Name: n8n Instagram Bot
|
|
248
|
-
Valid OAuth Redirect URIs: https://your-n8n.com/oauth/callback
|
|
249
|
-
Deauthorize Callback URL: https://your-n8n.com/oauth/deauth
|
|
250
|
-
Data Deletion Request URL: https://your-n8n.com/oauth/delete
|
|
251
|
-
```
|
|
252
|
-
4. Click **Save Changes**
|
|
253
|
-
|
|
254
|
-
#### Step 5: Add Instagram Accounts
|
|
255
|
-
|
|
256
|
-
1. Still in **Basic Display** tab
|
|
257
|
-
2. Scroll to **User Token Generator**
|
|
258
|
-
3. Click **Add or Remove Instagram Accounts**
|
|
259
|
-
4. Login to Instagram (Business Account)
|
|
260
|
-
5. Authorize the app
|
|
261
|
-
6. Account appears in list ✅
|
|
262
|
-
|
|
263
|
-
#### Step 6: Get App Credentials
|
|
264
|
-
|
|
265
|
-
1. Go to **Settings** → **Basic** (left sidebar)
|
|
266
|
-
2. Note your credentials:
|
|
267
|
-
```
|
|
268
|
-
App ID: 1234567890123456
|
|
269
|
-
App Secret: [Click Show] abc123def456...
|
|
270
|
-
```
|
|
271
|
-
3. **Keep these secure!** 🔒
|
|
272
|
-
|
|
273
|
-
---
|
|
274
|
-
|
|
275
|
-
### Part B: Connect Facebook Page
|
|
276
|
-
|
|
277
|
-
#### Step 7: Link Instagram to Facebook Page
|
|
278
|
-
|
|
279
|
-
1. Go to Facebook Page Settings
|
|
280
|
-
2. Click **Instagram** (left sidebar)
|
|
281
|
-
3. Click **Connect Account**
|
|
282
|
-
4. Login to Instagram Business Account
|
|
283
|
-
5. Confirm connection
|
|
284
|
-
|
|
285
|
-
#### Step 8: Generate Page Access Token
|
|
286
|
-
|
|
287
|
-
**Option 1: Using Graph API Explorer (Quick)**
|
|
288
|
-
|
|
289
|
-
1. Go to [Graph API Explorer](https://developers.facebook.com/tools/explorer/)
|
|
290
|
-
2. Select your app from dropdown
|
|
291
|
-
3. Click **Generate Access Token**
|
|
292
|
-
4. Grant permissions:
|
|
293
|
-
- ✅ instagram_basic
|
|
294
|
-
- ✅ instagram_manage_messages
|
|
295
|
-
- ✅ pages_manage_metadata
|
|
296
|
-
- ✅ pages_read_engagement
|
|
297
|
-
5. Copy the generated token (starts with `EAA...`)
|
|
298
|
-
|
|
299
|
-
**Option 2: Using Access Token Tool**
|
|
300
|
-
|
|
301
|
-
1. Go to [Access Token Tool](https://developers.facebook.com/tools/accesstoken/)
|
|
302
|
-
2. Find your Page
|
|
303
|
-
3. Click **Generate Token**
|
|
304
|
-
4. Select permissions
|
|
305
|
-
5. Copy Page Access Token
|
|
306
|
-
|
|
307
|
-
#### Step 9: Get Instagram Business Account ID
|
|
308
|
-
|
|
309
|
-
**Method 1: Auto-Discovery (Easiest)**
|
|
310
|
-
|
|
311
|
-
The package automatically discovers your Instagram Business Account ID when you use the **Instagram Access Token API** credential type.
|
|
312
|
-
|
|
313
|
-
**Method 2: Manual Lookup**
|
|
314
|
-
|
|
315
|
-
1. Go to [Graph API Explorer](https://developers.facebook.com/tools/explorer/)
|
|
316
|
-
2. Use your Page Access Token
|
|
317
|
-
3. Make request:
|
|
318
|
-
```
|
|
319
|
-
GET /{page-id}?fields=instagram_business_account
|
|
320
|
-
```
|
|
321
|
-
4. Copy the `instagram_business_account.id` value
|
|
322
|
-
|
|
323
|
-
**Method 3: Using Facebook Business Manager**
|
|
324
|
-
|
|
325
|
-
1. Go to [Business Settings](https://business.facebook.com/settings/)
|
|
326
|
-
2. Click **Instagram Accounts**
|
|
327
|
-
3. Select your account
|
|
328
|
-
4. ID shown in URL or account details
|
|
329
|
-
|
|
330
|
-
---
|
|
331
|
-
|
|
332
|
-
### Part C: Configure n8n Credentials
|
|
333
|
-
|
|
334
|
-
#### Option 1: OAuth2 Setup (Recommended)
|
|
335
|
-
|
|
336
|
-
1. **Open n8n**
|
|
337
|
-
- Navigate to **Credentials** (left sidebar)
|
|
338
|
-
- Click **+ New Credential**
|
|
339
|
-
|
|
340
|
-
2. **Select Credential Type**
|
|
341
|
-
- Search for "Instagram"
|
|
342
|
-
- Select **Instagram OAuth2 API**
|
|
343
|
-
|
|
344
|
-
3. **Configure OAuth2**
|
|
345
|
-
```
|
|
346
|
-
Credential Name: Instagram Bot
|
|
347
|
-
|
|
348
|
-
Client ID: [Your App ID from Step 6]
|
|
349
|
-
Client Secret: [Your App Secret from Step 6]
|
|
350
|
-
|
|
351
|
-
OAuth Callback URL: (auto-filled by n8n)
|
|
352
|
-
Copy this URL for Meta App settings
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
4. **Update Meta App Redirect URIs**
|
|
356
|
-
- Go to Meta App → **Instagram** → **Basic Display**
|
|
357
|
-
- Add n8n's OAuth Callback URL to **Valid OAuth Redirect URIs**
|
|
358
|
-
- Save changes
|
|
359
|
-
|
|
360
|
-
5. **Authorize in n8n**
|
|
361
|
-
- Back in n8n, click **Connect my account**
|
|
362
|
-
- Popup opens → Login to Facebook
|
|
363
|
-
- Authorize permissions
|
|
364
|
-
- Popup closes → Credential saved ✅
|
|
365
|
-
|
|
366
|
-
6. **Test Connection**
|
|
367
|
-
- Click **Test credential**
|
|
368
|
-
- Should show: ✅ "Credential test successful"
|
|
369
|
-
|
|
370
|
-
#### Option 2: Access Token Setup (Alternative)
|
|
371
|
-
|
|
372
|
-
1. **Open n8n**
|
|
373
|
-
- Navigate to **Credentials**
|
|
374
|
-
- Click **+ New Credential**
|
|
375
|
-
|
|
376
|
-
2. **Select Credential Type**
|
|
377
|
-
- Search for "Instagram"
|
|
378
|
-
- Select **Instagram Access Token API**
|
|
379
|
-
|
|
380
|
-
3. **Configure Token**
|
|
381
|
-
```
|
|
382
|
-
Credential Name: Instagram Bot (Token)
|
|
383
|
-
|
|
384
|
-
Access Token: [Your Page Access Token from Step 8]
|
|
385
|
-
(Paste the entire EAA... token)
|
|
386
|
-
|
|
387
|
-
Instagram Business Account ID: (Leave empty for auto-discovery)
|
|
388
|
-
|
|
389
|
-
Webhook Verify Token: (Optional, for webhooks)
|
|
390
|
-
my_secure_verify_token_2024
|
|
391
|
-
```
|
|
392
|
-
|
|
393
|
-
4. **Save & Test**
|
|
394
|
-
- Click **Save**
|
|
395
|
-
- Account ID automatically discovered ✅
|
|
396
|
-
- Click **Test credential** to verify
|
|
397
|
-
|
|
398
|
-
---
|
|
399
|
-
|
|
400
|
-
### Part D: Webhook Configuration (For Trigger Node)
|
|
401
|
-
|
|
402
|
-
#### Step 10: Set Up Webhook in n8n
|
|
403
|
-
|
|
404
|
-
1. Create new workflow in n8n
|
|
405
|
-
2. Add **Instagram Trigger** node
|
|
406
|
-
3. Select your credential
|
|
407
|
-
4. Copy the **Webhook URL** shown
|
|
408
|
-
```
|
|
409
|
-
https://your-n8n.com/webhook/abc123-def456-ghi789
|
|
410
|
-
```
|
|
411
|
-
|
|
412
|
-
#### Step 11: Configure Webhook in Meta App
|
|
413
|
-
|
|
414
|
-
1. Go to Meta App Dashboard
|
|
415
|
-
2. Click **Instagram** → **Configuration** (or **Messenger** tab)
|
|
416
|
-
3. Scroll to **Webhooks**
|
|
417
|
-
4. Click **Add Callback URL**
|
|
418
|
-
|
|
419
|
-
5. **Fill in Webhook Settings:**
|
|
420
|
-
```
|
|
421
|
-
Callback URL: [Your n8n Webhook URL from Step 10]
|
|
422
|
-
https://your-n8n.com/webhook/abc123-def456-ghi789
|
|
423
|
-
|
|
424
|
-
Verify Token: [Same token from credential setup]
|
|
425
|
-
my_secure_verify_token_2024
|
|
426
|
-
```
|
|
427
|
-
|
|
428
|
-
6. Click **Verify and Save**
|
|
429
|
-
- Meta sends GET request to n8n
|
|
430
|
-
- n8n responds with challenge
|
|
431
|
-
- Status shows ✅ "Complete"
|
|
432
|
-
|
|
433
|
-
#### Step 12: Subscribe to Webhook Events
|
|
434
|
-
|
|
435
|
-
1. In Webhooks section, click **Add Subscriptions**
|
|
436
|
-
2. Select your Instagram Account
|
|
437
|
-
3. Check these fields:
|
|
438
|
-
- ✅ `messages`
|
|
439
|
-
- ✅ `messaging_postbacks`
|
|
440
|
-
- ✅ `messaging_optins`
|
|
441
|
-
4. Click **Save**
|
|
442
|
-
|
|
443
|
-
#### Step 13: Test Webhook
|
|
444
|
-
|
|
445
|
-
1. Send a message to your Instagram Business Account
|
|
446
|
-
2. Check n8n workflow execution
|
|
447
|
-
3. Should see incoming message data ✅
|
|
448
|
-
|
|
449
|
-
---
|
|
450
|
-
|
|
451
|
-
## OAuth2 Flow
|
|
452
|
-
|
|
453
|
-
### How It Works (v1.5.7+)
|
|
454
|
-
|
|
455
|
-
```
|
|
456
|
-
User clicks "Connect"
|
|
457
|
-
↓
|
|
458
|
-
n8n redirects to Meta login
|
|
459
|
-
↓
|
|
460
|
-
User authorizes permissions
|
|
461
|
-
↓
|
|
462
|
-
Meta redirects back to n8n
|
|
463
|
-
↓
|
|
464
|
-
n8n receives short-lived token (1 hour)
|
|
465
|
-
↓
|
|
466
|
-
First API request triggers preAuthentication:
|
|
467
|
-
↓
|
|
468
|
-
┌─────────────────────────────────────────────┐
|
|
469
|
-
│ Token Exchange (automatic) │
|
|
470
|
-
│ Short-lived token → 60-day long-lived │
|
|
471
|
-
│ Token persisted to n8n database │
|
|
472
|
-
└─────────────────────────────────────────────┘
|
|
473
|
-
↓
|
|
474
|
-
Workflow runs normally
|
|
475
|
-
↓
|
|
476
|
-
┌─────────────────────────────────────────────┐
|
|
477
|
-
│ Token Refresh (automatic, when < 7 days) │
|
|
478
|
-
│ Old token → New 60-day token │
|
|
479
|
-
│ Updated token persisted to database │
|
|
480
|
-
└─────────────────────────────────────────────┘
|
|
481
|
-
```
|
|
482
|
-
|
|
483
|
-
### Token Lifecycle (v1.5.7+)
|
|
484
|
-
|
|
485
|
-
| Stage | Token Type | Validity | Action |
|
|
486
|
-
|-------|------------|----------|--------|
|
|
487
|
-
| OAuth | Short-lived | 1 hour | Received from Meta |
|
|
488
|
-
| Exchange | Long-lived | 60 days | Automatic on first API call |
|
|
489
|
-
| Active | Long-lived | 60 days | Persisted in n8n database |
|
|
490
|
-
| Near Expiry | Long-lived | < 7 days | Auto-refreshed |
|
|
491
|
-
| Refreshed | Long-lived | 60 days | New token persisted |
|
|
492
|
-
|
|
493
|
-
**Important Notes:**
|
|
494
|
-
- ✅ Tokens survive n8n restarts, Docker container restarts, and server reboots
|
|
495
|
-
- ✅ Refresh only happens if token is at least 24 hours old (Instagram API requirement)
|
|
496
|
-
- ✅ If refresh fails but token is still valid, the existing token continues to work
|
|
497
|
-
- ⚠️ If token fully expires (workflow not run for 60+ days), user must reconnect
|
|
498
|
-
|
|
499
|
-
### Scopes Requested
|
|
500
|
-
|
|
501
|
-
```json
|
|
502
|
-
{
|
|
503
|
-
"scope": "instagram_basic,instagram_manage_messages,pages_manage_metadata,pages_read_engagement"
|
|
504
|
-
}
|
|
505
|
-
```
|
|
506
|
-
|
|
507
|
-
---
|
|
508
|
-
|
|
509
|
-
## Access Token Method (Reference Only)
|
|
510
|
-
|
|
511
|
-
> **Note:** As of v1.5.7, you don't need to manually manage tokens. The OAuth2 credential type handles all token exchange and refresh automatically. This section is kept for reference only.
|
|
512
|
-
|
|
513
|
-
### How the Package Handles Tokens Automatically
|
|
514
|
-
|
|
515
|
-
**Token Exchange** (short-lived → long-lived):
|
|
516
|
-
```
|
|
517
|
-
GET https://graph.instagram.com/access_token
|
|
518
|
-
?grant_type=ig_exchange_token
|
|
519
|
-
&client_secret=YOUR_APP_SECRET
|
|
520
|
-
&access_token=SHORT_LIVED_TOKEN
|
|
521
|
-
```
|
|
522
|
-
|
|
523
|
-
Response:
|
|
524
|
-
```json
|
|
525
|
-
{
|
|
526
|
-
"access_token": "IGQ...",
|
|
527
|
-
"token_type": "bearer",
|
|
528
|
-
"expires_in": 5183944
|
|
529
|
-
}
|
|
530
|
-
```
|
|
531
|
-
|
|
532
|
-
**Token Refresh** (when < 7 days remaining):
|
|
533
|
-
```
|
|
534
|
-
GET https://graph.instagram.com/refresh_access_token
|
|
535
|
-
?grant_type=ig_refresh_token
|
|
536
|
-
&access_token=LONG_LIVED_TOKEN
|
|
537
|
-
```
|
|
538
|
-
|
|
539
|
-
Response:
|
|
540
|
-
```json
|
|
541
|
-
{
|
|
542
|
-
"access_token": "IGQ...",
|
|
543
|
-
"token_type": "bearer",
|
|
544
|
-
"expires_in": 5183944
|
|
545
|
-
}
|
|
546
|
-
```
|
|
547
|
-
|
|
548
|
-
> **All of this is handled automatically** by the `preAuthentication` hook in the credential type. The refreshed token is persisted to n8n's database, ensuring it survives restarts.
|
|
549
|
-
|
|
550
|
-
---
|
|
551
|
-
|
|
552
|
-
## Troubleshooting
|
|
553
|
-
|
|
554
|
-
### Common Issues
|
|
555
|
-
|
|
556
|
-
#### "Invalid OAuth Access Token" (Error 190)
|
|
557
|
-
|
|
558
|
-
**Causes:**
|
|
559
|
-
- Token expired (workflow not run for 60+ days)
|
|
560
|
-
- Token revoked by user in Instagram/Facebook settings
|
|
561
|
-
- Missing required permissions
|
|
562
|
-
- App removed from user's authorized apps
|
|
563
|
-
|
|
564
|
-
**Solutions:**
|
|
565
|
-
1. **Re-authorize credential in n8n:**
|
|
566
|
-
- Go to Credentials → Instagram OAuth2 API
|
|
567
|
-
- Click "Connect my account" to re-authenticate
|
|
568
|
-
- The system will automatically get a new long-lived token
|
|
569
|
-
2. Check token expiry in [Access Token Debugger](https://developers.facebook.com/tools/debug/accesstoken/)
|
|
570
|
-
3. Verify all permissions are still granted
|
|
571
|
-
4. Check if the Instagram account is still connected to the Facebook Page
|
|
572
|
-
|
|
573
|
-
**Note (v1.5.7+):** If you see this error after an n8n restart, it may indicate the token wasn't properly persisted. Try re-authenticating once to ensure the long-lived token is stored correctly.
|
|
574
|
-
|
|
575
|
-
#### "Permission Denied" (Error 200)
|
|
576
|
-
|
|
577
|
-
**Causes:**
|
|
578
|
-
- Missing app permissions
|
|
579
|
-
- App not in live mode
|
|
580
|
-
- Business verification required
|
|
581
|
-
|
|
582
|
-
**Solutions:**
|
|
583
|
-
1. Go to Meta App → **Roles** → Add your account as admin
|
|
584
|
-
2. Request advanced permissions in **App Review**
|
|
585
|
-
3. Complete Business Verification if required
|
|
586
|
-
|
|
587
|
-
#### "Webhook Verification Failed"
|
|
588
|
-
|
|
589
|
-
**Causes:**
|
|
590
|
-
- Verify token mismatch
|
|
591
|
-
- n8n webhook not accessible
|
|
592
|
-
- Firewall blocking Meta
|
|
593
|
-
|
|
594
|
-
**Solutions:**
|
|
595
|
-
1. Ensure verify token matches exactly (case-sensitive)
|
|
596
|
-
2. Test webhook URL is publicly accessible
|
|
597
|
-
3. Check HTTPS certificate is valid
|
|
598
|
-
4. Whitelist Meta IP ranges in firewall
|
|
599
|
-
|
|
600
|
-
#### "User Cannot Receive Messages" (Error 551)
|
|
601
|
-
|
|
602
|
-
**Causes:**
|
|
603
|
-
- 24-hour messaging window expired
|
|
604
|
-
- User hasn't started conversation
|
|
605
|
-
- Account not eligible
|
|
606
|
-
|
|
607
|
-
**Solutions:**
|
|
608
|
-
1. Wait for user to message first
|
|
609
|
-
2. Use message tags for out-of-window messages
|
|
610
|
-
3. Verify account is Instagram Business Account
|
|
611
|
-
|
|
612
|
-
---
|
|
613
|
-
|
|
614
|
-
## Security Best Practices
|
|
615
|
-
|
|
616
|
-
### Protecting Credentials
|
|
617
|
-
|
|
618
|
-
- 🔒 **Never commit** credentials to version control
|
|
619
|
-
- 🔒 **Use environment variables** in production
|
|
620
|
-
- 🔒 **Rotate tokens regularly** (every 30 days)
|
|
621
|
-
- 🔒 **Limit token permissions** to minimum required
|
|
622
|
-
- 🔒 **Monitor access logs** for suspicious activity
|
|
623
|
-
|
|
624
|
-
### Webhook Security
|
|
625
|
-
|
|
626
|
-
- ✅ **Always validate** webhook signatures
|
|
627
|
-
- ✅ **Use HTTPS** for all endpoints
|
|
628
|
-
- ✅ **Verify token** is strong (20+ characters)
|
|
629
|
-
- ✅ **Rate limit** webhook endpoints
|
|
630
|
-
- ✅ **Log failures** for monitoring
|
|
631
|
-
|
|
632
|
-
### Token Storage
|
|
633
|
-
|
|
634
|
-
n8n stores credentials encrypted:
|
|
635
|
-
- Credentials encrypted at rest
|
|
636
|
-
- Encryption key in environment variable
|
|
637
|
-
- Access restricted by user permissions
|
|
638
|
-
- Audit logs for credential access
|
|
639
|
-
|
|
640
|
-
---
|
|
641
|
-
|
|
642
|
-
## FAQs
|
|
643
|
-
|
|
644
|
-
### Q: Which authentication method should I use?
|
|
645
|
-
|
|
646
|
-
**A:** Use **OAuth2** for production (automatic refresh). Use **Access Token** for testing or when you need manual control.
|
|
647
|
-
|
|
648
|
-
### Q: How long do tokens last?
|
|
649
|
-
|
|
650
|
-
**A:**
|
|
651
|
-
- Short-lived (from OAuth): 1 hour
|
|
652
|
-
- Long-lived (after exchange): 60 days
|
|
653
|
-
- **With OAuth2 credential (v1.5.7+)**: Indefinitely, as long as workflow runs at least once every 60 days
|
|
654
|
-
|
|
655
|
-
### Q: Do tokens survive n8n restarts?
|
|
656
|
-
|
|
657
|
-
**A:** Yes! As of v1.5.7, long-lived tokens are automatically persisted to n8n's database. They survive:
|
|
658
|
-
- n8n service restarts
|
|
659
|
-
- Docker container restarts
|
|
660
|
-
- Server reboots
|
|
661
|
-
- n8n updates
|
|
662
|
-
|
|
663
|
-
### Q: When does automatic token refresh happen?
|
|
664
|
-
|
|
665
|
-
**A:** The token is automatically refreshed when:
|
|
666
|
-
- Token has less than 7 days remaining before expiration
|
|
667
|
-
- Token is at least 24 hours old (Instagram API requirement)
|
|
668
|
-
- An API request is made (triggers the refresh check)
|
|
669
|
-
|
|
670
|
-
### Q: Can I use a personal Instagram account?
|
|
671
|
-
|
|
672
|
-
**A:** No, you must use an **Instagram Business Account** or **Instagram Creator Account** connected to a Facebook Page.
|
|
673
|
-
|
|
674
|
-
### Q: Do I need Instagram API approval?
|
|
675
|
-
|
|
676
|
-
**A:** For basic testing (your own account), no. For production (other users), you need to submit your app for **App Review** and get advanced permissions approved.
|
|
677
|
-
|
|
678
|
-
### Q: How do I get Instagram-scoped user IDs?
|
|
679
|
-
|
|
680
|
-
**A:** User IDs come from:
|
|
681
|
-
1. Webhook events (when users message you)
|
|
682
|
-
2. Graph API calls to conversations endpoint
|
|
683
|
-
3. User interactions with your Instagram account
|
|
684
|
-
|
|
685
|
-
### Q: Can I send messages to anyone?
|
|
686
|
-
|
|
687
|
-
**A:** No, users must initiate conversation first. After that, you have a 24-hour window to respond. Use message tags for exceptions (e.g., updates, events).
|
|
688
|
-
|
|
689
|
-
### Q: What's the rate limit?
|
|
690
|
-
|
|
691
|
-
**A:** 200 API calls per hour per user. Webhooks can receive unlimited events.
|
|
692
|
-
|
|
693
|
-
### Q: How do I test without a real Instagram account?
|
|
694
|
-
|
|
695
|
-
**A:** Use Meta's **Graph API Explorer** to test API calls. For webhooks, use tools like **ngrok** to test locally.
|
|
696
|
-
|
|
697
|
-
---
|
|
698
|
-
|
|
699
|
-
## Additional Resources
|
|
700
|
-
|
|
701
|
-
### Official Documentation
|
|
702
|
-
- 📖 [Instagram Graph API](https://developers.facebook.com/docs/instagram-api)
|
|
703
|
-
- 📖 [Instagram Messaging API](https://developers.facebook.com/docs/messenger-platform/instagram)
|
|
704
|
-
- 📖 [Webhooks Reference](https://developers.facebook.com/docs/graph-api/webhooks)
|
|
705
|
-
- 📖 [Access Tokens Guide](https://developers.facebook.com/docs/facebook-login/guides/access-tokens)
|
|
706
|
-
|
|
707
|
-
### Tools
|
|
708
|
-
- 🔧 [Graph API Explorer](https://developers.facebook.com/tools/explorer/)
|
|
709
|
-
- 🔧 [Access Token Debugger](https://developers.facebook.com/tools/debug/accesstoken/)
|
|
710
|
-
- 🔧 [Webhook Tester](https://developers.facebook.com/tools/webhooks/)
|
|
711
|
-
|
|
712
|
-
### Support
|
|
713
|
-
- 💬 [Meta Developer Community](https://developers.facebook.com/community/)
|
|
714
|
-
- 💬 [n8n Community Forum](https://community.n8n.io)
|
|
715
|
-
|
|
716
|
-
---
|
|
717
|
-
|
|
718
|
-
**Authentication setup complete!** 🎉 You're ready to build Instagram automation workflows in n8n.
|