Heylock API
The Heylock API enables seamless integration of AI capabilities into your applications. Use it to enhance user experiences with natural language understanding, sorting, rewriting, and more.
Core Features
AI Conversations
Enable natural language interactions with an AI agent.
Sorting
Organize lists or collections using natural language instructions.
Text Rewriting
Rewrite text for clarity, tone, or style based on specific needs.
Engagement Timing
Identify the best moments to involve AI assistance.
Examples
AI Assistance on Websites
[Visitor] – I'm looking for a summer blouse. Where can I find it?
[Agent] – Scroll to the bottom of the page. It should be there. Are you looking for a specific blouse?
1const response = await fetch('https://heylock.dev/api/v1/message', {
2 method: 'POST',
3 headers: {
4 'Authorization': 'AGENT_KEY',
5 'Content-Type': 'application/json',
6 },
7 body: JSON.stringify({
8 content: "I'm looking for a summer blouse. Where can I find it?",
9 context: "Visitor opened the clothing section 30 seconds ago.",
10 }),
11});
{
"message": "Scroll to the bottom of the page. It should be there. Are you looking for a specific blouse?"
}
Text Rewriting
Use the API to rewrite text for specific contexts or styles.
1const userInput = "Original text to rewrite.";
2
3const response = await fetch('https://heylock.dev/api/v1/rewrite', {
4 method: 'POST',
5 headers: {
6 'Authorization': 'AGENT_KEY',
7 'Content-Type': 'application/json',
8 },
9 body: JSON.stringify({
10 text: userInput,
11 instructions: "Make it more formal.",
12 context: "This is for a business email.",
13 }),
14});
15
16const data = await response.json();
17console.log(data.text);
Smart Sorting
Sort items based on user preferences or context.
1const catalogItems = [
2 { id: 1, name: 'T-shirt' },
3 { id: 2, name: 'Jeans' },
4 { id: 3, name: 'Jacket' },
5];
6
7const response = await fetch('https://heylock.dev/api/v1/sort', {
8 method: 'POST',
9 headers: {
10 'Authorization': 'AGENT_KEY',
11 'Content-Type': 'application/json',
12 },
13 body: JSON.stringify({
14 array: catalogItems,
15 instructions: "Sort items based on what the user might prefer for winter clothing.",
16 context: "User is browsing winter clothing.",
17 }),
18});
19
20const data = await response.json();
21console.log(data.indexes); // [2, 1, 0]
1{
2 "indexes": [2, 1, 0],
3 "reasoning": "Based on the context, the user is browsing winter clothing. Jackets are most relevant, followed by jeans and then T-shirts."
4}
5
6// 2. Jacket
7// 1. Jeans
8// 0. T-shirt