Hey!
I’m working on a workflow in weweb and I have a problem. Let me explain the context:
When a button is clicked, my workflow must generate a pdf from weweb and send it to a user.
I have a dynamic template on sendgrid that is connected to xano.
I have an xano endpoint that allows me to send data from weweb.
This endpoint expects an email, a template-is and a JSON object named data.
For now, the first step is to generate the pdf and return the URI in the “pdfToSend” variable using the “html2pdf” library.
Then I do a “change variable value” and set the value of action 1 to “action.result.data”.
Finally, I use the endpoint. I’ve filled in the mail, the template id and I’ve tested it, it works with the firstname and lastname variables. My problem lies, I think, in the configuration of the data object and the uri format in attachments. I’ve read that the uri must be encoded in base 64, so it works like this:
Blockquote// Récupération des variables
let firstnameValue = variables[‘62d75fe9-d0c9-4e88-b371-b9bf4f291442’]?.[‘first_name’];
let lastnameValue = variables[‘62d75fe9-d0c9-4e88-b371-b9bf4f291442’]?.[‘last_name’];
let contentValue = variables[‘0879c04c-e772-4a46-bd39-8ef8096c1b4d’];
// Encode contentValue en base64
let encodedContentValue;
try {
encodedContentValue = btoa(unescape(encodeURIComponent(contentValue)));
} catch (e) {
console.error(“Erreur lors de l’encodage en base64:”, e);
}
// Création de l’objet JSON avec les propriétés
let jsonObject = {
firstname: firstnameValue,
lastname: lastnameValue,
attachments: [
{
content: encodedContentValue,
filename: “Planning du mois truc”,
type: “application/pdf”
}
]
};
// Retour de l’objet JSON
return jsonObject;
Blockquote
My problem is that I can only test in staging, once the application has been deployed. As a result, it’s impossible to debug properly and see what the uri format looks like. For the moment, on click, it generates the pdf in my downloads folder and closes the window (Don’t know why and so I can’t even make a consol.log in consol) and it does send an email with the first and last name in dynamic. But no pdf attachment…