Skip to content

🎨 Custom API – UI Templates

Ainisa allows you to turn raw API responses into interactive UI cards inside your web chat widget.
This means your assistant can fetch data from any API — and then display it visually using custom templates like product cards, job listings, contact results, payment cards, notifications, invoices etc.

This feature is available for web integrations (Ainisa web chat widgets).


🧭 Accessing UI Templates

After creating your Custom API Action, go to your actions list:

  1. Open AI Actions for your assistant (from https://ainisa.com/business/agents)
  2. Find the API action you want to design
  3. Click the three dots (…) menu → choose Set UI Template

AI Actions List


🧱 Steps to Configure UI Template

On the “Set UI Template” page, you’ll see a split view with API data on the right and your configuration form on the left.

Set UI Template Overview


1. Get API Results

Send a test request to your API endpoint to fetch real data.
Click Get Results — the API response will appear in a JSON tree viewer.


2. Array or Object?

  • Enable Is Array if your API returns a list of items (e.g. jobs, products, orders).
  • Leave it disabled if your API returns a single object with details.

3. Set Data Path

If your array is nested (e.g. inside data or results), you can define its path.

Example:

json
{
  "current_page": 1,
  "data": [ { "id": 14520, "title": "Sürücü" } ]
}

👉 Data path: data

4. Set Field Keys

After selecting your template type, you’ll need to map the fields in your template to the corresponding keys in your API response.
This is how Ainisa knows which value to display in each section of the UI card.

For example, if your API response looks like this:

json
{
  "id": 14520,
  "title": "Sürücü",
  "company_name": "Unicomp MMC",
  "city": {
    "title_az": "Bakı"
  },
  "min_salary": 500,
  "max_salary": 800,
  "salary_currency": "AZN",
  "image": "https://example.com/job-image.jpg"
}

Then your field mapping might look like this:

Template FieldExample JSON KeyTypeDescription
Job Title KeytitlestringThe title or name of the job or item
Company Name Keycompany_namestringThe company or brand name
City Keycity.title_azstringThe location or city name
Minimum Salary Keymin_salarynumberLower end of salary range
Maximum Salary Keymax_salarynumberUpper end of salary range
Currency Keysalary_currencystringCurrency symbol or code
Image KeyimagestringURL of the image to display
Job ID KeyidnumberUnique identifier for the item
View / Apply Link KeyviewLink or applyLinkstringURL for viewing or applying to the item
Salary Undefined Keysalary_undefinedbooleanMarks when salary is not specified

💡 Tip:
Use dot notation (city.title_az) to access nested object fields.
Ainisa automatically validates paths and updates the preview in real time.

Template Field Mapping

When you fill in all keys correctly, the preview card on the right will render your data in the selected template layout — allowing you to instantly verify that the information appears in the right place.

See example inside chat widget:

Template Field Mapping