Skip to main content 홈 크리에이터 jeremylongshore tons-of-skills-marketplace perplexity-webhooks-events
perplexity-webhooks-events Build event-driven architectures around Perplexity Sonar API with streaming,
batch pipelines, and scheduled search monitoring.
Trigger with phrases like "perplexity streaming", "perplexity events",
"perplexity batch search", "perplexity news monitor", "perplexity SSE".
설치로 이동 Skills Marketplace 커뮤니티가 만든 AI 스킬을 발견하고 탐색하세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/jeremylongshore/tons-of-skills-marketplace --skill perplexity-webhooks-events명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
Zip 다운로드 다운로드 중... 이 저장소의 다른 Skills langchain-deploy-integration Deploy a LangChain 1.0 / LangGraph 1.0 app to Cloud Run, Vercel, or LangServe correctly — with timeouts sized for chain length, cold-start mitigation, SSE anti-buffering headers, and Secret Manager over .env. Use when prepping a first production deploy, debugging a stream that hangs behind a proxy, or diagnosing p99 latency spikes. Trigger with "langchain deploy", "langchain cloud run", "langchain vercel python", "langchain langserve", or "langchain docker".
langchain-langgraph-agents Build a correct LangGraph 1.0 ReAct agent with create_react_agent — typed tools, error propagation, recursion caps, and stop conditions that actually stop. Use when writing a first tool-calling agent, migrating from AgentExecutor or initialize_agent, or diagnosing an agent that loops on vague prompts. Trigger with "langgraph agent", "create_react_agent", "langgraph tool calling", "AgentExecutor migration", or "agent loop cost".
langchain-langgraph-human-in-loop Build LangGraph 1.0 human-in-the-loop approval flows with interrupt_before /
interrupt_after and Command(resume=...) — JSON-serializable state, clean
resume semantics, and UI wiring for approval decisions. Use when adding an
approval gate before an expensive tool call, wiring a Slack/web UI for agent
approvals, or debugging a graph that crashes on interrupt.
Trigger with "langgraph human in loop", "langgraph interrupt_before",
"langgraph approval flow", "Command resume", "langgraph HITL".
jeremylongshore
jeremylongshore/tons-of-skills-marketplace
GitHub 저장소 열기 name perplexity-webhooks-events description Build event-driven architectures around Perplexity Sonar API with streaming,
batch pipelines, and scheduled search monitoring.
Trigger with phrases like "perplexity streaming", "perplexity events",
"perplexity batch search", "perplexity news monitor", "perplexity SSE".
allowed-tools Read, Write, Edit, Bash(curl:*) version 1.12.0 license MIT author Jeremy Longshore <jeremy@intentsolutions.io> tags ["saas","perplexity","webhooks"] compatibility Designed for Claude Code
Perplexity Events & Async Patterns
Overview
Build event-driven architectures around Perplexity Sonar API. Perplexity does not have webhooks -- all interactions are request/response. Event patterns are built using streaming SSE, job queues for batch processing, and cron-triggered monitoring.
Event Patterns
Pattern Trigger Use Case Streaming SSE Client request Real-time search with progressive rendering Batch queue Job submission Research automation, report generation Scheduled search Cron job News monitoring, trend alerts, competitive intel Citation pipeline Post-processing Source verification, link validation
Prerequisites
openai package installed
PERPLEXITY_API_KEY set
Queue system (BullMQ, SQS) for batch patterns
Cron scheduler for monitoring patterns
Instructions
Step 1: Streaming Search (Server-Sent Events)
import OpenAI from "openai" ;
import express from "express" ;
const perplexity = new OpenAI ({
apiKey : process.env .PERPLEXITY_API_KEY !,
baseURL : "https://api.perplexity.ai" ,
});
const app = express ();
app.use (express.json ());
app.post ("/api/search/stream" , async (req, res) => {
const { query, model = "sonar" } = req.body ;
res. ( , {
: ,
: ,
: ,
});
{
stream = perplexity. . . ({
model,
: [{ : , : query }],
: ,
: ,
});
fullText = ;
( chunk stream) {
text = chunk. [ ]?. ?. || ;
fullText += text;
res. ( );
citations = (chunk ). ;
(citations) {
res. ( );
}
}
res. ( );
} ( : ) {
res. ( );
}
res. ();
});
writeHead
200
"Content-Type"
"text/event-stream"
"Cache-Control"
"no-cache"
Connection
"keep-alive"
try
const
await
chat
completions
create
messages
role
"user"
content
stream
true
max_tokens
2048
let
""
for
await
const
of
const
choices
0
delta
content
""
write
`data: ${JSON .stringify({ type : "text" , content: text })} \n\n`
const
as
any
citations
if
write
`data: ${JSON .stringify({ type : "citations" , urls: citations })} \n\n`
write
`data: ${JSON .stringify({ type : "done" , totalLength: fullText.length })} \n\n`
catch
err
any
write
`data: ${JSON .stringify({ type : "error" , message: err.message })} \n\n`
end
Step 2: Batch Research Pipeline import { Queue , Worker } from "bullmq" ;
const searchQueue = new Queue ("perplexity-research" , {
connection : { host : "localhost" , port : 6379 },
});
async function submitResearchBatch (
queries : string [],
callbackUrl : string ,
model : string = "sonar-pro"
) {
const batchId = crypto.randomUUID ();
for (const query of queries) {
await searchQueue.add ("search" , { batchId, query, callbackUrl, model }, {
attempts : 3 ,
backoff : { type : "exponential" , delay : 2000 },
});
}
return { batchId, totalQueries : queries.length };
}
const worker = new Worker ("perplexity-research" , async (job) => {
const { query, callbackUrl, batchId, model } = job.data ;
const response = await perplexity.chat .completions .create ({
model,
messages : [{ role : "user" , content : query }],
max_tokens : 2048 ,
});
const result = {
event : "perplexity.search.completed" ,
batchId,
query,
answer : response.choices [0 ].message .content ,
citations : (response as any ).citations || [],
model : response.model ,
tokens : response.usage ?.total_tokens ,
};
await fetch (callbackUrl, {
method : "POST" ,
headers : { "Content-Type" : "application/json" },
body : JSON .stringify (result),
});
}, {
connection : { host : "localhost" , port : 6379 },
concurrency : 3 ,
limiter : { max : 40 , duration : 60000 },
});
Step 3: Scheduled News Monitor
async function monitorTopics (
topics : string [],
webhookUrl : string
) {
for (const topic of topics) {
const response = await perplexity.chat .completions .create ({
model : "sonar" ,
messages : [{
role : "system" ,
content : "Summarize the latest developments. Be concise. Include only new information." ,
}, {
role : "user" ,
content : `Latest developments about "${topic} " in the past 24 hours` ,
}],
search_recency_filter : "day" ,
max_tokens : 500 ,
} as any );
const answer = response.choices [0 ].message .content || "" ;
const citations = (response as any ).citations || [];
if (citations.length > 0 && answer.length > 100 ) {
await fetch (webhookUrl, {
method : "POST" ,
headers : { "Content-Type" : "application/json" },
body : JSON .stringify ({
event : "perplexity.monitor.update" ,
topic,
summary : answer,
citations,
timestamp : new Date ().toISOString (),
}),
});
}
await new Promise ((r ) => setTimeout (r, 2000 ));
}
}
Step 4: Client-Side SSE Consumer
function consumeSearchStream (
query : string ,
onText : (text: string ) => void ,
onCitations : (urls: string []) => void ,
onDone : () => void
) {
fetch ("/api/search/stream" , {
method : "POST" ,
headers : { "Content-Type" : "application/json" },
body : JSON .stringify ({ query }),
}).then (async (response) => {
const reader = response.body !.getReader ();
const decoder = new TextDecoder ();
while (true ) {
const { done, value } = await reader.read ();
if (done) break ;
const lines = decoder.decode (value).split ("\n" );
for (const line of lines) {
if (!line.startsWith ("data: " )) continue ;
const event = JSON .parse (line.slice (6 ));
if (event.type === "text" ) onText (event.content );
if (event.type === "citations" ) onCitations (event.urls );
if (event.type === "done" ) onDone ();
}
}
});
}
Error Handling Issue Cause Solution Stream stalls Complex search taking too long Set per-chunk timeout (10s) 429 in batch Too many concurrent workers Reduce concurrency, add rate limiter Empty monitor alerts Topic too niche Broaden topic or reduce recency filter Callback fails Webhook URL down Retry with exponential backoff
Output
Streaming SSE endpoint for real-time search
Batch research pipeline with queue-based processing
Scheduled news monitoring with alerting
Client-side stream consumer
Resources
Next Steps For deployment setup, see perplexity-deploy-integration.