Back to Dashboard

Documentation

Learn how to use Asyntai

Haystack Integration

Answer from a whole website inside your Haystack pipelines and agents

Create Account

Overview

Haystack is a Python framework for building AI pipelines and agents. The asyntai-haystack package connects them to an Asyntai website agent.

Point Asyntai at a domain. Asyntai crawls the site, reads the product feed, and keeps both fresh. Your pipeline then asks that website a question and gets the answer a visitor would get, built from the real pages and the real prices.

The same package feeds the website agent from your own indexing pipelines, and gives a Haystack agent the chats visitors had and the leads they left.

Components

  • AsyntaiGenerator — answers a prompt from the website's pages, products and knowledge base.
  • AsyntaiChatGenerator — the same, with chat messages in and out.
  • AsyntaiDocumentWriter — stores Haystack documents in the website agent's knowledge base.
  • AsyntaiUrlIndexer — reads web pages into the knowledge base.
  • AsyntaiToolset — six tools for a Haystack agent: ask the website, add a text, add a page, list the knowledge, read the leads, read a chat.

Requirements

  • Python 3.10 or higher
  • Haystack 2.14 or higher, including Haystack 3
  • An Asyntai account on the Starter plan or higher, because the package uses the Asyntai API

Installation

Follow these steps to add Asyntai to Haystack:

1

Install the Package

Run pip install asyntai-haystack.

2

Get Your API Key

Sign in to Asyntai, open Settings, then API, and copy your API key.

3

Set the Key

Put the key in the ASYNTAI_API_KEY environment variable. Every component reads it from there, so a saved pipeline never contains the key itself.

4

Add a Component

Add the components to your pipeline, or hand the toolset to your agent.

Ask a Website a Question

from haystack_integrations.components.generators.asyntai import AsyntaiGenerator

generator = AsyntaiGenerator()
result = generator.run(prompt="How long does delivery take?")
print(result["replies"][0])

Pass the session_id from result["meta"][0] on the next call to keep the conversation going.

Teach the Website Agent from Your Files

from haystack import Pipeline
from haystack.components.converters import TextFileToDocument
from haystack_integrations.components.writers.asyntai import AsyntaiDocumentWriter

pipeline = Pipeline()
pipeline.add_component("converter", TextFileToDocument())
pipeline.add_component("writer", AsyntaiDocumentWriter())
pipeline.connect("converter.documents", "writer.documents")

pipeline.run({"converter": {"sources": ["faq.txt", "returns.txt"]}})

Any converter works in front of the writer: PDF, DOCX, HTML or Markdown. The website chat answers from the new content right away.

Give an Agent the Asyntai Tools

from haystack.components.agents import Agent
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.dataclasses import ChatMessage
from haystack_integrations.tools.asyntai import AsyntaiToolset

agent = Agent(
    chat_generator=OpenAIChatGenerator(model="gpt-4o-mini"),
    tools=AsyntaiToolset(),
)
result = agent.run([ChatMessage.from_user("Who asked about delivery this week?")])
print(result["messages"][-1].text)

Give the agent only some tools with AsyntaiToolset(tools=["asyntai_ask_website"]).

Several Websites on One Account

An Asyntai account can run an agent per website. Name the one you want with website_id.

from haystack_integrations.common.asyntai import AsyntaiClient
from haystack_integrations.components.generators.asyntai import AsyntaiGenerator

for site in AsyntaiClient().websites():
    print(site["id"], site["domain"])

generator = AsyntaiGenerator(website_id=42)

Tip: The answer quality follows the knowledge base. Feed the documents that matter through AsyntaiDocumentWriter, and check the result with the asyntai_list_knowledge tool.

Errors

Every failure raises AsyntaiError with a message you can show to a user. The writer and the URL indexer take raise_on_failure=False to log a refused item and continue with the rest.

Plans & Pricing

The package is free. It uses the Asyntai API, which needs the Starter plan or higher. View pricing.

Need Help?

If you have any questions or run into issues, contact us at [email protected].