# Synapse

**What is Synapse?**

The Synapse node in StackAI allows you to query your Synapse database using either plain English or SQL. It automatically translates your request into a SQL query, executes it, and returns the results, making data access simple and intuitive for users of all technical backgrounds.

**How to use it?**

To use the Synapse node, you need to provide two required inputs:

1. **Schema** (Required): The structure of your database, including tables, columns, and data types. This helps the node understand how to interpret your query.
2. **Query** (Required): Your question or command, written in plain English or SQL. The node will process this and generate the appropriate SQL to fetch your data.

**Example of Usage**

Suppose you have a table called Customers with columns Name (TEXT), Email (TEXT), and Revenue (REAL).

* **Schema Example:**

  ```
  TABLE Customers (
    Name TEXT,
    Email TEXT,
    Revenue REAL
  );
  ```
* **Query Example (Plain English):**

  ```
  What is the total revenue for all customers?
  ```
* **Query Example (SQL):**

  ```
  SELECT SUM(Revenue) FROM Customers;
  ```

**Inputs**

| Name   | Description                                                                 | Required | Example                                                                                 |
| ------ | --------------------------------------------------------------------------- | -------- | --------------------------------------------------------------------------------------- |
| Schema | Database Schema (tables, columns, types, etc.)                              | Yes      | `TABLE Customers (Name TEXT, Email TEXT, Revenue REAL);`                                |
| Query  | Enter your query in plain English or SQL format to execute against database | Yes      | `What is the total revenue for all customers?` or `SELECT SUM(Revenue) FROM Customers;` |

**Configurations**

* No additional configurations are required. All you need is the schema and the query.

**Outputs**

| Name    | Description                     | Required | Example                               |
| ------- | ------------------------------- | -------- | ------------------------------------- |
| Query   | The SQL query that was executed | Yes      | `SELECT SUM(Revenue) FROM Customers;` |
| Results | Results of the Synapse query    | Yes      | `[{"SUM(Revenue)": 100000}]`          |

**Available Actions**

* **Query a Synapse Database**: This is the primary action, allowing you to run queries and retrieve results from your Synapse database.

**Summary Table**

| Action Name              | Description                    | Required Inputs | Outputs            |
| ------------------------ | ------------------------------ | --------------- | ------------------ |
| Query a Synapse Database | Run a query on your Synapse DB | Schema, Query   | SQL Query, Results |

**Best Practices**

* Always provide an accurate and up-to-date schema for best results.
* You can use either plain English or SQL for your queries.
* Review the output SQL to ensure it matches your intent.

**Use Case Example**

If you want to find the top 5 customers by revenue, provide the schema and use the query:

```
Show me the top 5 customers by revenue.
```

The node will generate the SQL, execute it, and return the results.

***

The Synapse node in StackAI streamlines database querying, making it accessible and efficient for all users.


---

# Agent Instructions: 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:

```
GET https://docs.stackai.com/workflow-builder/apps/synapse.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
