LogoLogo
PlatformConnectivityFlowsLearn
  • Getting Started
    • Welcome to Fastn
    • How Fastn Works
  • Your First Automation
  • Customer-Facing Integrations
    • Introduction to Embedded Integrations
    • Custom Webhooks: Automatic Triggers
    • Configuring the Embedded Experience
    • Workspace Management
  • Analytics & Monitoring
  • Building Flows
    • Flow Setup Essentials
    • Designing a Flow
    • Using Templates
  • Connecting Apps
    • Connector Types & Setup
    • Managing & Using Connectors
  • Data & Storage
    • Connect to the Fastn DB
    • Connecting External Databases
  • UCL - Unified Command Layer
    • About Fastn UCL
    • Getting Started with UCL
  • Multitenancy
  • Embedding Fastn UCL onto your AI Agent
  • UCL Monitoring
  • Fastn UCL Use Cases
    • Create a Google Doc and Share it to Slack - using Fastn UCL
    • Connect Fastn UCL to AI Assistant Preview for task Assignment in Jira
    • Connect Fastn UCL to Cursor and access data from Notion
  • Tutorials
    • Setting Up a HubSpot Integration in Your Platform
  • Additional Resources
    • Glossary
    • FAQs
Powered by GitBook
On this page

Was this helpful?

  1. Data & Storage

Connect to the Fastn DB

Connections to the Fastn database can be added into flows using the database flow element.

PreviousManaging & Using ConnectorsNextConnecting External Databases

Last updated 14 days ago

Was this helpful?

Database elements can be added when building a flow and configured with an SQL query to perform database operations.

Since database flow elements allow users to add SQL queries, they can be used to create tables.

An alternative way of creating a table in the Fastn DB is to navigate to the Databases page from the left side menu and then click on the Fastn DB.

Click on the Create Table button here to create a new table in the database.

Next you can define the table structure by specifying the name of the table and defining its columns. Once you have entered all the necessary details, you can save the table configuration and see it added in the database.

Example: Storing Slack Messages in a Fastn Database

Once you've added a Database element while building your flow, you can configure it with a custom SQL query to perform operations like inserting data into a table. Here's a simple use case:

Let’s say you're building a flow that captures messages from a Slack channel and stores them in a Fastn database.

First, ensure you've already created a table to hold the messages. You can do this by either:

  • Using an SQL query inside a flow (as shown below), or

  • Navigating to the Databases section from the sidebar, selecting Fastn DB, clicking Create Table, and defining the table structure manually.

For this example, suppose your table structure looks like this:

CREATE TABLE slack_messages (
  id SERIAL PRIMARY KEY,
  channel_name TEXT,
  user_name TEXT,
  message TEXT,
  timestamp TIMESTAMP
);

Now, in your flow, after receiving a message from Slack via a trigger like On App Event or On Chat Message, add a Database element and write an SQL query like this:

INSERT INTO slack_messages (channel_name, user_name, message, timestamp)
VALUES (:channel_name, :user_name, :message, :timestamp);

Here, :channel_name, :user_name, :message, and :timestamp are dynamic variables that map to the data coming from the Slack trigger.

This setup allows every new Slack message to be captured and stored in your database in real time; enabling you to build logs, run analytics, or even trigger additional downstream processes.