I’m struggling with a simple case : retrieve the MagicLink in Airtable “softr-users” synced table, after creating a new user, to be able to trigger a welcome email with it.
Here is the process we go through:
automate in Airtable create a new record in Airtable “softr-users” synced table
MagicLink need to be created by Softr, and saved in Airtable with after a sync action
Once magiclink is created, email “Welcome” is sent
We want to minimize the time between creation and “Welcome” email sent, and for sure not to have to loggin and open the “User management” page of Softr to trigger the sync. How can we make that ? Trigger a sync with an API call using a bit a script in Airtable automation, just after adding the record in the table ?
Please advise. Thanks
PS : As this is a key component in user journery, detailing the other occasions behing “etc” in the list below, would be really useful to understand how the product works
let inputConfig = input.config();
let userEmail = inputConfig.user_Email;
let apiUrl = `https://studio-api.softr.io/v1/api/users/magic-link/generate/${userEmail}`;
let requestOptions = {
method: 'POST',
headers: {
'Softr-Api-Key': 'YOURAPIKEY',
'Softr-Domain': 'YOURSOFTRAPP.softr.app'
}
};
let response = await fetch(apiUrl, requestOptions);
console.log(await response.text());
I no longer use this though, instead I generate the entire account via api call in airtable (because internal staff are… they’re dumb, misspell their own names and emails and it’s not worth the headache) with a temporary password, and i have a user group “unverified” essentially so they are forced to set new password and verify info before accessing actual application
i suck at coding but once i figured out the script it works quite nice!
This is really nice from you @danyalamriben - thanks for sharing this valuable piece of code.
With it I’m half-way to my target. I know with this API call that the magic link is created on Softr user table side, but it is still not synced in Airtable “Softr-users” table, so I’m not able to send the welcome message with the link embedded from Airtable automation. Do you know by any chance, what it the API call to GET user details from Softr ? I didn’t find it here : API Setup and Endpoints – Softr Help Docs
Thanks !
it should be synced. Go into softr app user settings. where you initially mapped your softr user information to your destination table in airtable. Ensure magic link field is connected. Should not be difficult!
also no clue hahaha i’m really not a coder… IDK if you can even get from their api? That’s for another community expert to answer LOL sorry cant be more helpful!
Thanks for the feedback. Can you please share the API call to create the user ?
The call to generate Magic Link does nothing from what I understand, since the user has only been created on Airtable side, and sync action is only triggered by Softr - so if you don’t login or open the user list page it doesn’t get known by softr. And I do have the link connected for magic link
@Flavien Not sure if you figured out a solution already, but for anyone else who might stumble across this and still need a solution, I was able to get this code to work to generate new users with the airtable script automation based on when a new user is added in airtable:
let inputConfig = input.config();
let userEmail = inputConfig.user_Email;
let fullName = inputConfig.user_Name;
let apiUrl = `https://studio-api.softr.io/v1/api/users`;
let data = {
email: inputConfig.user_Email,
generate_magic_link: true,
full_name: inputConfig.user_Name
};
let requestOptions = {
method: 'POST',
headers: {
'Softr-Api-Key': 'YOUR API KEY',
'Softr-Domain': 'YOUR APP DOMAIN',
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
};
let response = await fetch(apiUrl, requestOptions);
console.log(await response.text());
As with the example above, you must configure the two input variables (userEmail and fullName) in the Airtable interface.
Hi @Derek thanks for sharing this - how do you automatically retrieve the magic-link in your Airtable record ? The API call just create the user on Softr side, but it doesn’t force the sync that will make Softr write back the ML in airtable synchronized user table. This is for us a major painpoint, because it means at some point a manual action is required first, to be then able to communicate to an user its magic link from an airtable automation. Any input on this would be great, maybe you know how to do this, @Suzie ?
I just did a test: creating a user automatically adds the magic link in Airtable, if the user uses the sign up block + two way sync enabled.
Your workflow is a user creation through a sign up form or through Airtable at first?
If so, after some tests, this is the enpoint to create a user that works, not the one to create a magic link (??). Then it immediately adds the magic link in Airtable (in your dedicated field).
as per:
let inputConfig = input.config();
let userEmail = inputConfig.userInputEmail;
let fullName = inputConfig.UserInputName;
let apiUrl = `https://studio-api.softr.io/v1/api/users`;
let data = {
email: inputConfig.userInputEmail,
generate_magic_link: true,
full_name: inputConfig.UserInputName
};
let requestOptions = {
method: 'POST',
headers: {
'Softr-Api-Key': 'xxxxxxxxxxxxxxxxxx',
'Softr-Domain': 'xxxxxxxxxxx',
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
};
let response = await fetch(apiUrl, requestOptions);
console.log(await response.text());
Thank you Matthieu,
Our workflow is starting in Airtable, creating the user in the softr-users table first / then connect to Softr admin and sync the user table to force the sync (meaning, create the user and get back the ML).
I tried implementing the proposed code and got the following :
CONSOLE.LOG
“{“code”:“Bad Request”,“message”:“Something went wrong, please try again.”,“instance”:null,“status”:null,“title”:null,“type”:null,“source”:null}”
I checked the way I implement it and seems ok, input var are correctly retrieved abd api-key and domain are correct.
Line 2,3,8 and 10 must have the variables changed (userInputEmail and UserInputName)
Try not using your own domain for “Softr-Domain” but the Softr domain
You can find it here (it’s called “subdomain”)
Then you can set the automation to On and try it.
Tell me if something went wrong
Then create a second automation.
The trigger will be: “when a record is updated”. The field to look at will be the magic link field (url field).
The action will be send an email and then I think you know how to proceed.
Works like a charm, thanks - your description exactly matches the way I did it. For a reason I ignore, first time it did not work, then it ran perfectly and ML was synced to airtable without any manual action. Case solve and good doc. provided! Thank you @matthieu_chateau and @Derek for your time on this.
Hey folks we are working on datasource to softr auto-sync I assume it could go live in about 2 weeks. Do I get it right the use case is to automate user invitation?
Hello @artur yes this is to be able to provide the magic link in a email triggered on airtable side with an automation that send a user invitation/welcome email.
Hi there, I’ve resolved the magic link synchronization with an Airtable automation that triggers everytime the field “Magic Link” is updated and sends it to the user. I am using a MAKE that checks for a new user in the Airtable user’s table and calls the SOFTR API to create the user, thus forcing synchronization and triggering the sending of the magic link. It’s working fine.