Embedding the AI Analyst Chat
Last updated
Last updated
The Arcwise AI Analyst can be embedded as an iframe within your page or application using our embeddable chat page, https://sql.arcwise.app/chat-embed, as the source.
Using this method, we allow the outer frame to pass parameters into the embeddable chat page using the following query parameters.
spreadsheet_id
If you have used the Arcwise AI Analyst in Sheets, you may provide the Sheets spreadsheet id to chat across the connected tabs in that spreadsheet.
table
Instead of passing in a spreadsheet_id
, you may provide fully-qualified table names in the form of table=db.schema.table
to scope any new chat threads with the Arcwise AI Analyst to only those tables provided. Multiple tables can be added to the AI Analyst context by providing this query parameter multiple times like so: table=db.schema.table1&table=db.schema.table2&table=...
custom_instructions
This parameter may be used to provide any specific custom instructions to the Arcwise AI Analyst, which will be appended to its system context.
By default, the embedded AI Analyst chat will display a Google login button and ask the user to authenticate manually.
If you'd like to allow users to skip the login flow, the embedding URL may provide a user-specific JWT token via a #token
hash parameter (example: https://sql.arcwise.app/chat-embed?table=x#token=JWT_TOKEN
).
JWTs must be created programmatically in your embedding code through a server-side endpoint, to avoid leaking the Embed Secret.
Go to https://admin.arcwise.app/#/organizations and click to Edit your organization. On the next screen, click Manage Embed Secret.
Generate a new embed secret (important: you will only be shown this secret once, so you must store it securely in your application environment (e.g. as an environment variable) when it is created.
Also, copy and store the organization_id
in your application (this is non-sensitive).
Generate a JWT with the following payload format using the Embed Secret as the JWT key, and the Arcwise organization ID as the issuer, using the HS256 encryption algorithm. All fields in the payload are required.
"sub"
should be the user's Google account email address. It must match the Google email they use to access Arcwise.
"aud"
specifies the audience for the JWT (Arcwise).
"iat"
should be the current UNIX timestamp.
"iss"
must be your Arcwise Organization ID from above.
"exp"
determines how long the JWT will be valid. The user will be logged out of the iframe after this time, so we recommend setting this to a fairly large number of hours (depending on your organization's security policy).
Example with the PyJWT Python library