Airgentic Help
This guide covers the additional steps required when hosting the Airgentic secure widget on a SharePoint Online intranet. It builds on the general Adding the Secure Widget to Your Site guide — complete those steps first, then follow the SharePoint-specific guidance below.
SharePoint Online has security restrictions that affect how external scripts are loaded and executed. The key things to be aware of are:
<script> tags. You cannot simply paste the Airgentic embed code into a page editor.SharePoint Online's Content Security Policy blocks external scripts that are not explicitly trusted. Your SharePoint administrator must add the Airgentic script domain as a trusted source.
https://<your-tenant>-admin.sharepoint.com.https://chat.airgentic.com
Note: If you cannot find this setting in the admin center UI, your SharePoint administrator may need to configure it via PowerShell or the SharePoint API. Microsoft's documentation on allowing custom scripts provides additional guidance.
Without this step, the Airgentic widget script will be blocked by the browser and the widget will not load.
On modern SharePoint pages, you cannot insert a <script> tag directly. Instead, you need a SharePoint Framework (SPFx) web part that loads the Airgentic script.
Airgentic provides a ready-to-deploy SPFx package. No build step required — just download, upload to your App Catalog, and configure.
Download airgentic-webpart.sppkg
To deploy:
.sppkg file using the link above.https://<your-tenant>.sharepoint.com/sites/appcatalog)..sppkg file.Airgentic will provide your Account ID and Service ID.
If you want to use Airgentic's Search UI (a unified site search + chat overlay), the web part also supports these optional settings:
| Setting | Description |
|---|---|
| Search Input ID | The ID of your site's search input element (no # prefix) |
| Search Button ID | The ID of your site's search button element (no # prefix) |
You can provide one or both. When configured, Airgentic will bind to your existing search elements and activate the Search UI overlay when users interact with them.
If your organisation has a SharePoint developer and prefers to build or customise the web part, you can create your own SPFx project. This gives you full control over the web part's behaviour, allows you to integrate it into your existing SharePoint development workflow, and enables customisation such as styling or additional features.
<script
id="airgentic-script"
src="https://chat.airgentic.com/airgentic-1.4.js"
data-account-id="your_account_id"
data-service-id="your_service_id"
data-auth-mode="oidc"
data-auth-redirect-uri="https://yourorg.sharepoint.com/sites/intranet/SitePages/callback.aspx"
></script>
yo @microsoft/sharepoint
import { Version } from '@microsoft/sp-core-library';
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
import {
IPropertyPaneConfiguration,
PropertyPaneTextField
} from '@microsoft/sp-property-pane';
export interface IAirgenticWebPartProps {
accountId: string;
serviceId: string;
redirectUri: string;
searchInputId: string;
searchButtonId: string;
}
export default class AirgenticWebPart extends BaseClientSideWebPart<IAirgenticWebPartProps> {
private static SCRIPT_ID = 'airgentic-script';
private static SCRIPT_SRC = 'https://chat.airgentic.com/airgentic-1.4.js';
private scriptLoaded: boolean = false;
private scriptError: boolean = false;
public render(): void {
const { accountId, serviceId, redirectUri } = this.properties;
// Validate required properties
if (!accountId || !serviceId || !redirectUri) {
this.domElement.innerHTML = `
<div style="padding: 20px; border: 1px solid #c7c7c7; border-radius: 4px; background: #f9f9f9;">
<p style="margin: 0 0 10px 0; font-weight: 600;">Airgentic Widget - Configuration Required</p>
<p style="margin: 0; color: #666;">Please configure the web part properties:</p>
<ul style="margin: 10px 0 0 0; color: #666;">
${!accountId ? '<li>Account ID</li>' : ''}
${!serviceId ? '<li>Service ID</li>' : ''}
${!redirectUri ? '<li>Redirect URI</li>' : ''}
</ul>
<p style="margin: 10px 0 0 0; color: #666;">Click the edit (pencil) icon on this web part to open the property pane.</p>
</div>
`;
return;
}
// Show error state if script failed to load
if (this.scriptError) {
this.domElement.innerHTML = `
<div style="padding: 20px; border: 1px solid #d93025; border-radius: 4px; background: #fce8e6;">
<p style="margin: 0; color: #d93025; font-weight: 600;">Failed to load Airgentic widget</p>
<p style="margin: 10px 0 0 0; color: #666;">Please check that chat.airgentic.com is added to your SharePoint trusted script sources.</p>
</div>
`;
return;
}
// Show loading state while script loads
if (!this.scriptLoaded) {
this.domElement.innerHTML = `
<div style="padding: 20px; text-align: center; color: #666;">
Loading Airgentic widget...
</div>
`;
} else {
this.domElement.innerHTML = `<div id="airgentic-container"></div>`;
}
// Only inject script once
if (!document.getElementById(AirgenticWebPart.SCRIPT_ID)) {
this.injectScript();
}
}
private injectScript(): void {
const { accountId, serviceId, redirectUri, searchInputId, searchButtonId } = this.properties;
const script = document.createElement('script');
script.id = AirgenticWebPart.SCRIPT_ID;
script.src = AirgenticWebPart.SCRIPT_SRC;
script.setAttribute('data-account-id', accountId);
script.setAttribute('data-service-id', serviceId);
script.setAttribute('data-auth-mode', 'oidc');
script.setAttribute('data-auth-redirect-uri', redirectUri);
if (searchInputId) {
script.setAttribute('data-search-input-id', searchInputId);
}
if (searchButtonId) {
script.setAttribute('data-search-button-id', searchButtonId);
}
script.onload = () => {
this.scriptLoaded = true;
this.render();
};
script.onerror = () => {
this.scriptError = true;
this.render();
};
document.body.appendChild(script);
}
protected onDispose(): void {
// Clean up the script when the web part is removed
const script = document.getElementById(AirgenticWebPart.SCRIPT_ID);
if (script) {
script.remove();
}
super.onDispose();
}
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
return {
pages: [{
groups: [
{
groupName: 'Airgentic Settings',
groupFields: [
PropertyPaneTextField('accountId', {
label: 'Account ID',
description: 'Your Airgentic account ID (provided by Airgentic)'
}),
PropertyPaneTextField('serviceId', {
label: 'Service ID',
description: 'Your Airgentic service ID (provided by Airgentic)'
}),
PropertyPaneTextField('redirectUri', {
label: 'Redirect URI',
description: 'The callback page URL (e.g. https://yourorg.sharepoint.com/sites/intranet/SitePages/callback.aspx)'
})
]
},
{
groupName: 'Search UI (Optional)',
groupFields: [
PropertyPaneTextField('searchInputId', {
label: 'Search Input ID',
description: 'The ID of your site\'s search input element (no # prefix). Leave blank if not using Search UI.'
}),
PropertyPaneTextField('searchButtonId', {
label: 'Search Button ID',
description: 'The ID of your site\'s search button element (no # prefix). Leave blank if not using Search UI.'
})
]
}
]
}]
};
}
protected get dataVersion(): Version {
return Version.parse('1.0');
}
}
npm install
npx heft build --production
npx heft package-solution --production
If your SharePoint environment uses classic pages and your administrator has enabled custom scripts, you can use a Script Editor web part to paste the embed code directly. However, this approach is being phased out by Microsoft and is not recommended for new deployments.
The authentication flow requires a callback page — the page your identity provider redirects users to after sign-in. On SharePoint, we recommend creating a dedicated callback page rather than using the same page that hosts the widget.
Understanding the authentication flow helps explain why the callback page is needed:
The user stays on the callback page after sign-in — they are not automatically returned to the page they started from. This is standard OIDC behaviour.
https://yourorg.sharepoint.com/sites/intranet/SitePages/callback.aspx. You can name it anything (callback, airgentic-login, etc.).On every other page where you add the Airgentic web part, set the Redirect URI property to point to your callback page — not to the page itself.
For example, if your callback page is https://yourorg.sharepoint.com/sites/intranet/SitePages/callback.aspx, then:
| Page | Redirect URI setting |
|---|---|
| Homepage | https://yourorg.sharepoint.com/sites/intranet/SitePages/callback.aspx |
| HR Portal | https://yourorg.sharepoint.com/sites/intranet/SitePages/callback.aspx |
| Callback page | https://yourorg.sharepoint.com/sites/intranet/SitePages/callback.aspx |
All pages point to the same callback URL.
Since users stay on the callback page after authentication, consider making it a page where they'd naturally want to use the widget — such as your main intranet homepage — rather than a blank page.
Alternatively, you can create a simple callback page with a message like "You're now signed in. Return to [Homepage] to continue." with a link back.
Your SharePoint origin must be included in the Airgentic service configuration. When you send your details to Airgentic (see Registering Airgentic in your Identity Provider), include your SharePoint origin:
https://yourorg.sharepoint.com
If your organisation uses a custom domain for SharePoint (e.g. https://intranet.yourorg.gov.au), use that instead.
The Airgentic widget itself uses iframes internally — this is normal and works correctly on SharePoint.
However, if the SharePoint page that hosts the widget is loaded inside another iframe (for example, if someone embeds the SharePoint page within Microsoft Teams using an iframe, or wraps it in a third-party portal), the authentication redirect may fail. Identity providers such as Microsoft Entra ID block their sign-in pages from rendering inside nested iframes.
Ensure the SharePoint page with the Airgentic widget is loaded as a top-level page in the browser, not embedded inside another frame.
If your intranet is accessed through Microsoft Teams or Viva Connections, be aware that these environments can wrap SharePoint pages in ways that interfere with redirect-based authentication. If your users access the intranet through Teams or Viva, test the widget in those environments specifically to confirm the sign-in flow works correctly.
The widget stores authentication state in the browser's session storage, scoped to the top-level window. This means:
If your organisation uses group-based authorisation and users belong to a large number of groups (more than 150), Microsoft Entra ID may not include all groups directly in the token. In this case, Entra ID returns a link to the Microsoft Graph API instead. If you plan to use group-based authorisation, let Airgentic know how many groups your users typically belong to so we can ensure the configuration handles this correctly.
| Step | Action |
|---|---|
| 1 | SharePoint admin adds https://chat.airgentic.com to trusted script sources |
| 2 | Deploy an SPFx web part that loads the Airgentic widget script |
| 3 | Create a dedicated callback page with the same web part |
| 4 | Register the callback page URL in your Entra ID app registration |
| 5 | Send your SharePoint origin, client ID, client secret, tenant ID, and callback URL to Airgentic |
| 6 | Test sign-in and widget functionality |
| 7 | If accessing via Teams or Viva, test in those environments too |
chat.airgentic.com. If present, the trusted script source has not been added (Step 1).data-auth-redirect-uri does not exactly match the redirect URI registered in Entra ID. SharePoint page URLs are case-sensitive and include the full path — ensure they match character for character.If you need help, contact Airgentic support — see Contacting Airgentic.