Vapi
Voice AI platform for building conversational agents. Integrate Scrapfly to enable voice assistants that can fetch live web data during phone calls and voice interactions.
Prerequisites
Before getting started, make sure you have the following:
- Vapi account (sign up here)
- Your Scrapfly API key
- Webhook endpoint or server to handle function calls
Setup Instructions
Integrate Scrapfly with Vapi by creating function definitions and webhook handlers. This enables your voice assistants to scrape web data in real-time during conversations.
-
Create Webhook Server
Set up a webhook server to handle Vapi function calls and execute Scrapfly API requests:
Python Flask Example
Node.js Express Example
Tip: Deploy Your Webhook
Deploy your webhook server to a public URL using services like:
- Railway: Easy deployment with free tier
- Render: Free web service hosting
- Vercel/Netlify: Serverless function deployment
- ngrok: Quick local testing (development only)
-
Configure Function in Vapi Dashboard
Add a custom function to your Vapi assistant that calls your webhook:
- Log in to Vapi Dashboard
- Navigate to your assistant or create a new one
- Go to "Functions" section
- Click "Add Function"
- Configure the function with this schema:
Important: Replacehttps://your-webhook-url.comwith your actual webhook server URL. -
Configure Assistant Instructions
Update your Vapi assistant's system prompt to use the scraping function:
-
Test Your Voice Assistant
Test the integration using Vapi's dashboard or API:
- Start a test call in Vapi Dashboard
- Ask the assistant to look up information: "What are the top posts on Hacker News?"
- The assistant should call your webhook, which calls Scrapfly, and read the results
Pro Tip: Keep scraped content summaries short (under 500 characters) for natural voice delivery!
Example Prompts
Product Information Lookup
News Headlines
Business Hours Lookup
Competitive Pricing
Troubleshooting
Problem: Vapi does not call your webhook server
Solution:
- Verify webhook URL is publicly accessible (test with curl or Postman)
- Check function is properly configured in Vapi dashboard
- Ensure webhook accepts POST requests
- Review Vapi logs in dashboard for error messages
Problem: Webhook returns errors from Scrapfly API
Solution:
- Verify SCRAPFLY_API_KEY environment variable is set correctly
- Check URL format is valid (must start with http:// or https://)
- Ensure sufficient Scrapfly credits available
- Review Scrapfly API response for specific error details
Problem: Scraped content is too lengthy for voice delivery
Solution:
- Truncate content to ~500 characters max
- Use AI summarization before returning results
- Extract only key information (prices, titles, dates)
- Format responses as bullet points for clarity
Problem: Vapi times out waiting for webhook response
Solution:
- Optimize webhook code for faster response times
- Cache frequently scraped URLs
- Use Scrapfly cache parameter for repeat requests
- Return partial results quickly rather than waiting for full scrape
Problem: Assistant does not use scrape_webpage function
Solution:
- Update assistant instructions to explicitly mention using the function
- Use clearer prompts mentioning "look up", "check", or "scrape"
- Verify function schema is correct in Vapi dashboard
- Test with explicit URLs in user prompts
Next Steps
- Explore available MCP tools and their capabilities
- See real-world examples of what you can build
- Learn about authentication methods in detail
- Read the FAQ for common questions