Hey Vercel community! I’m building an open-source bot that generates and deploys v0 apps on Vercel directly from a text prompt—think of it like Grok generating responses, but for app creation. The bot automates simple app generation using v0’s capabilities, then deploys them via the Vercel API, retrieving the deployment URL to share (e.g., in comments or posts). I need some guidance on crafting the API payload for the /v13/deployments endpoint—specifically, how to structure the files field with v0-generated app files and ensure the deployment works smoothly to get the URL efficiently. Any examples or tips would be awesome! Happy to share more about the project or the repo if anyone’s curious. Thanks in advance!
Bot server running at http://localhost:3000
Error generating app: { error: { code: 'forbidden', message: 'Not authorized', invalidToken: true }}Test failed: Request failed with status code 403Already check that the token is correct.
const generateAndDeployApp = async (prompt) => { try { const payload = { name: 'my-v0bot-app', files: [ { file: 'index.html', data: Buffer.from('<html><body>Hello!</body></html>').toString('base64') } ], projectSettings: { framework: null } };
const response = await axios.post(VERCEL_DEPLOYMENT_URL, payload, { headers: { 'Authorization': `Bearer ${VERCEL_API_TOKEN}`, 'Content-Type': 'application/json' } });
return response.data.url; } catch (error) { console.error('Error generating app:', error.response?.data || error.message); throw error; }};