LNTWOOL - How does build ship handle concurrenc...
How does build ship handle concurrency ? basically i am building out the api layer for an ai agent mainly for it's tools, this agent wont be within buildship. so normal api calls. The API's i built need a auth token that is specific to that user for that session. We are going include it in the link the user clicks to get to the agent. My idea at this point is direct the link at build ship, which will capture the auth token and store it as a session variable, then redirect to the agent UI. Assuming that will work, if i have 10 users hitting the api at the same time, will buildship treat those sesions as unique, aka the variable i(token) it captures, will stay unique to that user for the duration of the session?
3 Replies
Hi @LNTWOOL, On free plan the concurrency is set to 1 which means multiple requests will hit the limit,. On all the paid plan there is no rate-limiting. So answering your question - BuildShip will treat those sessions as unique requests as each execution will be lodged separately, those 10 user's request will be unique. Let me know if any more questions?
thank you! yes onoe more! i am on paid plan have been for a while
let me grab my code snippet real quick
So here is the workflow. I am building an ai agent that handles two scenarios for a large mens haircut business. Cancelations and Reschedules. just context. They send out reminders 2 hours before and 30 minutes before the appoitment...this is when a lot of reschedules happen..
via sms (twilio). The text will include a link to the ai agent, within the link will be an auth token that is generated by twilio, it's unique to the user, and should only really persist for the session, but not a big deal as long as it stays tied to only that user. I am deleting the var's after the workflow is complete, So the link will always have the token that authenticates and identifies the user, the owner wants a one click experience where the agent greets them with information it already fetches based on the token. I have that all working but through the SMS, type in your code, then gets a token method which he does not want. So i want to store the token within buildship for the session, not with the agent for obvious reasons. I don't know how these workflow variables work. If i am using these, will other sessions using the API then use whatever token is stored there? How can i store the token within buildship for a session and ensure no other connections to the api endpoint use that variable? here is the code snip await env.set([
if (userData && userData.success) {
const userDetails = userData.payload.user;
logging.log('User details retrieved, storing session variables...');
// Serialize complex data types
const recentShops = JSON.stringify(userDetails.recentShops);
const dependents = JSON.stringify(userDetails.dependents);
const recentCuts = JSON.stringify(userDetails.recentCuts);
const preferredLocation = userDetails.recentShops[0];
// Store all session variables
await env.set([
{ name: 'authToken', value: token },
{ name: 'userId', value: userDetails.id.toString() },
{ name: 'userPhone', value: userDetails.phoneNumber },
{ name: 'userName', value: userDetails.name },
{ name: 'userRate', value: userDetails.rate.toString() },
{ name: 'recentShops', value: recentShops },
{ name: 'dependents', value: dependents },
{ name: 'recentCuts', value: recentCuts },
{ name: 'preferredLocation', value: preferredLocation }
], 'workflow');
logging.log('Session variables stored successfully');
return {
success: true,
payload: {
token,
userDetails,
sessionVariables: {
authToken: token,
userId: userDetails.id,
userPhone: userDetails.phoneNumber,
userName: userDetails.name,
userRate: userDetails.rate,
recentShops: userDetails.recentShops,
dependents: userDetails.dependents,
recentCuts: userDetails.recentCuts,
preferredLocation: preferredLocation
}
}
};
} else {
logging.log('Failed to retrieve user details:', userData);
throw new Error('Failed to retrieve user details');
}
} catch (error) {
logging.log('Error during SMS verification process:', error);
throw error;
}
}
Hi @LNTWOOL for this workflow issue, could please send it via in-app support? We can checkout your workflow copy and help you resolve this.