π§
Problem DescriptionHello! I'm having an issue where my TypeBot does not correctly receive responses from a webhook set up in Make. Below are the details:
π―
ObjectiveI'm aiming for my TypeBot to receive responses from a Make webhook after sending data through a POST request, and I need these data to be accurately displayed in the TypeBot chat.
π¨βπ»
Code Usedconst webhookUrl = 'https://hook.eu1.make.com/***********';
try {
const response = await fetch(webhookUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ nombre_usuario, consulta_cliente })
});
if (response.ok) {
const data = await response.json();
console.log('Complete response from webhook:', data);
if (data.response) {
console.log('Webhook message:', data.response.datos.mensaje);
await Typebot.setVariable('respuesta_webhook', data.response.datos.mensaje);
return data.response.datos.mensaje;
} else {
console.error('Response format unexpected or incomplete:', data);
await Typebot.setVariable('respuesta_webhook', 'Sorry, there seems to be a problem with the response format.');
return null;
}
} else {
console.error('Problem with the request. Status:', response.status);
await Typebot.setVariable('respuesta_webhook', 'Sorry, there was a problem with sending the query.');
return null;
}
} catch (error) {
console.error('Error contacting the API:', error);
await Typebot.setVariable('respuesta_webhook', 'There seems to be an error in processing the query.');
throw error;
}