Prompt Tips for Functions
The functions agent responds best to specific, well-structured prompts. Here are examples and techniques for common use cases.
Webhook Handlers
Section titled “Webhook Handlers”“Create a function that receives HubSpot workflow webhooks. When a deal moves to the ‘Closed Won’ stage, send a Slack notification with the deal name and amount.”
“Build an endpoint that listens for Stripe payment events and updates the corresponding company’s payment status in HubSpot.”
Scheduled Sync Tasks
Section titled “Scheduled Sync Tasks”“Write a scheduled function that runs every 6 hours, fetches all deals closed in the last 24 hours from HubSpot, and sends a summary email via SendGrid.”
“Create a cron function that syncs contact data from our external database to HubSpot every hour. I’ll add the database API key as a secret.”
HubSpot API Integration
Section titled “HubSpot API Integration”“Write a function that creates a new HubSpot contact when called, using the properties from the request body. Use the correct property names from my schema.”
“Build a trigger function that looks up a company by domain and returns all associated deals with their pipeline stages.”
The agent will read your CRM schema files automatically, so it uses the correct property names and pipeline IDs.
Multi-Service Integrations
Section titled “Multi-Service Integrations”“Create a webhook handler that receives a HubSpot form submission, creates a ticket in Zendesk, and sends a confirmation email via SendGrid.”
“Build a function that receives a Stripe invoice.paid event, finds the matching company in HubSpot by the Stripe customer email, and updates a custom property called ‘Last Payment Date’.”
Working with Secrets
Section titled “Working with Secrets”When your function needs API keys, tell the agent what you need:
“I need to call the Slack API. I’ll add my SLACK_BOT_TOKEN as a secret — use it from env.”
“Add HubSpot API authentication using env.HUBSPOT_API_KEY.”
The agent will define the Env interface and instruct you to add the secret in the Secrets tab.
Iterating on Code
Section titled “Iterating on Code”Build incrementally — start with the core functionality, then refine:
- “Create a basic webhook handler that logs the incoming payload.”
- “Now add validation — only process events where the event type is ‘deal.propertyChange’.”
- “Add error handling and return appropriate HTTP status codes.”
General Tips
Section titled “General Tips”- State the function type if it is not obvious — “Create a trigger function that…” or “Build a scheduled function that…”
- Name the external services you want to integrate with
- Reference specific CRM objects and properties when working with HubSpot data — the agent will verify them against your schema
- Mention secrets by name if they already exist — “Use env.STRIPE_SECRET_KEY for authentication”
- Start in Plan mode for complex multi-service integrations to review the approach before the agent writes code