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.

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.

Why MongoDB?

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.

Requirements

Step 1: Sign up for MongoDB

Make sure to sign up for a MessageBird account and a WhatsApp for Business account. Done? Awesome! Time to sign up for MongoDB.

1. Complete the get started with MongoDB Atlas steps

2 - Return to Clusters 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:

{"_id":{"$oid":"5eb3685493a05b7859d3a1fb"},"balance":"your-balance","name":"your-name","email":"your-email-address","phone":"your-personal-whatsapp-number"}

Step 2: Create a Stitch app

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

1. Create a stitch app

2. Create 3 x incoming webhooks

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:

  • 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.

Step 3: Connect it all in the MessageBird Dashboard

1. Log in to your MessageBird Dashboard and go to Flow Builder.

2. Import the sample flow.

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. If this is not the case, please remove the phone verification branch from your flow.

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.

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.

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

Last updated