Unlisted
Like
leads
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.
Viewing readonly version of simplified branch: v100View latest version
AI-powered lead filtering from any data source.
- Click Remix
- Save your
OPENAI_API_KEYas an environment variable - Customize
PROMPT.txt. Don't remove anything from the structured output. (But you can add fields!) - Get the val's HTTP endpoint from
main.ts: - Forward any leads to the val's HTTP endpoint as a POST request.
- That's it! You now have a growing
leadssqlite table with one column for your originalinput_dataand second column for the AI evaluator'soutput_data.
- When a new lead comes in via POST, it is sent to the OpenAI agent in
agent.ts. - The agent uses web search and the lead data from your POST request to determine if it's a
matchfor the criteria inPROMPT.txt. By default, the AI'soutput_dataincludesmatch(trueorfalse), it'sreasoning, and a normalizednamefor the lead. - The
input_dataand agent'soutput_dataeach get a column in theleadssqlite table. - The
main.tsdashboard shows a history of all lead assessments, successful matches first. Clicking any lead shows the full inbound and output data from the assessment.
- You can add any number of fields to the AI's output instructions in
PROMPT.txtand they'll be added to theoutput_datajson in the sqlite table and be viewable in the dashboard. This can be used to add more colr to the AI's assessments or simply normalize data from different sources. - You can also add query parameters to the end of your val endpoint. (ex:
yourval.val.run?source=singup-page). They'll be bundled in the_queryobject of 'input_data.' This can be useful for tracking where a lead came from.