@extends('layouts.app') @section('title', 'Instagram Bot – Social Networks') @section('content')

← Social Networks

Instagram Bot

Connect the Instagram Messaging API for DMs. Set the webhook URL and verify token in your Meta app to receive and send messages.

@if (session('success'))
{{ session('success') }}
@endif @if (session('verify_token_result') || session('verify_webhook_result'))
@if (session('verify_token_result'))

Token: @if(session('verify_token_ok'))✓@else✗@endif {{ session('verify_token_result') }}

@endif @if (session('verify_webhook_result'))

Webhook: @if(session('verify_webhook_ok'))✓@else○@endif {{ session('verify_webhook_result') }}

@endif
@endif @if ($errors->any())
@endif
@csrf
When unchecked, incoming Instagram DMs are logged but no automatic AI reply is sent. Requires Enable AI bot globally in Setting → Social Media. WhatsApp has its own “Enable bot” under WhatsApp Bot Settings.
Your Instagram professional account ID. With Instagram Login the API uses /me; optional for send/receive.
Use a token that works for sending DMs: usually a Facebook Page access token (Graph graph.facebook.com) for the Page linked to this Instagram professional account. Instagram Login user tokens validate on graph.instagram.com but often fail on graph.facebook.com/me/messages with error 190 unless Meta accepts them on both hosts. Scopes: instagram_business_manage_messages and instagram_business_basic. Leave blank to keep current token.
A secret string you choose. Enter the same value in Meta app → Webhooks → Verify token.
Leave empty so the bot replies to everyone. To test while the Meta app is Live without auto-replying to the public, list only the numeric sender IDs that may receive bot replies (same IDs Meta sends as sender.id in the webhook). After someone writes and is blocked, check storage/logs/instagram-webhook.log for skip: sender not in allowlist and copy sender_id here.

Webhook URL

In Meta for Developers → Your App → Instagram → Webhooks (or Configuration), set:

Subscribe to messages (and optionally message_reactions, messaging_postbacks).

Modo Live vs pruebas: si la app no está en Live, Meta suele no enviar webhooks de DMs salvo para cuentas con rol en la app o probadoras. Tokens del bot se guardan arriba (base de datos), igual que WhatsApp en su pantalla — no hace falta duplicarlos en .env. Con la app en Live, usa Allowed sender IDs arriba para limitar quién recibe respuestas automáticas; vacío = todos.

@if($setting->isConnected())

✓ Instagram Bot is connected (token set).

@else

Fill Access Token and Verify Token and save to connect.

@endif

Instagram Bot

AI-powered replies using Shopify catalog. View DM conversations from Instagram.

Conversations

Connection status

Token is checked against Meta when you open this page. Click the button below to re-check token and whether the webhook has received events.

@if($setting->isConnected()) @if($tokenValid)

✓ {{ $tokenMessage }}

@else

✗ {{ $tokenMessage }}

@endif @else

Save an Access Token above to verify connection.

@endif @if(isset($lastWebhookReceived) && $lastWebhookReceived)

✓ Webhook last received: {{ \Carbon\Carbon::parse($lastWebhookReceived)->diffForHumans() }}.

@endif
@csrf

To confirm the webhook is working, use the Test button in Meta App Dashboard → Webhooks to send a sample, or send a DM to your Instagram account.

@push('styles') @endpush @endsection