No internet connection
  1. Home
  2. How to

Need help integrating webhook with existing script

By Mike Indovina @Mike_Indovina
    2024-09-26 19:40:06.868Z

    For a while now, I've been using a script to help create various folders on my hard drive based on the types of projects I'm working on. In short, it asks me about the artist's name, year, song/album name, and type of project, and then creates the corresponding folders based on those details.

    I'd now like to update it so that I can create a new project inside of Samply based on the artist name. To do so, I figured I'd need to use a webhook with Zapier to integrate it with Samply. That said, I've never used webhooks before so I think that's the solution. I just have no clue how to code that in. Any suggestions?

    the following is my webhook URL: https://hooks.zapier.com/hooks/catch/1603543/2dwpxpx/

    The following is my existing macro script:

    // Set the root directory to the desktop
    let rootDirectoryPath = "/Volumes/Rocksteady/Pro Tools Sessions";
    
    // Ask user for the artist's name
    const artistName = sf.interaction.displayDialog({
        prompt: "Please enter the artist's name",
        title: "Artist Name",
        defaultAnswer: "",
        buttons: ["Ok", "Cancel"],
        defaultButton: "Ok"
    }).text;
    
    // Ask user for the year
    const year = sf.interaction.displayDialog({
        prompt: "Please enter the year",
        title: "Year",
        defaultAnswer: "",
        buttons: ["Ok", "Cancel"],
        defaultButton: "Ok"
    }).text;
    
    // Ask user for the album name
    const albumTitle = sf.interaction.displayDialog({
        prompt: "Please enter the album title",
        title: "Album Title",
        defaultAnswer: "",
        buttons: ["Ok", "Cancel"],
        defaultButton: "Ok"
    }).text;
    
    // Ask user for the song title
    const songTitle = sf.interaction.displayDialog({
        prompt: "Please enter the song title",
        title: "Song Title",
        defaultAnswer: "",
        buttons: ["Ok", "Cancel"],
        defaultButton: "Ok"
    }).text;
    
    // Define popup the options
    const projectTypes = ["Mixing", "Mastering"]
    
    // Popup window with option selection
    const projectType = sf.interaction.popupSearch({
        items: projectTypes.map(projectType => ({
            name: projectType,
        })),
    }).item.name;
    
    // Project Folder Name and path
    const projectFolderName = `${artistName}`;
    const projectFolderPath = `${rootDirectoryPath}/${projectFolderName}`;
    
    // Create Project Directory
    sf.file.directoryCreate({ path: projectFolderPath });
    
    if (projectType === "Mixing") {
        
        // Create Sub Folder named "To Mix"
        sf.file.directoryCreate({ path: `${projectFolderPath}/${year}/${albumTitle}/${songTitle}/To Mix` });
        sf.file.directoryCreate({ path: `${projectFolderPath}/${year}/${albumTitle}/${songTitle}/Reference Tracks` });
    
        //Add script for making pro tools session here.
    
    } else if (projectType === "Mastering") {
    
        // Create render folders
        sf.file.directoryCreate({ path: `${projectFolderPath}//${year}/${albumTitle}/${songTitle}/44.1k Renders` });
        sf.file.directoryCreate({ path: `${projectFolderPath}//${year}/${albumTitle}/${songTitle}/44.1k Renders/${songTitle}_24441_WAV_V1` });
        sf.file.directoryCreate({ path: `${projectFolderPath}//${year}/${albumTitle}/${songTitle}/44.1k Renders/${songTitle}_16441_WAV_V1` });
        sf.file.directoryCreate({ path: `${projectFolderPath}//${year}/${albumTitle}/${songTitle}/48k Renders` });
        sf.file.directoryCreate({ path: `${projectFolderPath}//${year}/${albumTitle}/${songTitle}/48k Renders/${songTitle}_2448_WAV_V1` });
        sf.file.directoryCreate({ path: `${projectFolderPath}//${year}/${albumTitle}/${songTitle}/96K Renders` });
        sf.file.directoryCreate({ path: `${projectFolderPath}//${year}/${albumTitle}/${songTitle}/To Master` });
    }
    
    sf.file.open({path:projectFolderPath});
    
    
    • 0 replies