[Extension] How to connect a MongoDB database in Blip Smart Contacts April 22, 2024 13:31 Updated Table of contents: Introduction Features Installation and configuration User guide Dependencies Support Brief description: MongoDB for Blip has arrived to make developers' lives easier. Connect Blip directly to your PostgreSQL database without the need for intermediary APIs. With MongoDB for Blip, enter your connection credentials and execute database queries and operations directly in Builder or Studio. Keywords: MongoDB, database, NoSQL integration, PostgreSQL, connection, queries, API, router, Blip extension, efficiency, NoSQL. IntroductionMongoDB for Blip, developed by Sharkdev, is an extension that allows you to connect Blip directly to your MongoDB database using connection data, eliminating the need to build and maintain an intermediary API.As a practical example, you can use the extension directly in Builder or Studio to check the status of an order in your company's database and display this information to the customer in real time during the conversational flow. FeaturesThe MongoDB for Blip extension was developed to allow developers to access databases directly through Builder, without the need for an intermediary API.The following features are available: Connection to your own database; Execution of database commands through HTTP requests; Viewing commands executed in the database during the last 30 days; Installation and configurationTo use the MongoDB for Blip extension, you need to access the contract where you want to install it, and then access the Router bot. Once this is done, navigate to the extensions section, where the Blip Store will open, and search for “MongoDB for Blip.” Once you find it, you need to activate and install it.After it has been activated, installed, and the terms have been accepted, a small configuration is required before you can start using it. Follow the step-by-step instructions below.Step 1 - Connecting to the databaseOn the extension's main page, enter name, host, user, and password in the connection form and click "Connect."If the connection is successful, you will quickly see the message "Database connected." If it is unsuccessful, we suggest reviewing the connection details entered in the form. Step 2 - Define the token in the bots' configuration variablesFor your bot to use the extension, the authorization token must be provided when making the request.* This step is not required, but it is suggested to help maintain the Smart Contact.Step 3 - Now you can use it!At this point, the extension is configured and you can start using it. To do so, learn about the concept of commands in the “User guide.” User guideCommandsJust like Blip, communication with the extension through Builder is done using Commands. To do so, follow the instructions below:Basic dataBase URL: https://mongoforblip.blip.sharkdev.com.br/commandsAuthorization token: {{config.token}} or Authentication header (Authorization)How to execute a commandTo execute a command, configure an HTTP Request using the POST method, to the URL provided in Base URL, and provide the Authorization token in the "Authorization" key of the Header. For convenience, see the image below:Now, you need to define the request Body. To do so, the JSON sent must follow the attributes below: Attribute Type Required Description collection string Yes Name of the collection in which the command will be executed.Example: notes command object Yes List of methods to be executed, based on methods from MongoDB's Collection and Cursor.Example: { find: { group: 'example' }, sort: 'name'} apply boolean No Causes array-type methods to be placed as parameters of the method being processed. Default: false Below, we list some examples of the Body of a request. How to insert a document How to find a specific document How to list documents How to update a document How to delete a document How to sort a document list How to execute an aggregate DependenciesFor this extension to work correctly, you need to subscribe to it through the Blip Store by accessing Blip through a paying account. In addition, you need to use your own database. SupportIf you have questions or encounter any problems with the extension, contact us by email at suporte@sharkdev.com.br or by phone at +55 (35) 99148-3887. Need more help? Explore our content on Blip Academy or Blip Community, watch tutorials on our YouTube channel or get answers to your questions through our support channel. Related articles Artificial intelligence engine STILINGUE BLU - Blip Language Understanding How to Publish Your Bot on Microsoft Teams MySQL for Blip Extension How to add Blip Chat to a WordPress site