> For the complete documentation index, see [llms.txt](https://docs.iadvize.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.iadvize.dev/use-cases/copilots/ai-knowledge-synchronization-through-api-1.md).

# FAQ sync through API

{% hint style="info" %}
This feature is under preview, this means we reserve the right to modify the behaviour of this part of the API without maintaining backward compatibility. To learn more about previews, [please follow this link.](/technologies/graphql-api/schema-lifecycle.md#preview)

The **`Accept`** header to add to HTTP requests in order to gain access to this preview is **`application/vnd.iadvize.knowledge-preview+json`**
{% endhint %}

## Introduction

This feature allows to keep knowledge about FAQs up to date, by allowing you to send updates, creations and deletion operations about the FAQ information your system holds. Upon receiving these events, we'll index the new knowledge such that your bot can use the very latest information to answer your visitors' questions.

To do so, we'll look into how you can create a knowledge source (your FAQ), and insert, update and delete knowledge items (your FAQ information).

## Step 1: Create a new KnowledgeSource

This operation will only need to be done once, therefore there is no need to write any code for it.

It consists in using GraphQL to create a new KnowledgeSource, and taking note of the identifier that was attributed to it. This identifier will be used during step 3.

{% tabs %}
{% tab title="Using Apollo" %}
You can open the GraphQL mutation [by clicking on this link](https://ha.iadvize.com/apollo?explorerURLState=N4IgJg9gxgrgtgUwHYBcQC4RxighigSwiQAIBpJCAdwBsEwBzBAZQhgCcoEBhdhfBAAoAJAGtKtek1YcuvfigQBJJAAcc6chLqMWbTjz4CV6lAEIAlCWAAdUiXHUd0-XKOLBjybpkH5xtQ0SMW0pPVlDBWVAlCtbexIHUJ9XBGs7RMySAjAMrJIkXEQ8xIBfPPKkUpAAGhAAN1x2AlwAIzoAZwwQeMSbEC9ncL93aNN%2BzV7M-rAEPAIaDon0hOmQADNcAEcAQVUCZgBPJChl4Eqs0pqSkn7C4oxbkAAee4QAPn7r1f7VdggAFYIKAoJS5R7PP6A4EoAC0OU%2B9kq1VKQA). You'll need to:

* Be logged in as an administrator.
* Replace the variables in the bottom panel with the identifier of your project, the name of the knowledge you're about to create ("API sync FAQ" for instance).
* Execute the query by clicking the KnowledgeSourceCreate blue button.
* Write down the identifier of the KnowledgeSource that will appear in the right panel.
  {% endtab %}

{% tab title="Manually" %}

<pre class="language-graphql" data-title="Graphql Mutation"><code class="lang-graphql"><strong>mutation KnowledgeSourceCreate(
</strong>  $knowledgeSourceCreateInput: KnowledgeSourceCreateInput!
) {
  knowledgeSourceCreate(knowledgeSourceCreateInput: $knowledgeSourceCreateInput) {
    knowledgeSource {
      id
      name
    }
  }
}

</code></pre>

{% code title="Variables" %}

```json
{
  "knowledgeSourceCreateInput": {
    "details": {
      "faqApiSync": {}
    },
    "name": "<name>",
    "projectId": <project-id>
  }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% hint style="info" %}
If you are requesting our GraphQL API directly, do not forget to [get your GraphQL token](/technologies/graphql-api/authentication.md) first
{% endhint %}

## Step 2: Synchronize your FAQs with us

Now you have a KnowledgeSource, you can add, update or delete items within that source. In order to do this, you'll need to react to events within your system and call our GraphQL API.

### Create or update an FAQ item

You can use this mutation, bearing in mind you can submit up to 100 FAQs in a single mutation.

{% code title="Mutation" %}

```graphql
mutation KnowledgeFAQsUpsert($input: KnowledgeFAQsUpsertInput!) {
  knowledgeFAQsUpsert(input: $input) {
    upsertedFAQs {
      faqId
      status
    }
  }
}
```

{% endcode %}

{% code title="Variables" %}

```json
{
  "input": {
    "knowledgeSourceId": "<id from step 1>",
    "faqs": [
      {
        "id": "1",
        "question": "How to return a product?",
        "answer": "You must send it to <your address>"
      }
    ],
  }
}
```

{% endcode %}

### Delete FAQ items

{% code title="Mutation" %}

```graphql
mutation KnowledgeFAQsDelete($input: KnowledgeFAQsDeleteInput!) {
  knowledgeFAQsDelete(input: $input) {
    deletedFAQs {
      faqId
      status
    }
  }
}
```

{% endcode %}

{% code title="Variables" %}

```json
{
  "input": {
    "knowledgeSourceId": "<id from step 1>",
    "faqIds": [
      "<FAQ item id from your system to delete>"
    ]
  }
}
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.iadvize.dev/use-cases/copilots/ai-knowledge-synchronization-through-api-1.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
