Author: Philodi
Email: me@philodi.com
Website: https://philodi.com
- Overview
- Features
- Prerequisites
- Quick Start
- Installation
- Configuration
- Usage
- API Reference
- Deployment
- Contributing
- License
PHILIA Recipe Engine is an intelligent Facebook Messenger bot that provides personalized food recommendations and recipe suggestions. Originally developed as an Alexa conversation skill, it now offers over 2 million indexed, standardized recipes with complete nutritional information.
The bot enables users to search for recipes by:
- Nutrient quantities (protein, carbs, calories, etc.)
- 40+ dietary restrictions (vegan, gluten-free, keto, etc.)
- Health labels (low-sodium, heart-healthy, etc.)
- Cuisine types (Chinese, Italian, Indian, French, etc.)
- Meal types (breakfast, lunch, dinner, snacks)
- Dish types (soup, salad, pizza, sandwich, etc.)
- π€ Intelligent Chat Interface - Natural language processing for recipe queries
- π½οΈ 2M+ Recipes - Comprehensive database with nutritional information
- π― Dietary Filtering - Support for 40+ diet types and health labels
- π Global Cuisines - Recipes from around the world
- π± Facebook Messenger Integration - Seamless user experience
- π Smart Search - Keyword and category-based recipe discovery
- π Nutritional Data - Complete nutritional breakdown for each recipe
- πΌοΈ Recipe Images - Visual recipe previews
Before you begin, ensure you have the following:
- Facebook Developer Account
- Node.js (v16 or higher)
- GitHub Account
- Heroku Account (for deployment)
- Terminal/Command Line access
# Clone the repository
git clone https://github.com/Phil-Jayz/philia-bot-messenger.git
cd philia-bot-messenger
# Install dependencies
npm install
# Start the server
npm startgit clone https://github.com/Phil-Jayz/philia-bot-messenger.git
cd philia-bot-messengernpm installCreate a .env file in the root directory:
PORT=8001
FACEBOOK_ACCESS_TOKEN=your_facebook_access_token
VERIFY_TOKEN=your_verify_tokennpm startThe server will start on port 8001 (or the port specified in your environment variables).
-
Create a Facebook Page
- Go to Facebook Pages
- Choose a page name, category, and description
- Click "Create Page"
-
Create a Facebook App
- Visit Facebook Developers
- Click "Create App"
- Select "Manage Business Integrations"
- Fill in app details and create
-
Configure Messenger
- In your app, click the "Messenger" icon
- Click "Set Up"
- Generate a Page Access Token
- Configure webhooks with your server URL
// Your webhook URL should be: https://your-app.herokuapp.com/
// Verify Token: Your chosen verification token
// Subscription Fields: messagesUsers can interact with the bot using natural language:
User: "Hello"
Bot: "Welcome to philia, your personal food recommendation assistant..."
User: "Can I get a high-protein meal?"
Bot: "In that case, I recommend that you take [Recipe Name]"
[Recipe Image]
User: "Do you have Italian food?"
Bot: "In that case, I recommend that you take [Italian Recipe]"
[Recipe Image]
| Command Type | Examples |
|---|---|
| Dietary Requests | "Can I get a low-carb meal?", "Do you have vegan options?" |
| Cuisine Types | "Show me Italian food", "I want Chinese recipes" |
| Meal Types | "Breakfast ideas", "Lunch suggestions" |
| Dish Types | "Pizza recipes", "Soup options" |
| General | "Help", "Thank you", "Goodbye" |
Facebook verification endpoint for webhook setup.
Parameters:
hub.mode: Must be "subscribe"hub.verify_token: Your verification tokenhub.challenge: Facebook's challenge string
Handles incoming messages from Facebook Messenger.
Request Body:
{
"object": "page",
"entry": [{
"messaging": [{
"sender": {"id": "user_id"},
"message": {"text": "user_message"}
}]
}]
}The methods.js file provides the following methods:
sendText(text, id)- Send text message to usersendImageAttachment(image, id)- Send image with recipegetMessageObject(json)- Extract message and user ID from webhook data
-
Install Heroku CLI
npm install -g heroku
-
Login to Heroku
heroku login
-
Create Heroku App
heroku create your-app-name
-
Set Environment Variables
heroku config:set FACEBOOK_ACCESS_TOKEN=your_token heroku config:set VERIFY_TOKEN=your_verify_token
-
Deploy
git push heroku main
-
Create Dockerfile
FROM node:16-alpine WORKDIR /app COPY package*.json ./ RUN npm ci --only=production COPY . . EXPOSE 8001 CMD ["npm", "start"]
-
Create .dockerignore
node_modules npm-debug.log .git .gitignore README.md .env -
Build and Run
# Build the image docker build -t philia-bot . # Run the container docker run -p 8001:8001 \ -e FACEBOOK_ACCESS_TOKEN=your_token \ -e VERIFY_TOKEN=your_verify_token \ philia-bot
-
Using Docker Compose
# docker-compose.yml version: '3.8' services: philia-bot: build: . ports: - "8001:8001" environment: - FACEBOOK_ACCESS_TOKEN=${FACEBOOK_ACCESS_TOKEN} - VERIFY_TOKEN=${VERIFY_TOKEN} restart: unless-stopped
docker-compose up -d
-
Create Kubernetes Deployment
# k8s/deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: philia-bot labels: app: philia-bot spec: replicas: 3 selector: matchLabels: app: philia-bot template: metadata: labels: app: philia-bot spec: containers: - name: philia-bot image: your-registry/philia-bot:latest ports: - containerPort: 8001 env: - name: FACEBOOK_ACCESS_TOKEN valueFrom: secretKeyRef: name: philia-secrets key: facebook-token - name: VERIFY_TOKEN valueFrom: secretKeyRef: name: philia-secrets key: verify-token resources: requests: memory: "128Mi" cpu: "100m" limits: memory: "256Mi" cpu: "200m"
-
Create Service
# k8s/service.yaml apiVersion: v1 kind: Service metadata: name: philia-bot-service spec: selector: app: philia-bot ports: - protocol: TCP port: 80 targetPort: 8001 type: LoadBalancer
-
Create Secrets
kubectl create secret generic philia-secrets \ --from-literal=facebook-token=your_token \ --from-literal=verify-token=your_verify_token
-
Deploy to Kubernetes
kubectl apply -f k8s/
-
Create ECR Repository
aws ecr create-repository --repository-name philia-bot
-
Build and Push to ECR
# Get login token aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin your-account.dkr.ecr.us-east-1.amazonaws.com # Build and tag docker build -t philia-bot . docker tag philia-bot:latest your-account.dkr.ecr.us-east-1.amazonaws.com/philia-bot:latest # Push to ECR docker push your-account.dkr.ecr.us-east-1.amazonaws.com/philia-bot:latest
-
Create Task Definition
{ "family": "philia-bot", "networkMode": "awsvpc", "requiresCompatibilities": ["FARGATE"], "cpu": "256", "memory": "512", "executionRoleArn": "arn:aws:iam::your-account:role/ecsTaskExecutionRole", "containerDefinitions": [ { "name": "philia-bot", "image": "your-account.dkr.ecr.us-east-1.amazonaws.com/philia-bot:latest", "portMappings": [ { "containerPort": 8001, "protocol": "tcp" } ], "environment": [ { "name": "FACEBOOK_ACCESS_TOKEN", "value": "your_token" }, { "name": "VERIFY_TOKEN", "value": "your_verify_token" } ], "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "/ecs/philia-bot", "awslogs-region": "us-east-1", "awslogs-stream-prefix": "ecs" } } } ] } -
Create ECS Service
aws ecs create-service \ --cluster your-cluster \ --service-name philia-bot \ --task-definition philia-bot:1 \ --desired-count 2 \ --launch-type FARGATE \ --network-configuration "awsvpcConfiguration={subnets=[subnet-12345],securityGroups=[sg-12345],assignPublicIp=ENABLED}"
-
Create Lambda Function
// lambda.js const serverless = require('serverless-http'); const app = require('./index'); module.exports.handler = serverless(app);
-
Create serverless.yml
service: philia-bot provider: name: aws runtime: nodejs16.x region: us-east-1 environment: FACEBOOK_ACCESS_TOKEN: ${env:FACEBOOK_ACCESS_TOKEN} VERIFY_TOKEN: ${env:VERIFY_TOKEN} functions: webhook: handler: lambda.handler events: - http: path: / method: get - http: path: / method: post
-
Deploy with Serverless Framework
npm install -g serverless serverless deploy
-
Enable Required APIs
gcloud services enable run.googleapis.com gcloud services enable containerregistry.googleapis.com
-
Build and Push to Container Registry
# Build the image docker build -t gcr.io/your-project/philia-bot . # Push to Container Registry docker push gcr.io/your-project/philia-bot
-
Deploy to Cloud Run
gcloud run deploy philia-bot \ --image gcr.io/your-project/philia-bot \ --platform managed \ --region us-central1 \ --allow-unauthenticated \ --set-env-vars FACEBOOK_ACCESS_TOKEN=your_token,VERIFY_TOKEN=your_verify_token
-
Create GKE Cluster
gcloud container clusters create philia-cluster \ --zone us-central1-a \ --num-nodes 3 \ --machine-type e2-medium
-
Deploy to GKE
# Build and push to Container Registry docker build -t gcr.io/your-project/philia-bot . docker push gcr.io/your-project/philia-bot # Apply Kubernetes manifests kubectl apply -f k8s/
| Variable | Description | Required |
|---|---|---|
PORT |
Server port | No (default: 8001) |
FACEBOOK_ACCESS_TOKEN |
Facebook page access token | Yes |
VERIFY_TOKEN |
Webhook verification token | Yes |
We welcome contributions! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Add voice interface support
- Integrate with Wit.ai for better NLP
- Add recipe rating system
- Implement user preferences storage
- Add meal planning features
- Support for recipe sharing
- Add nutritional goal tracking
This project is licensed under the MIT License - see the LICENSE file for details.
- Facebook Developer Circles for tutorial examples
- Edamam API for recipe data
- Heroku for hosting platform
- Node.js community for excellent tools and libraries
If you have any questions or need help:
- Email: me@philodi.com
- Website: https://philodi.com
- GitHub Issues: Create an issue
Happy Cooking! π³
Built with β€οΈ by Philodi