# Integrate MongoDB and Omni-Channel automation with FlowBuilder

In this guide, you will learn how to Integrate MongoDB and omni-channel automation with MessageBird’s FlowBuilder. This tutorial covers a mock account inquiry conversation with inbuilt 2FA between a customer and a loan provider.

&#x20;

<figure><img src="https://675349995-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUJNEE9TMK4fU91VKstBr%2Fuploads%2Fgit-blob-ff3693941373f47cae6889645b98876637faca36%2FSE_TUTS_Mongodb-FLB_20200429.gif?alt=media" alt=""><figcaption></figcaption></figure>

**Account inquiries on WhatsApp**

We’ll learn how to authenticate customers via 2FA and allow secure account access via QR codes that initiate a WhatsApp chat, which can help reduce agent overhead and increase customer retention.

&#x20;

**Why MongoDB?**&#x20;

**Always-On Availability**

Replication of data in MongoDB is first-class—groups of MongoDB nodes that hold the same data set are called replica sets. Replica sets enable high availability of data and developers able to fine-tune their consistency requirements for even greater performance and availability.

**Faster Development with JSON Documents**

Working with data as flexible JSON documents, rather than as rigid rows and columns, is proven to help developers move faster. Teams who have been able to accelerate development cycles by 3-5x after moving to MongoDB from relational databases.

**Scale Infinitely and Cheaply**

MongoDB includes native support in the database for sharing data across multiple nodes.

&#x20;

**Requirements**

* [MessageBird account](https://dashboard.messagebird.com/en/sign-up)
* [WhatsApp for Business account](https://www.messagebird.com/whatsapp/)
* [MongoDB account](https://www.mongodb.com/download-center)

&#x20;

**Step 1: Sign up for MongoDB**

Make sure to sign up for a [MessageBird account](https://dashboard.messagebird.com/en/sign-up) and a [WhatsApp for Business account](https://www.messagebird.com/whatsapp/). Done? Awesome! Time to [sign up for MongoDB.](https://www.mongodb.com/download-center)&#x20;

1\. Complete the [get started with MongoDB Atlas](https://docs.atlas.mongodb.com/getting-started/) steps

2 - Return to [**Clusters**](https://docs.atlas.mongodb.com/tutorial/view-all-clusters/#id1) homepage and click **Collections**

3\. Create a sample **Database,** then a sample **Collection**, and insert the following document replacing all ‘**your-...**’ fields with your own details:

&#x20;{"\_id":{"$oid":"5eb3685493a05b7859d3a1fb"},"balance":"**your-balance**","name":"**your-name**","email":"**your-email-address**","phone":"**your-personal-whatsapp-number**"}

&#x20;

**Step 2: Create a Stitch app**&#x20;

To enable webhook connectivity, we’ll set up a Stitch app by following these steps:

1\. [**Create a stitch app**](https://docs.mongodb.com/stitch/procedures/create-stitch-app/)

2\. [**Create 3 x incoming webhooks**](https://docs.mongodb.com/stitch/services/create-a-service-webhook/)

During **initial** webhook setup:

* **Name** your webhook according to function(Insert, Search, Delete)
* **Authentication** can be set to **System** for this demo
* All HTTP **methods** are **POST**
* Set respond with the result to **ON**
* Request validation **No additional authorization**
* Content for each webhook function is provided in the links below:
* * [Insert](https://drive.google.com/open?id=1D2a3Z7kqbDsWkxuh5CYyYYpkQJTJWEOm)
  * [Search](https://drive.google.com/open?id=1JuDpWSngoQ0qHQ7sfmGNTW6ISGsVswSl)
  * [Delete](https://drive.google.com/open?id=1--bcE8GgyquOcPfQqkQDIfdtCez4U6JY)
* Before copying across, please change the following lines inside each file and point to your own Database and Collection:
* * const mycollection = mongodb.db("**your-db**").collection("**your-collection**");
* And that’s it! Now copy and paste into the **Function Editor** accordingly.
* **Record** URLs of webhooks for later use.

&#x20;

**Step 3: Connect it all in the MessageBird Dashboard**

1\. Log in to your [MessageBird Dashboard](https://dashboard.messagebird.com/en/login) and go to [Flow Builder](https://dashboard.messagebird.com/en/flow-builder).

2\. Import the [sample flow](https://drive.google.com/open?id=1b_XGJ_yYcxohcpKRX0fZQ6X28cCHj0cJ).

3\. Select **WhatsApp** as the trigger of your flow.

4\. Look for step ‘**MDB\_search’** and replace URL with the newly created **Search webhook** from the Stitch app.

5\. If you are looking to provide voice 2FA, simply [purchase a MessageBird Number](https://dashboard.messagebird.com/en/numbers). If this is not the case, please remove the **phone verification branch** from your flow.&#x20;

6\. Publish your flow in the top-right corner of your screen, and you're good to go!

7\. Done! Initiate a conversation with your channel to try the flow.&#x20;

Remember, the first step of the flow is an **HTTP Fetch** step which is querying the database and attempting to retrieve details of the user via their phone number. Make sure the personal details (phone number, email and name) of the person using the flow exist in your database.

&#x20;

And that’s it! 🎉 Now you know how to integrate MongoDB and omni-channel automation with FlowBuilder.

&#x20;

&#x20;
