This script is designed to integrate with the 3CX phone system to detect and handle spam calls using the Tellows API. It includes functionality for whitelisting and blacklisting specific numbers, routing calls based on spam scores, and logging events.
-
Tellows Spam Detection:
- Queries the Tellows API to get a spam score for the incoming call.
- If the spam score exceeds a configurable threshold, the call is considered spam and routed accordingly.
-
Whitelist:
- A list of phone numbers that will always be treated as non-spam, regardless of the Tellows score.
- Calls from these numbers are automatically routed to the originally dialed destination.
-
Blacklist:
- A list of phone numbers that will always be treated as spam, regardless of the Tellows score.
- Calls from these numbers are automatically routed to a predefined spam extension.
-
Call Routing:
- Non-spam calls are routed to the originally dialed destination.
- Spam calls are routed to a predefined internal spam extension.
- Configurable routing timeout to handle call forwarding and routing failures.
-
Logging:
- Logs important events, including spam detection, routing actions, and errors, to a log file.
- Logging can be enabled or disabled through the
enableLoggingvariable.
-
Configuration Options:
- API Keys: Replace with your Tellows API key and partner ID. https://blog.tellows.de/2011/07/tellows-api-fur-die-integration-in-eigene-programme/
- Whitelist and Blacklist: Specify comma-separated phone numbers in the variables
whitelistandblacklist. - Log File Path: Define the log file location in the
logFileNamevariable. - Spam Threshold: Configure the spam score threshold that triggers spam call handling.
-
API Variables:
tellowsApiKey: Your Tellows API key.tellowsPartnerID: Your Tellows partner ID.
-
Phone Number Management:
whitelist: Comma-separated list of phone numbers that are always treated as non-spam.blacklist: Comma-separated list of phone numbers that are always treated as spam.
-
Logging:
enableLogging: Set totrueorfalseto enable or disable logging.logFileName: Path to the log file where events will be recorded.
-
Spam Threshold:
tellowsThreshold: Spam score threshold (e.g., a score of 5 or higher will be treated as spam).
-
Internal Spam Extension:
internalSpamExtension: The internal extension number to which spam calls are routed.
- The script intercepts incoming calls and checks if the caller’s number is in the whitelist or blacklist.
- If the number is whitelisted, the call is routed to the originally dialed number.
- If the number is blacklisted, the call is routed to the internal spam extension.
- If the number is not on either list, the Tellows API is queried for a spam score.
- Based on the Tellows score:
- If the score exceeds the defined threshold, the call is treated as spam and routed to the spam extension.
- If the score is below the threshold, the call is treated as non-spam and routed to the originally dialed number.
- Logging captures all key events, errors, and call routing details.
- Replace the placeholder values (API keys, phone numbers, etc.) with your actual data.
- Adjust the spam threshold, timeout values, and other configurable settings as needed.
- Deploy the script in your 3CX environment and monitor the log file for events and troubleshooting.
- The Tellows API key and partner ID are required for spam detection.
- Ensure that the
logFileNamepath is accessible and writable by the script. - Test the script thoroughly in a safe environment before deploying it in production.
If this project helps you, you can give me a cup of coffee