https://retellai.com/?utm_source=discord&utm_medium=seo logo
what's the best way to detect whether a call was s...
# ❓・ai-evy-support
a
@AI Evy what's the best way to detect whether a call was spam via the call_analyzed webhook?
a
Thanks for tagging me @Andreas. I'll look through relevant sources and get back to you shortly.
### Answer The best approach is to create a custom post-call analysis field to detect spam calls. Here's how: ## Set Up a Custom Analysis Category Post-call analysis supports several data types you can use for spam detection [(1) ]() : - Boolean (True/False) – Create a field like
is_spam
that returns true/false based on conversation patterns - Selector (Enum) – Create a field with categories like "spam", "legitimate", "unknown" - Text (String) – Extract details about why a call might be spam ## Consume via Webhook When the
call_analyzed
webhook fires, the payload includes the
call_analysis
object [(2) ]() [(3) ]() :
Copy code
json
{
  "event_type": "call_analyzed",
  "call": {
    // Call object with call_analysis field populated
  }
}
[(2) ]() The
call_analysis
object contains your custom fields in
custom_analysis_data
[(4) ]() :
Copy code
json
"call_analysis": {
  "call_summary": "...",
  "in_voicemail": false,
  "user_sentiment": "Positive",
  "call_successful": true,
  "custom_analysis_data": {}
}
## Important Notes - Post-call analysis fields will not be populated for calls that were not connected or where no conversation took place—check whether the field exists before using it [(2) ]() [(1) ]() - If a call doesn't connect (e.g.,
dial_no_answer
) , no meaningful analysis will occur [(5) ]() Define your spam detection criteria in the custom analysis settings (e.g., short call duration, no meaningful conversation, specific keywords) , and then check the
custom_analysis_data
field in the webhook payload.
​ To learn more, see the sources I considered: [[1] Post Call Analysis Overview](https://docs.retellai.com/features/post-call-analysis-overview) [[2] Consume the analysis data](https://docs.retellai.com/features/post-call-analysis-consumption) [[3] Webhook Overview](https://docs.retellai.com/features/webhook-overview) [[4] Get Call](https://docs.retellai.com/api-references/get-call) [[5] No "call_analyzed" webhook for some disconnection reasons](https://community.retellai.com/t/no-call-analyzed-webhook-for-some-disconnection-reasons/387) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.