PostgreSQL

v24.5.0
Maintained by Envyro

PostgreSQL Integration for Botpress

Empower your Botpress chatbot with PostgreSQL to manage your database. Create, query, update, and delete database tables directly through your chatbot. Ideal for automating database workflows.

Table of Contents

Introduction

The PostgreSQL integration for Botpress empowers your chatbot to manage your database. Create, query, update, and delete database tables directly through your chatbot. This integration is ideal for automating database workflows.

PostgreSQL Setup & Configuration

Prerequisites

Before enabling the Botpress PostgreSQL Integration, please ensure that you have the following:

  • A Botpress server instance set up either locally or in the cloud.
  • PostgreSQL database credentials with appropriate permissions.

Enable Integration

To enable the PostgreSQL integration in Botpress, follow these steps:

  1. Access your Botpress admin panel.
  2. Navigate to the “Integrations” section.
  3. Locate the PostgreSQL integration and click on “Enable” or “Configure.”
  4. Provide the required dbUser, dbHost, dbName, dbPassword, and dbPort.
  5. Save the configuration.

Actions

Here are the actions supported by the PostgreSQL integration:

Create Table

Create a new table in the PostgreSQL database.

Drop Table

Drop an existing table from the PostgreSQL database.

Insert Data

Insert data into a specified table.

Delete Data

Delete data from a specified table based on conditions.

Update Data

Update data in a specified table based on conditions.

Query Data

Query data from a specified table based on conditions.

Custom Query

Execute a custom SQL query on the PostgreSQL database.

Use Cases

Here are some common use cases for the PostgreSQL integration:

  1. Database Management
  • Enable users to create and drop tables.
  • Use the Create Table and Drop Table actions to manage database schema.
  1. Data Entry
  • Allow users to insert data into tables.
  • Use the Insert Data action to add new records to the database.
  1. Data Retrieval
  • Retrieve and display data from the database.
  • Use the Query Data action to fetch records based on user input.
  1. Data Modification
  • Update and delete records in the database.
  • Use the Update Data and Delete Data actions to modify existing records.
  1. Custom Queries
  • Execute complex SQL queries directly.
  • Use the Custom Query action for advanced database operations.

Popular SQL Commands

To aid beginner SQL users, here are some popular SQL commands:

  1. Create Table
   CREATE TABLE users (
       id SERIAL PRIMARY KEY,
       name VARCHAR(100),
       email VARCHAR(100) UNIQUE NOT NULL
   );
  1. Insert Data
   INSERT INTO users (name, email) VALUES ('John Doe', 'john.doe@example.com');
  1. Select Data
   SELECT * FROM users;
  1. Update Data
   UPDATE users SET name = 'Jane Doe' WHERE email = 'john.doe@example.com';
  1. Delete Data
   DELETE FROM users WHERE email = 'john.doe@example.com';
  1. Drop Table
   DROP TABLE users;

Supported Events

This integration does not currently include events that trigger based on PostgreSQL activities. However, you can customize the integration to listen for specific database event notifications via triggers or other mechanisms in PostgreSQL.