https://discord.gg/botpress logo
onboarding
# 🤝help
b
hey i want to ask if its possible to connect a login onboarding platform to the data base in bot press to automtic fills info for my multitenant system?
l
If you build your own custom integration this might be possible @big-gigabyte-89779 however there is no built in way to do this. Is there anything else I can help with?
g
If you want to: - have users authenticate in a separate platform (login) - store tenant/user profile data somewhere (their DB) - then have Botpress automatically: -- identify the user -- load their profile/tenant data -- use it inside the bot (auto-fill forms, personalise, etc.) use something like Clerk or Auth0. you can import their sdk into your codebase (NOT IN BOTPRESS, IN THE CODEBASE THAT HAS YOUR BOT INITIALISED). For example, say your bot is initialised in the project in vanilla js, html and css, you can simply include Clerk SDK using the recommended tag method:
Copy code
<script
      async
      crossorigin="anonymous"
      data-clerk-publishable-key="YOUR CLERK PUBLISHABLE KEY FROM CLERK DASHBOARD"
      src="https://square-horse-61.clerk.accounts.dev/npm/@clerk/clerk-js@5/dist/clerk.browser.js"
      type="text/javascript"
    ></script>
now you have access to clerk methods in the project, such as the sign in modal. you can ensure users cant use your content unless the user signs in. regarding keeping the user data in sync with the bot. Clerk has 3 types of metadata, unsafe (write and read on front end) public (read on front end, no write, write using backend) and private (no read or write allowed on front end). when your user creates an account with you, you can set metadata for the user, such as name age business logic usage and limits.
To keep the bot and app in sync, you use window.botpress.sendEvent to send user data to your bot. and to recieve data from the bot in the web app, use the send custom event card (studio). and attach a listener in the front end of your proj:
window.botpress.on('customEvent', async (event) => { // Your listener logic goes here }
so for example, in the 'event' input box in the send custom event card, you must send a json string, something like this:
{"action": "check-user-usage"}
then, you can do something like this in the bp custom event listener i just sent:
Copy code
window.botpress.on('customEvent', async (event) => { if (event.action === 'check-user-usage' {await window.Clerk.reload (reload user data)
const publicMetadata = await window.Clerk.publicMetadata (get metadata json from clerk)
// then however you define usage, check it and decide next steps.
 }}
Sorry for the essay pal, good luck!
a couple more notes: - Anything that enforces entitlements/usage limits should be server-authoritative. - Don’t rely on “unsafe” metadata or any front-end-writeable field for enforcement. - Use the bot/web app to display usage; use backend to decide usage.
the example i sent before was just an example, loading usage data in the front end isnt ideal