Vapi

Vapi logo

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.

AI Voice Platform Cloud REST API Webhooks Official Website

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
Note: Vapi does not directly support MCP servers. Instead, we integrate Scrapfly through function calling, where your webhook server calls Scrapfly's API when the voice assistant needs web data.

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.

  1. 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)
  2. Configure Function in Vapi Dashboard

    Add a custom function to your Vapi assistant that calls your webhook:

    1. Log in to Vapi Dashboard
    2. Navigate to your assistant or create a new one
    3. Go to "Functions" section
    4. Click "Add Function"
    5. Configure the function with this schema:
    Important: Replace https://your-webhook-url.com with your actual webhook server URL.
  3. Configure Assistant Instructions

    Update your Vapi assistant's system prompt to use the scraping function:

  4. Test Your Voice Assistant

    Test the integration using Vapi's dashboard or API:

    1. Start a test call in Vapi Dashboard
    2. Ask the assistant to look up information: "What are the top posts on Hacker News?"
    3. 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
Check the current price and availability on this product page: [URL]
News Headlines
What are the top stories on Hacker News right now?
Business Hours Lookup
Look up the business hours from their website
Competitive Pricing
Compare the pricing on these competitor websites: [URL1, URL2]

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

Summary