Hello So I created a button that when clicked it runs a script and the script connects to a webhook and sends some fields to the webhook.
But I added an input field at the beginning. First it asks your to input some text, and then send all the information to a webhook but have no idea how to send the input text. I appreciate your help.
This is the code:
let name = await input.textAsync(‘Escribe aqui la tarea’);
output.text(Your name is ${name}.
);
// Webhook URL
let webhook = ‘httpsWebhookURL’
// Airtable Script Button Text
let actionDescription = ‘Creando una tarea de esta integracion’
// Table to send data from
let tableName = ‘Interacciones’
// Fields to bind and send
let fieldsToSend = ‘Descripcion’, ‘Compañia’]
// !--------------------! //
let table = base.getTable(tableName);
let record = await input.recordAsync(actionDescription, table);
let queryParams = /?id=${record.id}
if(fieldsToSend.length > 0){
function buildParams(fieldName) {
let fieldValue = record.getCellValueAsString(fieldName)
queryParams += &${encodeURIComponent(fieldName)}=${encodeURIComponent(fieldValue)}
}
fieldsToSend.forEach(buildParams);
}
const returnedPayload = await fetch(${webhook}${queryParams}
);
var payloadResponse = await returnedPayload.json()
let results = payloadResponse.result;
output.text(results)