Instagram Webhook
This component acts as a secure bridge between Instagram and your automation workflow. It listens for new messages, comments, or updates on your Instagram account and captures them in real time.
Instead of handling all data as a single block, this tool intelligently separates incoming information into two distinct streams: text-based messages (like Direct Messages or comments) and media files (like images or videos attached to those messages). This separation allows you to easily build different response paths in Nappai, such as using an AI model to reply to text while simultaneously analyzing uploaded photos.
How it Works
The component works by establishing a connection to the Instagram API via a secure endpoint known as a “webhook.” When a user interacts with your Instagram business profile (for example, by sending a DM or posting a comment), Instagram sends a signal to Nappai.
Upon receiving this signal, the component performs the following steps:
- Verification: It confirms that the request is coming from a legitimate source using secure tokens.
- Classification: It analyzes the incoming data to determine what type of content it is.
- Splitting: It routes text content to the Message output and image/video content to the Media output.
This structure ensures that your downstream AI agents receive clean, organized data, making it easier for them to understand whether they are reading a text or looking at an image.
Connection & Credentials
To use this component, you must first set up a secure connection to Instagram. Because this involves sensitive account data, Nappai requires you to configure a specific credential before the component will work.
- Go to the Credentials section in your Nappai dashboard.
- Create a new credential of type Instagram.
- Fill in the required fields using the guide below:
- Instagram API Identifier: Found in your Instagram settings under
Advanced > Accounts > Instagram. - Instagram API Access Token: Generated via the Meta Developers Console (see Instagram Basic Display API Guide). Ensure you have activated the permissions
instagram_basicandinstagram_manage_comments. - Verification Token: A security token required to verify webhook requests.
- Instagram API Identifier: Found in your Instagram settings under
- Return to your workflow canvas. Click on the Instagram Webhook component and select the credential you just created in the Credential input field.
Note: The technical fields for API keys and tokens are hidden from the main view to keep your interface clean. You only need to select the credential you created.
Inputs
This component is designed to be “plug-and-play” once your credential is set. It does not require manual input fields for data entry in this view, as its primary role is to receive data from external sources.
Input Fields
- Credential: Select the Instagram API credential you configured in your Nappai panel. This connects the component to your specific Instagram account.
Outputs
The component produces two distinct outputs based on the type of Instagram interaction it receives. You can connect these outputs to different parts of your AI workflow.
- Message: This output contains text-based data, such as the content of a Direct Message (DM) or a comment. Use this output to connect to Text Generation or Language Model nodes to draft replies.
- Media: This output contains data related to images or videos attached to messages or posts. Use this output to connect to Image Analysis or Computer Vision models.
Output Data Example (JSON)
Below is an example of what the Message output might look like in JSON format when a text-based interaction is received: json { “entry_id”: “17841405793864813”, “id”: “17851645989909466”, “parent_id”: “17851645989909466”, “timestamp”: “2023-09-14T22:17:03.231Z”, “from”: { “id”: “17841405822304811”, “full_name”: “Jane Doe”, “username”: “janedoe_user” }, “text”: “Hi! I have a question about your new product launch.” }
Connectivity
Typically, this component serves as the starting point (or trigger) for an Instagram-based automation workflow.
- Connect to:
- LLM / Chat Model Nodes: Connect the Message output to these nodes to have an AI read incoming DMs and generate text replies.
- Computer Vision / Image Processing Nodes: Connect the Media output to these nodes if you need to analyze images sent by users (e.g., identifying products in photos).
- Social Media Management Nodes: Connect to nodes that handle sending responses back to Instagram users.
It does not typically connect from other components, as it is designed to receive incoming data from Instagram’s servers.
Usage Example
Scenario: Automating Customer Support for Instagram DMs
- Trigger: A customer sends a Direct Message to your business Instagram account asking about pricing.
- Processing: The Instagram Webhook component captures this message.
- Routing:
- The Message output sends the text “Hi! I have a question…” to an AI Text Assistant.
- The AI Text Assistant analyzes the intent and generates a response: “Our pricing starts at $50/month.”
- Action: The generated response is sent to an Instagram API Post component to reply to the customer.
Note: If the customer sent a photo instead of text, the Media output would be triggered, allowing you to use an image recognition AI to identify the product in the photo before replying.
Tips and Best Practices
- Development Mode: This component is optimized for development. When testing locally, ensure you are using a tool like
ngrokto expose your local server to the internet so Instagram can send webhooks to your Nappai instance. - Splitting Paths: Take advantage of the dual outputs. If a message contains both text and an image, you can branch your workflow to handle both simultaneously for a richer user experience.
- Credential Management: Always update your API tokens before they expire. If your Instagram API token expires, the webhook will stop receiving data until you update the credential in Nappai.
Security Considerations
- Authentication: Ensure you use strong, unique API tokens. Never share your Instagram API Access Token or Verification Token in public forums or unsecured files.
- Data Privacy: Be mindful of the data you process. Messages and media from Instagram contain user-generated content. Ensure your AI workflows comply with relevant data protection regulations (like GDPR) when storing or analyzing this data.
- Secure Endpoints: When deploying this component to a live environment, ensure your webhook endpoint uses HTTPS to encrypt the data in transit.