Back to Dashboard

Documentation

Learn how to use Asyntai

Pulumi Provider

Manage your Asyntai AI chatbots as code, in the language you already use

Create Account

Overview

Pulumi manages infrastructure as code in TypeScript, Python, Go, C# or YAML. The Asyntai provider lets you create AI agents for your websites, set the widget look and behaviour, write the AI instructions, fill the knowledge base and register webhooks, all from your Pulumi program.

Agencies and teams that run chatbots on many sites keep every bot in version control, review changes in pull requests and roll out the same setup to each new site with one pulumi up.

Requirements

  • Pulumi 3 or later
  • An Asyntai account on the Starter, Standard or Pro plan. The API is part of these plans
  • Your API key from the API Settings page

Getting Started

1

Add the Package

Install the SDK for your language:

# TypeScript / JavaScript
npm install @asyntai/pulumi

# Python
pip install pulumi_asyntai

# Go
go get github.com/asyntai/pulumi-asyntai/sdk/go/asyntai

# .NET
dotnet add package Asyntai.Pulumi.Asyntai

Or generate a local SDK in any language with pulumi package add asyntai.

2

Set Your API Key

Copy the key from the API Settings page and store it in your stack as a secret, so it never sits in your files:

pulumi config set asyntai:apiKey --secret

The ASYNTAI_API_KEY environment variable works too.

3

Describe Your Chatbot

Add a website and anything you want to set for it. In TypeScript:

import * as asyntai from "@asyntai/pulumi";

const shop = new asyntai.Website("shop", {
    domain: "shop.example.com",
    name: "Shop assistant",
});

new asyntai.WebsiteSettings("shop", {
    websiteId: shop.id,
    settings: {
        ai_support_name: "Ava",
        widget_color: "#0f172a",
    },
});

export const embedCode = shop.embedCode;

The same in Python:

import pulumi
import pulumi_asyntai as asyntai

shop = asyntai.Website("shop", domain="shop.example.com", name="Shop assistant")

asyntai.WebsiteSettings("shop",
    website_id=shop.id,
    settings={"ai_support_name": "Ava", "widget_color": "#0f172a"})

pulumi.export("embed_code", shop.embed_code)
4

Deploy

pulumi up

Pulumi creates the agent and prints the embed code. Put it on your site, and the chat bubble is live. Asyntai reads the site and writes a first draft of the AI instructions, the same as when you add a website in the dashboard.

Resources

ResourceWhat it manages
asyntai.WebsiteA website (AI agent). Gives the widget ID and the embed code
asyntai.WebsiteSettingsWidget settings: the same settings as the Customize page, for example name, colours, welcome message and reply languages
asyntai.InstructionsThe AI instructions the agent follows
asyntai.KnowledgeTextA text item in the knowledge base, for example opening hours or a return policy
asyntai.KnowledgeUrlA web page in the knowledge base
asyntai.WebhookA webhook for new messages, new chats, leads, tickets and human takeovers

Two functions read what is already in your account: asyntai.getWebsites lists every website, and asyntai.getWebsite gives the widget ID, embed code and setup status of one website.

One Setup for Many Sites

Because a Pulumi program is real code, a loop rolls out the same chatbot to every site:

import * as fs from "fs";
import * as asyntai from "@asyntai/pulumi";

const domains =["shop.example.com", "blog.example.com", "help.example.com"];

for (const domain of domains) {
    const site = new asyntai.Website(domain, { domain });
    new asyntai.Instructions(domain, {
        websiteId: site.id,
        instructions: fs.readFileSync("instructions.md", "utf8"),
    });
}

Each change to the instructions keeps the previous text in the instruction history of the dashboard, so you can always go back.

Widget Settings

Pulumi manages only the settings you list. Every other setting keeps the value it has in the dashboard. Write each value as text: "true", "42" and "#0f172a" all work. For a list setting, use JSON, for example JSON.stringify(["en", "de"]). The output allSettingsJson shows every setting and its current value, so you can find the exact names.

Changes Made in the Dashboard

When someone changes a managed setting, the instructions or a knowledge item in the dashboard, pulumi preview --refresh shows the difference, and pulumi up --refresh sets it back to your program.

Importing What You Already Have

Bring existing websites, settings, instructions, text items and webhooks under Pulumi with pulumi import:

pulumi import asyntai:index/website:Website shop 42
pulumi import asyntai:index/instructions:Instructions shop 42

The getWebsites function lists the IDs of your websites.

Removing Resources

Knowledge items and webhooks are deleted when you remove them from your program. Websites, their settings and their instructions stay in your account together with their chat history, so pulumi destroy never takes a live chatbot offline. Delete a website in the dashboard when you no longer need it.

Plans & Pricing

The provider is free. It uses the Asyntai API, which is part of the Starter, Standard and Pro plans. View pricing.

Need Help?

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