Asterisk Skill for Claude
· 5.5 KiB · Text
Raw
# /asterisk
Analyze an Asterisk PBX call log and generate a professional expert conclusion.
## Usage
Paste the full Asterisk log text, then run `/asterisk`. The skill will:
1. Determine the next case number from existing `case_*.log` files
2. Save the log as `case_N.log`
3. Generate a detailed professional conclusion as `case_N_conclusion.md`
## Instructions for Claude
You are an expert Asterisk PBX analyst specializing in medical clinic IVR systems. Your task:
1. **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).
2. **Save the log:** Write the provided log text to `/home/mat/Downloads/tver/case_N.log` using the Write tool.
3. **Parse the log thoroughly.** Read the entire log file and extract these facts:
- **Call ID**: Find the pattern `C-XXXXXXXX` from log lines
- **Caller (Side A)**: Extract from lines containing `caller=` or CDR references
- **Callee/Entry**: Find the initial context or number dialed
- **Call start time**: First timestamp in the log
- **IVR flow**: Trace every context transition (e.g., TrunkRoute → macro → Ivr*) with timestamps and what the system did
- **MRCP speech recognition**: Extract any RECOG_RESULT XML blocks with recognized text
- **Operator dial**: Find the channel that rang (e.g., SIP/Trunk65/200), timestamp dial was initiated
- **Operator answered**: Exact timestamp when operator answered (look for "answered" in app_dial.c lines)
- **Bridge established**: When two channels enter `simple_bridge` or similar
- **Bridge duration**: Calculate end_time - answer_time
- **Bridge ended**: When channels left the bridge
- **Hangup cause code**: Extract the numeric code from `macro-SaveHangup` lines (e.g., code 16 = Normal call clearing)
- **Recording file path**: Find `soundFile` or Monitor() paths
- **All WARNINGs and ERRORs**: List every WARNING and ERROR line with context (do NOT filter; report what's actually in the log)
4. **Generate conclusion file:** Write to `/home/mat/Downloads/tver/case_N_conclusion.md` following this exact structure:
```markdown
На основе анализа предоставленного лога звонка с идентификатором `{CALL_ID}` можно сделать следующие выводы:
### Краткий итог
**{One sentence bold summary of the call outcome}**
### Детальный разбор
1. **Сценарий звонка:**
* **A (Кто звонил):** Номер абонента (из лога).
* **B (Кому звонили):** Контекст входа / номер.
* **Суть:** Краткое описание того, что абонент делал в IVR (данные из лога).
2. **[Section title from call flow]:**
* Факты с цитатами log lines (timestamp + что произошло).
3. **[Next section - e.g., "Перевод на оператора" or "Проблема"]:**
* Факты из лога.
4. **Соединение с оператором:**
* Канал, время, ответ оператора (из лога).
5. **Завершение звонка:**
* Timestamp когда bridge closed.
* Длительность разговора.
* Hangup cause code.
### Расшифровка кода завершения (Hangup Cause Code) `{CODE}`
По стандарту SIP/Q.850, код `{CODE}` означает:
> **[Standard meaning of the code]**
### Вывод
* **Что случилось со звонком?** [Brief answer from log facts]
* **Почему он завершился?** [Answer from log]
* **Кто положил трубку?** [Answer from log]
```
## Critical Rules
- **100% log-based only**: Every statement must be traceable to a specific log line. No assumptions or inferences beyond what the log explicitly shows.
- **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").
- **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.
- **Exact hangup code**: Extract the numeric code from the log (not guessed). Provide the standard SIP/Q.850 meaning.
- **Bridge duration**: Calculate from exact timestamps when bridge started → ended, or when operator answered → bridge ended.
- **No speculation**: If something is unclear in the log, state "log does not contain sufficient information about..." rather than guessing.
## Example Conclusion Sections
If the call has an IVR failure:
```
2. **Попытка автоматической записи:**
* В контексте `Ivr651066` система попыталась найти свободный талон.
* [log line timestamp] ... система не нашла доступные слоты.
* Переход в контекст `Ivr651069` с сообщением об ошибке.
```
If there's operator transfer:
```
3. **Перевод на оператора:**
* [timestamp] pbx.c: Calling `SIP/Trunk65/200`.
* [timestamp] app_dial.c: `SIP/Trunk65-XXXX` answered.
* Bridge established between caller and operator.
```
---
## Output
The skill outputs two files to `/home/mat/Downloads/tver/`:
- `case_N.log` — the raw log
- `case_N_conclusion.md` — the expert analysis
Confirm completion with the file paths.
| 1 | # /asterisk |
| 2 | |
| 3 | Analyze an Asterisk PBX call log and generate a professional expert conclusion. |
| 4 | |
| 5 | ## Usage |
| 6 | |
| 7 | Paste the full Asterisk log text, then run `/asterisk`. The skill will: |
| 8 | 1. Determine the next case number from existing `case_*.log` files |
| 9 | 2. Save the log as `case_N.log` |
| 10 | 3. Generate a detailed professional conclusion as `case_N_conclusion.md` |
| 11 | |
| 12 | ## Instructions for Claude |
| 13 | |
| 14 | You are an expert Asterisk PBX analyst specializing in medical clinic IVR systems. Your task: |
| 15 | |
| 16 | 1. **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 | |
| 18 | 2. **Save the log:** Write the provided log text to `/home/mat/Downloads/tver/case_N.log` using the Write tool. |
| 19 | |
| 20 | 3. **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 | |
| 36 | 4. **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 | |
| 46 | 1. **Сценарий звонка:** |
| 47 | * **A (Кто звонил):** Номер абонента (из лога). |
| 48 | * **B (Кому звонили):** Контекст входа / номер. |
| 49 | * **Суть:** Краткое описание того, что абонент делал в IVR (данные из лога). |
| 50 | |
| 51 | 2. **[Section title from call flow]:** |
| 52 | * Факты с цитатами log lines (timestamp + что произошло). |
| 53 | |
| 54 | 3. **[Next section - e.g., "Перевод на оператора" or "Проблема"]:** |
| 55 | * Факты из лога. |
| 56 | |
| 57 | 4. **Соединение с оператором:** |
| 58 | * Канал, время, ответ оператора (из лога). |
| 59 | |
| 60 | 5. **Завершение звонка:** |
| 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 | |
| 89 | If the call has an IVR failure: |
| 90 | ``` |
| 91 | 2. **Попытка автоматической записи:** |
| 92 | * В контексте `Ivr651066` система попыталась найти свободный талон. |
| 93 | * [log line timestamp] ... система не нашла доступные слоты. |
| 94 | * Переход в контекст `Ivr651069` с сообщением об ошибке. |
| 95 | ``` |
| 96 | |
| 97 | If there's operator transfer: |
| 98 | ``` |
| 99 | 3. **Перевод на оператора:** |
| 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 | |
| 109 | The 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 | |
| 113 | Confirm completion with the file paths. |