Skip to content

Conversation

cwjwisse
Copy link
Contributor

@cwjwisse cwjwisse commented Sep 11, 2025

  • reuses the same command for onboarding
  • if brand exists for given site, the users will be prompted with two buttons:
    • users can choose to only add/update entitlements and enrollments (this is done using the tier client)
    • they can also choose to update the IMS org, and subsequently update the entitlements and enrollments
  • success and failure messages are posted in the same thread

Copy link

This PR will trigger a minor release when merged.

@cwjwisse cwjwisse force-pushed the enable-llmo-reonboarding branch 7 times, most recently from bc89c1d to c8bc191 Compare September 12, 2025 11:26
@ravverma
Copy link
Contributor

@cwjwisse I was checking method createEntitlementAndEnrollment

async function createEntitlementAndEnrollment(site, lambdaCtx, slackCtx) {
  const { dataAccess, log } = lambdaCtx;
  const { say } = slackCtx;
  const { Entitlement, SiteEnrollment } = dataAccess;

  const orgId = site.getOrganizationId();

  // find if there are any entitlements for this site enabling LLMO
  const enrollments = await SiteEnrollment.allBySiteId(site.getId());
  const llmoEntitlements = (await Promise.all(enrollments.map(async (enrollment) => {
    // find entitlement for this enrollment
    const entitlement = await Entitlement.findById(enrollment.getEntitlementId());
    // check if the entitlement is for the same organization as the site
    const entitlementOrgId = entitlement.getOrganizationId();
    if (entitlementOrgId !== orgId) return null;
    // check if the entitlement is for LLMO
    const entitlementProductCode = entitlement.getProductCode();
    return entitlementProductCode === LLMO_PRODUCT_CODE ? entitlement : null;
  }))).filter((x) => !!x);

  if (llmoEntitlements.length > 0) {
    await say(`Site ${site.getId()} is already entitled to LLMO. Skipping entitlement grant.`);
    log.warn(`Site ${site.getId()} already entitled to LLMO. Skipping.`);
    return;
  }

  // create an entitlement
  const newEntitlement = await Entitlement.create({
    organizationId: orgId,
    productCode: LLMO_PRODUCT_CODE,
    tier: LLMO_TIER,
    quotas: { llmo_trial_prompts: 200 },
  });
  await newEntitlement.save();
  const newEntitlementId = newEntitlement.getId();

  // create enrollment
  const newEnrollment = await SiteEnrollment.create({
    entitlementId: newEntitlementId,
    siteId: site.getId(),
  });
  await newEnrollment.save();
}

there is a edge case in this flow.
If org O and two sites A and B
on On-boarding A -> it will create an entitlement and siteEnrollment -> good
on On-boarding B -> it will again create an entitlement and siteEnrollment -> NOT good , it will break access.

So in case of B only siteEnrollment need to created with existing entitlement

I would suggest first fetch the entitlement on org level for LLMO , and use that for comparison for siteEnrollment
e.g.

const entitlement = await this.Entitlement.findByOrganizationIdAndProductCode(orgId, this.productCode);

cc: @solaris007

@cwjwisse cwjwisse marked this pull request as draft September 15, 2025 06:05
@cwjwisse cwjwisse force-pushed the enable-llmo-reonboarding branch 6 times, most recently from 8f06175 to 04c8133 Compare September 16, 2025 11:42
@cwjwisse cwjwisse marked this pull request as ready for review September 16, 2025 11:44
@cwjwisse cwjwisse requested a review from ravverma September 16, 2025 11:49
@cwjwisse cwjwisse force-pushed the enable-llmo-reonboarding branch from 04c8133 to 4c42c6d Compare September 16, 2025 13:09
@cwjwisse cwjwisse force-pushed the enable-llmo-reonboarding branch 6 times, most recently from de2c84f to 7e9ed04 Compare September 16, 2025 15:57
@cwjwisse cwjwisse force-pushed the enable-llmo-reonboarding branch from 7e9ed04 to 4d5c0f2 Compare September 17, 2025 07:57
@cwjwisse cwjwisse requested a review from ravverma September 17, 2025 08:26
@cwjwisse cwjwisse force-pushed the enable-llmo-reonboarding branch from 4d5c0f2 to 5e53869 Compare September 17, 2025 09:14
@cwjwisse cwjwisse force-pushed the enable-llmo-reonboarding branch 7 times, most recently from 45776b7 to 2828482 Compare September 18, 2025 06:25
@cwjwisse cwjwisse force-pushed the enable-llmo-reonboarding branch from 2828482 to 82f02df Compare September 18, 2025 09:25
@cwjwisse cwjwisse merged commit 429c73f into main Sep 18, 2025
11 checks passed
@cwjwisse cwjwisse deleted the enable-llmo-reonboarding branch September 18, 2025 09:46
solaris007 pushed a commit that referenced this pull request Sep 18, 2025
## [1.178.1](v1.178.0...v1.178.1) (2025-09-18)

### Bug Fixes

* **slack/onboarding-llmo:** allow rerun of onboarding command ([#1242](#1242)) ([429c73f](429c73f))
@solaris007
Copy link
Member

🎉 This PR is included in version 1.178.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants