appwizard / app.js
sharon55's picture
by using python flask language we need to build an app for gaining the access from user to open all apps in the user mobile by text or voice prompt by sharing requirements over here, Title: Mobile Agentic App Launcher (NLP β†’ Open Apps, No Automation)
f7a2d86 verified
Raw History Blame Contribute Delete
2.47 kB
```javascript
// Flask backend for AppWizard
const express = require('express');
const app = express();
const port = 3000;
// Sample app registry
const appRegistry = {
"whatsapp": {
"name": "WhatsApp",
"androidPackage": "com.whatsapp",
"iosSchemes": ["whatsapp://","https://wa.me/"],
"categories": ["social","messaging"]
},
"uber": {
"name": "Uber",
"androidPackage": "com.ubercab",
"iosSchemes": ["uber://"],
"categories": ["cabs","transport"]
},
"ola": {
"name": "Ola",
"androidPackage": "com.olacabs.customer",
"iosSchemes": ["ola://"],
"categories": ["cabs","transport"]
}
};
// Intent parser
function parseIntent(input) {
input = input.toLowerCase().trim();
// Check for direct app opening
if (input.startsWith("open ")) {
const appName = input.substring(5);
for (const [id, app] of Object.entries(appRegistry)) {
if (app.name.toLowerCase().includes(appName)) {
return {
type: "open_app",
appId: id,
candidates: [id],
confidence: 0.9,
needsDisambiguation: false
};
}
}
}
// Check for categories
const categories = {
"cab": ["uber", "ola"],
"taxi": ["uber", "ola"],
"ride": ["uber", "ola"],
"food": ["swiggy", "zomato"],
"music": ["spotify", "youtube music"]
};
for (const [keyword, apps] of Object.entries(categories)) {
if (input.includes(keyword)) {
const installedApps = apps.filter(app => appRegistry[app]);
return {
type: "open_category",
category: keyword,
candidates: installedApps,
confidence: 0.7,
needsDisambiguation: installedApps.length > 1
};
}
}
return {
type: "unknown",
candidates: [],
confidence: 0,
needsDisambiguation: false
};
}
// Routes
app.get('/api/parse', (req, res) => {
const query = req.query.q;
if (!query) {
return res.status(400).json({ error: "Missing query parameter" });
}
const result = parseIntent(query);
res.json(result);
});
app.listen(port, () => {
console.log(`AppWizard backend running on port ${port}`);
});
```