• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
seyicool12

seyicool12

leadgenerationapp

Public
Like
leadgenerationapp
Home
Code
3
README.md
new-file-4170.tsx
new-file-8038.tsx
Branches
1
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
5/21/2025
README.md

untitled-6431// Val Town App - Lead Generation + Cold Email Builder

export async function leadGenApp( industry = "FinTech", solutionType = "CRM software", region = "Nigeria", jobTitle = "CTO", leadCount = 5 ) { // 🔐 NOTE: Replace this with your actual Bing Search API key const API_KEY = "YOUR_BING_API_KEY"; const SEARCH_URL = "https://api.bing.microsoft.com/v7.0/search";

// 📌 If you don’t have a Bing key, use mock search results instead const useMock = !API_KEY || API_KEY === "YOUR_BING_API_KEY";

const query = ${industry} companies in ${region} using ${solutionType}; let searchResults = [];

if (useMock) { searchResults = Array.from({ length: leadCount }).map((_, i) => ({ name: Mock Company ${i + 1}, url: https://example.com/company${i + 1}, snippet: A mock snippet about company ${i + 1} doing ${solutionType} })); } else { const response = await fetch(${SEARCH_URL}?q=${encodeURIComponent(query)}&count=${leadCount}, { headers: { "Ocp-Apim-Subscription-Key": API_KEY } });

if (!response.ok) {
  throw new Error("Failed to fetch from Bing Search API");
}

const data = await response.json();
searchResults = data.webPages?.value || [];

}

// 📧 Build leads with email pitch const leads = searchResults.map((item, i) => { const company = item.name; const website = item.url; const snippet = item.snippet;

const email = `Hi ${jobTitle},\n\nI came across ${company} while researching top companies in the ${industry} space.\nWe provide a ${solutionType} that can help you streamline operations and boost efficiency.\nWould you be open to a quick conversation?\n\nBest regards,\n[Your Name]`;

return {
  ID: i + 1,
  Company: company,
  Website: website,
  Snippet: snippet,
  ColdEmail: email.replace(/\n/g, ' ')
};

});

// 🧾 Create CSV const headers = "ID,Company,Website,Snippet,ColdEmail"; const rows = leads.map(l => "${l.ID}","${l.Company}","${l.Website}","${l.Snippet}","${l.ColdEmail}" ); const csv = [headers, ...rows].join("\n");

const blob = new Blob([csv], { type: "text/csv" });

return new File([blob], "leads.csv", { type: "text/csv" }); }

FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.