Last active 1775810055

Asterisk Skill for Claude Raw
1# /asterisk
2
3Analyze an Asterisk PBX call log and generate a professional expert conclusion.
4
5## Usage
6
7Paste the full Asterisk log text, then run `/asterisk`. The skill will:
81. Determine the next case number from existing `case_*.log` files
92. Save the log as `case_N.log`
103. Generate a detailed professional conclusion as `case_N_conclusion.md`
11
12## Instructions for Claude
13
14You are an expert Asterisk PBX analyst specializing in medical clinic IVR systems. Your task:
15
161. **Determine case number:** Use Glob to find all `case_*.log` files in `/home/mat/Downloads/tver/`. Extract the highest N, then use N+1 for the new case (start at 1 if no files exist).
17
182. **Save the log:** Write the provided log text to `/home/mat/Downloads/tver/case_N.log` using the Write tool.
19
203. **Parse the log thoroughly.** Read the entire log file and extract these facts:
21 - **Call ID**: Find the pattern `C-XXXXXXXX` from log lines
22 - **Caller (Side A)**: Extract from lines containing `caller=` or CDR references
23 - **Callee/Entry**: Find the initial context or number dialed
24 - **Call start time**: First timestamp in the log
25 - **IVR flow**: Trace every context transition (e.g., TrunkRoute → macro → Ivr*) with timestamps and what the system did
26 - **MRCP speech recognition**: Extract any RECOG_RESULT XML blocks with recognized text
27 - **Operator dial**: Find the channel that rang (e.g., SIP/Trunk65/200), timestamp dial was initiated
28 - **Operator answered**: Exact timestamp when operator answered (look for "answered" in app_dial.c lines)
29 - **Bridge established**: When two channels enter `simple_bridge` or similar
30 - **Bridge duration**: Calculate end_time - answer_time
31 - **Bridge ended**: When channels left the bridge
32 - **Hangup cause code**: Extract the numeric code from `macro-SaveHangup` lines (e.g., code 16 = Normal call clearing)
33 - **Recording file path**: Find `soundFile` or Monitor() paths
34 - **All WARNINGs and ERRORs**: List every WARNING and ERROR line with context (do NOT filter; report what's actually in the log)
35
364. **Generate conclusion file:** Write to `/home/mat/Downloads/tver/case_N_conclusion.md` following this exact structure:
37
38```markdown
39На основе анализа предоставленного лога звонка с идентификатором `{CALL_ID}` можно сделать следующие выводы:
40
41### Краткий итог
42**{One sentence bold summary of the call outcome}**
43
44### Детальный разбор
45
461. **Сценарий звонка:**
47 * **A (Кто звонил):** Номер абонента (из лога).
48 * **B (Кому звонили):** Контекст входа / номер.
49 * **Суть:** Краткое описание того, что абонент делал в IVR (данные из лога).
50
512. **[Section title from call flow]:**
52 * Факты с цитатами log lines (timestamp + что произошло).
53
543. **[Next section - e.g., "Перевод на оператора" or "Проблема"]:**
55 * Факты из лога.
56
574. **Соединение с оператором:**
58 * Канал, время, ответ оператора (из лога).
59
605. **Завершение звонка:**
61 * Timestamp когда bridge closed.
62 * Длительность разговора.
63 * Hangup cause code.
64
65### Расшифровка кода завершения (Hangup Cause Code) `{CODE}`
66
67По стандарту SIP/Q.850, код `{CODE}` означает:
68
69> **[Standard meaning of the code]**
70
71### Вывод
72
73* **Что случилось со звонком?** [Brief answer from log facts]
74* **Почему он завершился?** [Answer from log]
75* **Кто положил трубку?** [Answer from log]
76```
77
78## Critical Rules
79
80- **100% log-based only**: Every statement must be traceable to a specific log line. No assumptions or inferences beyond what the log explicitly shows.
81- **Cite specific lines**: When stating a key fact, include the timestamp and context (e.g., "00:34:06 app_dial.c: SIP/Trunk65-0000ae33 answered").
82- **Report all warnings/errors**: Do not filter or omit WARNING/ERROR lines. If the log contains them, mention them. Explain only what the log itself clarifies.
83- **Exact hangup code**: Extract the numeric code from the log (not guessed). Provide the standard SIP/Q.850 meaning.
84- **Bridge duration**: Calculate from exact timestamps when bridge started → ended, or when operator answered → bridge ended.
85- **No speculation**: If something is unclear in the log, state "log does not contain sufficient information about..." rather than guessing.
86
87## Example Conclusion Sections
88
89If the call has an IVR failure:
90```
912. **Попытка автоматической записи:**
92 * В контексте `Ivr651066` система попыталась найти свободный талон.
93 * [log line timestamp] ... система не нашла доступные слоты.
94 * Переход в контекст `Ivr651069` с сообщением об ошибке.
95```
96
97If there's operator transfer:
98```
993. **Перевод на оператора:**
100 * [timestamp] pbx.c: Calling `SIP/Trunk65/200`.
101 * [timestamp] app_dial.c: `SIP/Trunk65-XXXX` answered.
102 * Bridge established between caller and operator.
103```
104
105---
106
107## Output
108
109The skill outputs two files to `/home/mat/Downloads/tver/`:
110- `case_N.log` — the raw log
111- `case_N_conclusion.md` — the expert analysis
112
113Confirm completion with the file paths.