Azure Cosmos DB Emulator

Alexander Chernov
A free video tutorial from Alexander Chernov
Conversational Commerce Consultant
4.0 instructor rating • 1 course • 1,152 students

Learn more from the full course

E-Commerce Shopping Bot

Welcome to the world of conversational commerce

10:27:02 of on-demand video • Updated February 2018

  • Build Facebook Messenger Bot
  • Build Slack Bot
  • Use Wit ai
  • Authenticate with Passport using Facebook Twitter and Google
  • Pay with Stripe and PayPal
  • Understand async/await
  • Understand testing
  • Understand debugging
  • Upload with Multer
  • Build pagination
  • Deal with errors
  • Use EJS templating language
  • Use Git with SSH keys
  • Use Eslint
  • Use Ngrok
  • Use Winston and Morgan
  • Use Helmet
English Hi let's create a folder in the desktop directory and drag it to the working area of the editor. in this lesson I gonna show you how to connect the chatbot to the azure cosmos database locally using emulator. may be I will make a course about Microsoft bot framework in the future first step is to create local git repository and package json file OK next is the app dot js file in the root directory I want my code to work in the restricted variant of javascript. Use strict. Let's open Microsoft Bot framework documentation. Select node is then copy. The following npm command to install bot builder sdk for node js then install restify framework to set up a server Whoops. Please don't pay attention to these errors we have no time to meddle with Python and node gyp here. To speed up the process. Let's copy part of the snippet and paste it to the app js file Change var to const this percent. s is a C++ sprint F like syntax s is a string and D is a number we don't need credentials locally. Click on how to link then develop link then node js link then messages link. Then add rich cards to messages link Let's send a carousel of hero cards to a customer. Copy this snippet and paste it to the app js file. Also we need to manage state data of our conversations. We will use in-memory data storage for testing. Lets create a new instance of the in memory storage. Change to const and register in memory storage. Copy and paste it as I did. OK we will use common way to connect to the mongodb database with mongoose Also we will use find or create plugin for mongoose to find or create collections in the database But it's not a must I use semi-colons here because the code is from the documentation but in my projects I prefer not to music and schema with two properties. Name all the customer and the array with selected. products Well here is a trick we will replace MongoDB with cosmos db from Microsoft azure Select node js click on Cosmos db link then tutorial link then develop locally link then use the emulator link you can download the emulator using Microsoft download center or you can use docker copy this connection string And paste it inside the quotes Lets run azure cosmos db Emulator Data explorer will open in your browser It's too bright That’s better Lets install packages start the server We have unhandled promise rejection password contains an illegal unescaped character let's replace slash Plus the equal signs. Honestly speaking I don't remember ASCII codes myself. Let's take a look. refresh I forgot number two. Refresh all as expected. Lets create the public folder in the project directory and place three images with t –shirts in it let's add one more item to the carousel. Type in the way to the public folder We need temp variable to add number of the customer to the data base we will simply increment this variable Check out the cosmos db database The database is empty. Let's open Microsoft bot framework emulator connect to the API slash messages route and type in hi The bot sent us the message The bot will show the products if our request will match these two words in regular expression and list type in show We have the carousel with products Lets check out the database We have users collection with one document in it Name one and empty array Type in hi one more time And the bot will start new conversation with the new customer check out the database. Second document name 2 and empty array Let's delete this collection and start new conversation to handle button input. we have to copy this snippet and pasted to the app js file. Let's change colors to white red and black. And last thing to do is to save chosen product in the database music refresh database is empty. Let's check it out. That is it. Thanks for watching.