← Files Sulekha EventsARCHIVED FILE

source/README.md

11.2 KB · Nov 30, 2026 · 07:53 UTC

↓ Download file

# Sulekha Events — ChatGPT Apps SDK

One public, read-only tool (`search_sulekha_events`) and one results widget.
Users search by keyword/location and open, copy or share public event links.
No account login, booking, payment, customer form or database is implemented.

## Run and test

Node.js 22.11 or newer:

```sh
npm ci
npm run check
npm test
npm start
```

For local development, the root `.env` is loaded unless `NODE_ENV=production`.
The confirmed events API URL and search path are built in. Host environment
variables override these public defaults. See `.env.production.example`.

## Deploy on your existing Azure Windows app

```sh
npm run prepare:deploy
```

Upload the **contents** of `deploy/` to the **staging slot's** website root.
It contains exactly three files: `server.js`, `package.json`, `web.config`.
The server is a CommonJS bundle containing all runtime dependencies and the UI.
**There is no npm install or build step on Azure.** Use ordinary ZIP deployment;
server-side build automation (`SCM_DO_BUILD_DURING_DEPLOYMENT`) can be disabled.
VS Code's workspace task rebuilds this folder before uploading to staging.

Use these Azure environment variables (the API URL, path and widget domain
already have these defaults; only change them to override the defaults):

```text
NODE_ENV=production
SULEKHA_EVENTS_WEB_BASE_URL=https://sulnriwebapps.azurewebsites.net/
SULEKHA_EVENTS_WEB_SEARCH_PATH=api/1.0/plugai/getsearchresultsnriai
WIDGET_DOMAIN=https://events.sulekha.com
WIDGET_ASSET_ORIGIN=https://sulainodeapp-staging-ekevbhe4f2bmdchc.eastus-01.azurewebsites.net
```

Use Node.js 22.11 or newer. IIS supplies `PORT`; do not override it.
Restart the staging slot after a successful upload.

Health: https://sulainodeapp-staging-ekevbhe4f2bmdchc.eastus-01.azurewebsites.net/health

Expected current response:

```json
{"status":"ok","version":"0.4.6","build":"apps-sdk-widget-11"}
```

If that build identifier is absent, the current package is not active.
Check the upload result and selected slot; changing local code cannot replace
an aborted upload. Check the complete live integration with:

```sh
npm run verify:live -- https://sulainodeapp-staging-ekevbhe4f2bmdchc.eastus-01.azurewebsites.net
```

This checks the build, MCP tools, UI metadata and a real upstream search.
Unit/integration tests use a local API fixture and separately run the deployment
bundle from a temporary folder without this repository's `node_modules`.
Windows IIS itself and ChatGPT desktop/mobile rendering require hosted testing.

## Publish to the ChatGPT directory

The server endpoint is:
https://sulainodeapp-staging-ekevbhe4f2bmdchc.eastus-01.azurewebsites.net/mcp

`submission/plugin.json` and `submission/mcp.json` are **draft listing files**,
not a finished submission. The hosting package (`deploy/`) runs on Azure; the
listing package points ChatGPT to that server. A listing upload does not host it.

Before submission:

1. Establish a reliable production HTTPS endpoint. The current host and upstream
   are staging services; OpenAI's remote MCP requirements exclude testing endpoints.
   Update `submission/mcp.json` and `WIDGET_DOMAIN` when the production host is chosen.
2. Complete the listing with approved website, privacy-policy, support and terms
   URLs; provide the official logo. Add these in `extensions.com.openai.interface`
   (`websiteURL`, `privacyPolicyURL`, `supportURL`, `termsOfServiceURL`, `logo`).
   None have been invented here. The privacy policy must cover this app's real data
   handling, including hosting/API logs and search inputs.
3. Verify the publishing identity and domain through the OpenAI submission portal.
4. Connect `/mcp` in ChatGPT with no authentication and test search, no results,
   API failures, image fallback and event links on desktop and mobile. Record actual
   results and a demo for review. The draft test cases are expectations, not results.
5. ZIP the contents of `submission/` after completing the assets and metadata.
   Upload it to the OpenAI plugin submission portal, connect/scan the MCP server,
   resolve findings, and submit for review. Publish after approval.

Official references:
- https://developers.openai.com/plugins/deploy/submission
- https://developers.openai.com/plugins/deploy/app-review
- https://developers.openai.com/plugins/reference

### Existing ChatGPT connections

Both previously advertised widget addresses (`events-v10.html` and
`events-v11.html`) remain readable, so cached tool metadata can still load the
component. After updating the app, refresh the connection's tools/metadata and
test in a new chat. A successful MCP resource read verifies resource delivery;
actual ChatGPT rendering must also be checked in the client.

### Self-contained widget startup

The widget embeds its JavaScript directly in the MCP HTML resource, following
OpenAI's component template pattern. Startup requires no separate asset request.
This fixes the observed staging/production mismatch: staging returned the widget
HTML successfully, but its production script URL returned HTTP 500, preventing
the initialization handshake and causing the client to report a timeout.

The current resource is `ui://sulekha/events-v20.html`. Previously advertised
v10–v19 resource addresses return the same corrected HTML. The old hashed script
endpoint remains available for compatibility. `WIDGET_ASSET_ORIGIN` is retained
for compatibility but no longer determines where the current widget starts.
Deploy `sulekha-azure-widget-fix.zip` to the affected slot, restart it, refresh
the ChatGPT connection, and test a new chat. Expected health build:
`apps-sdk-widget-11`. A passing server verification does not replace a real
ChatGPT rendering check.

Production returned HTTP 500 for both `/health` and `/mcp` during diagnosis.
Embedding the widget removes staging's dependency on that failing host; it does
not establish that production's separate hosting problem is repaired. Review
Azure startup logs if production still returns 500 after deployment.

Reference: https://developers.openai.com/plugins/build/chatgpt-ui

### Search API authentication

Set `SearchApiAuth__ClientId` and `SearchApiAuth__Secret` on the Node host to match the C# API. Production reads Azure/IIS application settings rather than local `.env`. Keep the secret out of tracked files and widget code.

For this deployment, select **sulainodeapp → staging → Settings → Environment variables**
in Azure, and add both authentication settings using the working local values.
Save the settings and restart the staging slot. Do not upload `.env` or put the
secret in the deployment ZIP. Run `npm run verify:live -- https://sulainodeapp-staging-ekevbhe4f2bmdchc.eastus-01.azurewebsites.net`
afterward. A healthy `/health` response alone does not verify API authentication.
If authentication is rejected, check the staging logs and confirm both API and
Node hosts use matching credentials and synchronized clocks.

Each request sends `X-Client-Id`, `X-Timestamp` (Unix seconds), `X-Nonce` (fresh UUID), and `X-Signature` (hex HMAC-SHA256). The signed UTF-8 payload joins timestamp, nonce, uppercase method, and exact path plus query with newlines. Redirects are rejected because signatures are bound to the requested URL.

Direct browser navigation lacks these headers and is expected to be rejected. Keep both hosts' clocks synchronized for the validator's 60-second window. Replay prevention requires an atomic nonce cache shared by API instances, retaining accepted nonces through timestamp plus 60 seconds (up to 120 seconds after acceptance for future timestamps).

## Search intent and location

Location-only requests such as “show me events in PA”, “find events in NJ”,
and “get events in CA” must use an empty `query`. Do not carry over an artist
from a previous request unless the user explicitly refers to it. Preserve user-chosen
keywords and language. Use `stateCode` for a strict US state or Canadian province
boundary. `country: "CA"` means Canada; `stateCode: "CA"` with `country: "US"`
means California. Clarify bare CA when context is ambiguous. Supply coordinates and a radius covering the requested
area, and leave `cityUrl` empty for state searches. For city searches supply
the city slug and coordinates. Only include an artist or genre keyword when
the user explicitly asks for one.

The server excludes artist/organizer suggestions and filters country and region before
applying the result limit. Geographic coverage still depends on the upstream
API's returned records and radius (maximum 500 miles); results are not a
guaranteed complete statewide inventory. Local changes require deployment
and the client refreshing tool metadata before the new state input is usable.

Country filtering uses recognized US state and Canadian province/territory codes
in upstream records. Records with missing or unrecognized region codes are excluded
rather than assigned a guessed country. The upstream request still uses its existing
city/coordinate parameters; no undocumented country parameter is assumed.

## Search input minimization

The public MCP tool accepts event keywords and location filters, not full chat
messages. Legacy `rawQuery` input is discarded at the MCP boundary before API
requests. The internal API helper remains backwards compatible for separate
callers, but the public plugin never forwards full-message input.

## OpenAI domain verification

Set `OPENAI_APPS_CHALLENGE_TOKEN` in the production Azure application settings
to the current token shown by the submission portal. The server returns its
exact value at `/.well-known/openai-apps-challenge` for GET and HEAD (empty
body for HEAD). Without a configured token the route returns 404.
Deploy the rebuilt Azure bundle, then click Verify Domain in the portal.

## Platform label

Each upstream request includes `platform`: `appsSDK`, `Claude`, `Perplexity`,
or `unknown`. It is supplied by the server, not by the model's search arguments.
Recognized MCP client-name hints are used when available. This server creates a
fresh MCP instance per HTTP request, so initialization client information may
not be available during later tool calls; missing hints produce `unknown`.
For a deployment dedicated to one platform, configure `SULEKHA_PLATFORM=appsSDK`
(or `Claude` / `Perplexity`). Do not set a fixed label on a deployment shared
across platforms. The API should store this as an analytics hint, not identity.

## Production deployment

Production host: https://sulainodeapp-agcbddf0b4d8dybg.eastus-01.azurewebsites.net

Upload the contents of `sulekha-azure-production.zip` to the production website root.
Set `NODE_ENV=production`, `WIDGET_DOMAIN=https://events.sulekha.com`, and
`WIDGET_ASSET_ORIGIN=https://sulainodeapp-agcbddf0b4d8dybg.eastus-01.azurewebsites.net` in Azure application settings.
The obsolete `WIDGET_ASSET_ORIGIN_STAGGING` setting is no longer used.
Configure `SearchApiAuth__ClientId` and `SearchApiAuth__Secret` securely on the host.
The upstream events API remains `https://sulnriwebapps.azurewebsites.net/`.
See `.env.production.example` for the complete configuration.
Staging deployments must explicitly set `WIDGET_ASSET_ORIGIN` to their staging host.

Production MCP endpoint: https://sulainodeapp-agcbddf0b4d8dybg.eastus-01.azurewebsites.net/mcp

After deployment, run `npm run verify:live -- https://sulainodeapp-agcbddf0b4d8dybg.eastus-01.azurewebsites.net`.

SHA-256: a45ab289abc91b624ce90f21bf191687b19e865a16c8ab6d52479d1e2dacf262