Help

Newb Struggling to Connect Automation to Make

Topic Labels: Automations Integrations
Solved
Jump to Solution
2378 6
cancel
Showing results for 
Search instead for 
Did you mean: 
Tahir_Jetter
6 - Interface Innovator
6 - Interface Innovator

Hi,

It's been several months since I've done this, but basically, I'm trying to send an automation from a clicked button in an AT interface to a Make webhook that I've created. 

The automation so far was when a button is clicked > run a script. I've been able to successfully pull in a test record id via the "when a button is clicked" stage -- my field is named "rec_id" with the autogenerated formula and that works fine.

FYI--when I hardcode the rec_id in there with the actual value, it works just fine with significantly less code. But with the code below--whenever I get to this step below, it just doesn't work. Can anyone help? Thanks!

let recordID = input.config().rec_id;

// Validate that recordID is not undefined

if (!recordID) {

    throw new Error('recordID is undefined. Check the input configuration.');

}

THE WHOLE CODE

// Define the record ID manually for testing purposes

// Define the base URL for the HTTP request to the Make webhook

let url = "https://hook.us1.make.com/mywebhookurl";

 

// Retrieve the record ID from the input configuration, which is provided by Airtable

let recordID = input.config().rec_id;

// Validate that recordID is not undefined

if (!recordID) {

    throw new Error('recordID is undefined. Check the input configuration.');

}

 

// Access the table where the records are stored

let table = base.getTable('Follow-Ups');

 

// Retrieve the specific record using the record ID

let record = await table.selectRecordAsync(recordID);

 

// Extract the values for the fields you want to send to Make

 

**values for fields i'm extracting

 

// Construct the payload with the extracted data

let payload = {

**payload I'm sending

};

 

// Send the payload to the Make webhook via a POST request

let response = await fetch(url, {

    method: 'POST',

    body: JSON.stringify(payload),

    headers: {

        'Content-Type': 'application/json'

    }

});

 

// Check if the request was successful

if (response.ok) {

    // If response is successful, log the response or perform other actions

    let responseBody = await response.json();

    console.log('Success:', responseBody);

} else {

    // If the request failed, log the error

    console.error('Request failed with status:', response.status);

}

 

 

1 Solution

Accepted Solutions
Yes, Make worked fine even though AT automation errors occurred.
Thanks so much for your responses
 
So a friend showed me: 
 
let url = "my-web-hook/?recordID="
let inputConfig = input.config();
await fetch(url + inputConfig["recordID"]);
 
Screenshot 2024-02-11 at 11.19.06 AM.png
 
and that worked. . 

See Solution in Thread

6 Replies 6

Sorry, I don’t know much about scripting, but if you’re interested in a different way of getting the exact same result, I would just use Make’s Airtable Get A Record module to pull in all the Airtable data thar you need.

You can either click on a button in Airtable to trigger the webhook URL directly, or my preferred way of doing this is to use a single select field in Airtable to trigger the Make webhook.

Complete details on my method here: https://air.tableforums.com/t/sending-airtable-data-to-an-external-webhook-such-as-make-com/159

It seems like your input config's not set up properly, try setting it up like this instead:

Screenshot 2024-02-09 at 2.36.42 PM.png

Hi, thanks for this. I'll try that out. 

 

Hi, 

So I believe I've tried this in two ways and I'm still having challenges. Do you have any thoughts? 

Thanks!

The default response format from a Make webhook isn't JSON, and so attempting to parse the response as JSON using .json()'s causing that error.  Try removing line 63 and just console logging 'response' instead.  (This assumes you didn't create a webhook response module in your scenario)

The Make scenario runs fine even though your Airtable automation errors though right?

Yes, Make worked fine even though AT automation errors occurred.
Thanks so much for your responses
 
So a friend showed me: 
 
let url = "my-web-hook/?recordID="
let inputConfig = input.config();
await fetch(url + inputConfig["recordID"]);
 
Screenshot 2024-02-11 at 11.19.06 AM.png
 
and that worked. .