--- name: asterisk-tester description: Тестирование сценариев Asterisk dialplan и потоков звонков используя безопасные Local каналы. Использовать при тестировании логики маршрутизации звонков, отладке проблем dialplan или проверке потоков IVR меню. allowed-tools: Bash, Read, Grep, Glob --- # asterisk-dialplan-testing Tests Asterisk dialplan scenarios and call flows to verify they work as expected. ## What this skill does - Tests dialplan contexts and extensions - Simulates call flows through the dialplan - Verifies routing logic and conditions - Tests IVR menus and time conditions - Validates AGI/AMI integrations - Checks pattern matching and regular expressions ## When to use this skill Use this skill when: - Creating or modifying dialplan scenarios - Testing call routing logic - Verifying IVR menu flows - Debugging call issues - Testing time-based routing - Validating custom dialplan applications ## How to use this skill Simply describe what you want to test: - "Test calling extension 201" - "Simulate call flow through IVR menu" - "Test emergency number routing" - "Verify time condition for night mode" - "Test pattern matching for international calls" ## Instructions You are an expert Asterisk dialplan tester. When invoked: 1. **Understand the test scenario** from the user's request: - Which extension/pattern to test - Expected call flow - Conditions to verify (time, caller ID, etc.) - Success criteria 2. **Access Asterisk CLI** in the Docker container: ```bash # Get container ID docker ps | grep mikopbx # Access Asterisk CLI docker exec -it asterisk -rvvv ``` 3. **Analyze dialplan** before testing: ```bash # Show specific context docker exec asterisk -rx "dialplan show " # Show specific extension docker exec asterisk -rx "dialplan show @" # Search for pattern docker exec asterisk -rx "dialplan show" | grep -A 10 "" ``` 4. **Use dialplan simulation** tools: ```bash # Test extension matching docker exec asterisk -rx "dialplan show @" # Simulate call flow (requires custom AGI or debug) docker exec asterisk -rx "core set verbose 5" docker exec asterisk -rx "core set debug 5" ``` 5. **Test with originate command** for real call simulation: ```bash # Originate a test call docker exec asterisk -rx "channel originate Local/@ application Wait 10" # Test with specific caller ID docker exec asterisk -rx "channel originate Local/@ application Playback demo-congrats" ``` 6. **Monitor call flow** in real-time: ```bash # Enable verbose logging docker exec asterisk -rx "core set verbose 10" # Watch dialplan execution docker exec asterisk -rx "dialplan set debug on" # Follow logs during test docker exec tail -f /var/log/asterisk/full ``` 7. **Test specific scenarios**: **IVR Testing**: ```bash # Check IVR structure docker exec asterisk -rx "dialplan show ivr-@" # Test DTMF handling docker exec asterisk -rx "channel originate Local/@ application Read digits,/var/lib/asterisk/sounds/en/beep,1" ``` **Time Condition Testing**: ```bash # Check current time conditions docker exec asterisk -rx "dialplan show" | grep -i "gotoiftime" # Verify time expressions # (requires checking dialplan logic) ``` **Pattern Matching**: ```bash # Test pattern match docker exec asterisk -rx "dialplan show @" # Should show which pattern matched ``` **Call Recording**: ```bash # Verify recording is enabled docker exec asterisk -rx "dialplan show" | grep -i "mixmonitor" ``` 8. **Database verification**: ```bash # Check extension in database docker exec sqlite3 /cf/conf/mikopbx.db "SELECT * FROM extensions WHERE number=''" # Check routing rules docker exec sqlite3 /cf/conf/mikopbx.db "SELECT * FROM m_IncomingRoutes" docker exec sqlite3 /cf/conf/mikopbx.db "SELECT * FROM m_OutgoingRoutes" ``` 9. **Report test results** in this format: ``` ## Dialplan Test Results ### Scenario: - Status: ✅ Passed / ❌ Failed / ⚠️ Warning ### Test Configuration - Extension: - Context: - Caller ID: - Time: ### Call Flow 1. [Step]: 2. [Step]: 3. ... ### Verification Points - ✅ Extension matched: - ✅ Routing correct: - ❌ Recording failed: - ⚠️ Timeout occurred:
### Dialplan Execution ``` ``` ### Issues Found - : - : ### Recommendations - - ``` 10. **Common test patterns**: **Basic extension call**: ```bash # Test extension 201 can receive calls docker exec asterisk -rx "dialplan show 201@internal" docker exec asterisk -rx "channel originate Local/201@internal application Playback demo-congrats" ``` **Outbound routing**: ```bash # Test outbound number pattern docker exec asterisk -rx "dialplan show 79001234567@outgoing" ``` **IVR menu**: ```bash # Show IVR structure docker exec asterisk -rx "dialplan show ivr-main@internal" # Test each menu option docker exec asterisk -rx "dialplan show 1@ivr-main" ``` ## Advanced testing techniques ### Test with AMI (Asterisk Manager Interface) ```bash # Connect to AMI docker exec asterisk -rx "manager show connected" # Can use curl for AMI actions curl -u admin:password http://localhost:8088/asterisk/rawman?action=Originate&Channel=Local/201@internal&Exten=202&Context=internal&Priority=1 ``` ### Test with AGI scripts ```bash # Check AGI scripts docker exec ls -la /var/lib/asterisk/agi-bin/ # Test AGI execution docker exec /var/lib/asterisk/agi-bin/