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);
}