Skip to content
DaneshyarDocs
Sign in
  • Introduction
  • Quickstart
  • What is Daneshyar?
  • The Apps page
  • Inside an app
  • Workspace: files and chat
  • Sharing and members
  • Notes and dictation
  • Language practice
  • Appointment booking
  • Automations
  • The file reader
  • Your profile
  • Wallet
  • Customer chats
  • API keys
  • Authentication
  • Apps, workspaces, resources
  • Ingestion
  • Chat and sessions
  • Citations
  • Skills
  • Conventions
  • Workspaces
  • Resources
  • Chat
  • Skills
  • Errors
  • Customer support assistant
  • Internal knowledge base
  • Documentation chatbot
  • Academy tutor
  • Embedded widget
  • Widget configuration
  • Framework guides
  • Security
  • Troubleshooting
  • FAQ
  1. Docs
  2. Embedded widget
  3. Embedded widget

Embedded widget

One script tag puts a chat on your site. It answers only from the documents in one workspace.

The widget is a chat panel for your own website. A visitor asks a question and gets an answer taken only from the documents in the workspace you choose. Visitors do not sign in, cannot upload or change anything, and do not see your files or which document an answer came from.

The key in the snippet is a public widget key (pk_…). Anyone can read it in your page source, but it can only ask questions — it cannot use the REST API, list files or change anything. Read Securing the widget key before you go live.

Add it in three steps

  1. 1

    Open the Embed page

    In the console, open your app, then the workspace the widget should answer from, and choose Embed. The page shows a live preview and your snippet. Change the look (color, theme, language, texts) and press <b>Save</b>: the next time you open the page, even after you sign in again, it shows the look you saved. Only the workspace owner can save it. At the top, turn on <b>Widget for this workspace</b>: a new workspace starts off, and the widget does not answer for a workspace that is off — not even on an allowed site.

  2. 2

    Add your domain

    Under Allowed domains, add every site that will show the widget, for example clinic.ir and www.clinic.ir. All sites are blocked by default: with an empty list, the widget works on no site.

  3. 3

    Paste the snippet

    Copy the snippet and paste it into your site, once per page, just before </body>. It loads with async, so it does not slow your page down.

    HTML
    <script
      src="https://app.daneshyar.info/widget.js"
      data-api-key="sk_9f3aC2xQ7mB1vT8sE4nK6pR0jY5wZ2hL"
      data-app-id="2d7c0e91-4a5b-4f8e-b3c6-9e1f0a7d5c42"
      data-workspace-id="8f14e45f-ceea-467a-9f4c-1a2b3c4d5e6f"
      async
    ></script>

Using React, Next.js, Vue or another framework? See Framework guides.

How it works

The script draws a button on your page. When a visitor opens it, the chat loads inside an iframe on Daneshyar's own site, so your CSS cannot break it and it cannot read your page.

Your pageLoads widget.js and draws the chat button.<script src="…/widget.js">
The widget iframeRuns on Daneshyar's site. The browser shows it only on your allowed domains, and our server answers only questions from them.frame-ancestors
The widget APIChecks the widget key and finds an answer in your documents. The answer has no sources./api/widget/chat/
On a site that is not in your allowed list, the browser refuses to show the iframe, and the visitor sees nothing.
Your page loads widget.js. The script opens an iframe on Daneshyar's site. The iframe sends each question to the widget API with your widget key and your page's address. The browser refuses to show the iframe, and our server refuses to answer, on sites that are not in your allowed list.
  • The widget only reads. It lists the workspace's documents and answers questions about them.
  • It talks to two endpoints only: /api/widget/config/ and /api/widget/chat/.
  • Answers are grounded. If the documents do not hold the answer, the widget says so instead of guessing.

About the key in the snippet

The widget authenticates with the app's public widget key. It is not the key the REST API accepts. What it can and cannot do:

  • It can ask questions only in the workspaces where you turned the widget on, and read the widget's allowed domains. Nothing else. Your other workspaces in the same app stay closed to it.
  • It cannot list, read or download your files, and its answers do not say which document they came from.
  • Answers still repeat what your documents say, so put only documents in this workspace whose content you are happy for visitors to learn.
For the REST API, use the secret key (sk_…) from your server. Never put the secret key in a snippet.

What visitors see

  • A round button in the corner of the page, or the chat inside an element you choose (inline mode).
  • A list of the documents the answers come from.
  • Answers in Persian or English, written only from your documents.
  • A full-screen chat on phones narrower than 480px.

Allowed domains

The allowed list says which sites may show the widget. It belongs to the whole app, so one list covers every workspace you embed. Enter a host, with no https:// and no path. A port counts as part of the host.

You enterWorks onDoes not work on
clinic.irclinic.irwww.clinic.ir
*.clinic.irwww.clinic.ir · help.clinic.irclinic.ir
localhost:5173localhost:5173localhost:3000
  • All sites are blocked by default. An empty list means the widget works on no site — only the preview in the console.
  • A wildcard like *.clinic.ir covers subdomains but not clinic.ir itself. Add both if you need both.
  • Today you cannot remove the last domain from the list in the console. To turn the widget off everywhere, delete the widget key on the app page.

Limits and costs

Each limit works on its own. When a visitor reaches one, the widget asks them to wait and try again later.

LimitDefaultWhat it counts
widget_chat_ip20 per hourQuestions from one IP address.
widget_chat_app500 per dayQuestions to your whole app, from every visitor.
widget_get_ip60 per hourLoads of the widget's settings and document list from one IP address.

Every answer is paid from the wallet of the account that owns the app, the same as a chat in the console. When the wallet is empty, visitors see “The assistant can't answer right now”, and they never see a billing message.

Widget configurationEvery option the widget reads, with defaults, and a builder that writes the snippet for you.Framework guidesWhere the snippet goes in HTML, React, Next.js, Vue, Nuxt, Angular, SvelteKit and Laravel.SecurityWhere each of your two keys may live, what protects it, and a checklist before you go live.TroubleshootingFind your problem by what you see, then read why it happens and how to fix it.
PreviousAcademy tutorNextWidget configuration

On this page

  • Add it in three steps
  • How it works
  • About the key in the snippet
  • What visitors see
  • Allowed domains
  • Limits and costs

Every example on this site runs against the live API. If one doesn't, tell us — that's a bug in the docs.

ServicesAboutTalk to us