A sophisticated chat application that integrates with Instagram Direct Messages, featuring AI-powered responses and user management through Clerk authentication.
- Instagram DM integration
- AI-powered automated responses using OpenAI
- User authentication with Clerk
- Dashboard interface
- Real-time messaging
- Automated message handling
- Custom response templates
- Analytics tracking
- Node.js (v14 or higher)
- npm or yarn
- Instagram Business/Creator Account
- OpenAI API account
- Clerk account
- Instagram Graph API access
Create a .env file in the root directory with the following configurations:
# Database Configuration
DATABASE_URL="your_database_url"
# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY="your_clerk_publishable_key"
CLERK_SECRET_KEY="your_clerk_secret_key"
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
NEXT_PUBLIC_CLERK_SIGN_IN_FORCE_REDIRECT_URL=/dashboard
NEXT_PUBLIC_CLERK_SIGN_UP_FORCE_REDIRECT_URL=/dashboard
# Application URLs
NEXT_PUBLIC_NGROK_URL="your_ngrok_url_for_development"
NEXT_PUBLIC_HOST_URL="http://localhost:3000"
# Stripe Configuration (Optional)
STRIPE_SUBSCRIPTION_PRICE_ID="your_stripe_price_id"
STRIPE_CLIENT_SECRET="your_stripe_secret"
# Instagram Configuration
INSTAGRAM_BASE_URL="https://graph.instagram.com"
INSTAGRAM_EMBEDDED_OAUTH_URL="your_instagram_oauth_url"
INSTAGRAM_CLIENT_ID="your_instagram_client_id"
INSTAGRAM_CLIENT_SECRET="your_instagram_client_secret"
INSTAGRAM_TOKEN_URL="https://api.instagram.com/oauth/access_token"
# OpenAI Configuration
OPEN_AI_KEY="your_openai_api_key"- Clone and Install:
git clone https://github.com/ParthDevInnovator/Trigly.git
cd Trigly
npm install-
Instagram Setup:
- Create a Meta Developer account
- Create a new app in Meta Developers Console
- Configure Instagram Graph API
- Set up OAuth redirect URLs
- Get your Client ID and Client Secret
-
Clerk Setup:
- Create a Clerk application
- Configure authentication settings
- Get your publishable and secret keys
-
Database Setup:
- Set up your preferred database
- Update DATABASE_URL in .env
-
OpenAI Setup:
- Get your OpenAI API key
- Add it to OPEN_AI_KEY in .env
- Start the development server:
npm run dev- For local testing with Instagram webhooks, use ngrok:
ngrok http 3000Update NEXT_PUBLIC_NGROK_URL with your ngrok URL
- Automated DM responses
- Message history tracking
- Custom response templates
- User profile management
- Analytics dashboard
- Multi-account support
- Configure Instagram Webhooks in Meta Developer Console
- Use ngrok URL for development webhook testing
- Verify webhook subscription
- Handle webhook events in the application
- Keep your Instagram access tokens secure
- Regularly rotate API keys
- Monitor API usage limits
- Test webhook handling thoroughly
- Implement rate limiting
- Handle API errors gracefully
Common issues and solutions:
-
Instagram Authentication Issues:
- Verify Instagram permissions
- Check OAuth configuration
- Validate redirect URLs
-
Webhook Problems:
- Confirm ngrok is running
- Verify webhook subscription
- Check webhook signatures
-
API Limits:
- Monitor Instagram API usage
- Implement proper rate limiting
- Handle API throttling
- Use environment variables for sensitive data
- Implement proper error handling
- Follow Instagram's API guidelines
- Maintain proper logging
- Regular testing of webhook endpoints
- Never commit .env file
- Secure storage of Instagram tokens
- Proper session management
- Rate limiting implementation
- Input validation
- Error handling
For support:
- Check documentation
- Raise GitHub issues
- Contact maintainers
Remember to handle Instagram tokens securely and follow Meta's platform policies.