# Conference recoding to IVR

**URL:** <https://community.freepbx.org/t/conference-recoding-to-ivr/104287>\
**Category:** Development\
**Tags:** freepbx\
**Created:** [February 16, 2025, 10:16am UTC](https://community.freepbx.org/t/conference-recoding-to-ivr/104287 "2025-02-16T10:16:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![autoh](https://community.freepbx.org/letter_avatar_proxy/v4/letter/a/f07891/32.png) [@autoh](https://community.freepbx.org/u/autoh)\
**Post date:** [February 16, 2025, 10:16am UTC](https://community.freepbx.org/t/conference-recoding-to-ivr/104287/1 "2025-02-16T10:16:31Z")

</div>

I want that conference recordings should automatically be available to add to IVR.

I created a script, but im getting errors.

1. when i go to the preview, i can’t listen to the recording
2. when i call in and select that from the IVR menu, the call gets disconnected

See script

```auto
#!/bin/bash

MONITOR_DIR="/var/spool/asterisk/monitor"
RECORDINGS_DIR="/var/lib/asterisk/sounds/custom"

# Find the most recent audio file
latest_file=$(find "$MONITOR_DIR" -type f \( -name "*.wav" -o -name "*.mp3" -o -name "*.gsm" \) -printf "%T@ %p\n" | sort -n | tail -1 | cut -d ' ' -f2)

# Check if a file was found
if [-n "$latest_file"]; then
    # Get file creation time in dd_mm_yy_hh_mm format
    creation_time=$(stat -c %y "$latest_file" | awk '{print $1, $2}' | sed 's/[:-]/ /g' | awk '{printf "%02d_%02d_%02d_%02d_%02d", $3, $2, substr($1,3,2), $4, $5}')

    # Get file extension
    ext="${latest_file##*.}"

    # Define new filename format
    new_name="${creation_time}_Conference_Recording.${ext}"

    # Rename only if needed
    if ["$(basename "$latest_file")" != "$new_name"]; then
        mv "$latest_file" "$MONITOR_DIR/$new_name"
    fi

    # Copy file to FreePBX system recordings directory
    cp "$MONITOR_DIR/$new_name" "$RECORDINGS_DIR/"

    # Set correct ownership and permissions
    chown asterisk:asterisk "$RECORDINGS_DIR/$new_name"
    chmod 644 "$RECORDINGS_DIR/$new_name"

    # Register recording in FreePBX database
    mysql asterisk -e "INSERT INTO recordings (displayname, filename, description) VALUES ('$new_name', 'custom/$new_name', 'Conference Recording') ON DUPLICATE KEY UPDATE filename='custom/$new_name';"

    # Apply FreePBX changes
    fwconsole reload
fi

```

---

<div class="post-metadata">

**Author:** ![david55](https://community.freepbx.org/letter_avatar_proxy/v4/letter/d/e19adc/32.png) [@david55](https://community.freepbx.org/u/david55)\
**Post date:** [February 16, 2025, 11:52am UTC](https://community.freepbx.org/t/conference-recoding-to-ivr/104287/2 "2025-02-16T11:52:23Z")

</div>

Maybe I’ve missed something, but I don’t see anything here that changes the FreePBX configuration and would require a reload.

---

<div class="post-metadata">

**Author:** ![autoh](https://community.freepbx.org/letter_avatar_proxy/v4/letter/a/f07891/32.png) [@autoh](https://community.freepbx.org/u/autoh)\
**Post date:** [February 17, 2025, 11:42am UTC](https://community.freepbx.org/t/conference-recoding-to-ivr/104287/3 "2025-02-17T11:42:09Z")

</div>

See below the error I’m getting

 ![image](https://community.freepbx.org/uploads/default/original/3X/6/9/698a8d9376c43f40765ef851b47608aec9be7de0.png)

---

<div class="post-metadata">

**Author:** ![BlazeStudios](https://community.freepbx.org/letter_avatar_proxy/v4/letter/b/e0b2c6/32.png) [@BlazeStudios](https://community.freepbx.org/u/BlazeStudios)\
**Post date:** [February 17, 2025, 3:55pm UTC](https://community.freepbx.org/t/conference-recoding-to-ivr/104287/4 "2025-02-17T15:55:32Z")

</div>

Because System Recordings default to custom as the source directory. So what you have ends up being a file path of `/var/lib/asterisk/sounds/en/custom/custom/you file.wav` which is incorrect.

---

<div class="post-metadata">

**Author:** ![autoh](https://community.freepbx.org/letter_avatar_proxy/v4/letter/a/f07891/32.png) [@autoh](https://community.freepbx.org/u/autoh)\
**Post date:** [February 18, 2025, 5:52am UTC](https://community.freepbx.org/t/conference-recoding-to-ivr/104287/5 "2025-02-18T05:52:32Z")

</div>

Can you please help me and update it, or explain me a bit more what i have to change?

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://community.freepbx.org/uploads/default/original/3X/f/7/f7056d57e04fdbf71c6ad967e1ced351317f5c3f.png) [@system](https://community.freepbx.org/u/system)\
**Post date:** [March 21, 2025, 3:36pm UTC](https://community.freepbx.org/t/conference-recoding-to-ivr/104287/6 "2025-03-21T15:36:18Z")

</div>

Closed on March 21, 2025, 3:36pm UTC

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
