Echo Dot (3rd Gen) - Smart speaker with Alexa - Charcoal

Use your voice to play a song, artist, or genre through Amazon Music, Apple Music, Spotify, Pandora, and others. With compatible Echo devices in different rooms, you can fill your whole home with music.

Buy Now

Wireless Rechargeable Battery Powered WiFi Camera.

Wireless Rechargeable Battery Powered WiFi Camera is home security camera system lets you listen in and talk back through the built in speaker and microphone that work directly through your iPhone or Android Mic.

Buy Now

Creating your First MSBot using Microsoft Bot Framework #2

0
292


Go to your bot.ts file and create and if/else statement.

Bot.ts file
The only thing you need to do to get your echo bot.

Now let me explain what is happening now

First you need to import ActivityTypes class

The ActivityTypes class contain a list of possible events or actions that an input can be so under the activity type class one of the main and most used actions is Message which is basically most of the inputs a user will send to the bot.

You can read on ActivityTypes here on the Microsoft Docs

Now compile your code when that is done open your emulator and choose your bot, the response should be as shown below

You should have a response like this.

Now we have successfully built the echo-bot all other information after here just explains what happened in the code..

Let me take your through what just happened in your code

When the app started

A request was sent to localhost:3078/api/messages which then detected which the detected the request as an event which then called the myBot.onTurn(context) which is the one that is found in bot.ts, that function in bot.ts classified context which is a fancy term for what you send to the bot be in a request or an event. Context is an object which contains everything you send along with other data such as its type and other meta data

When we get to more advanced cases we will be able to use the text part to call APIs or even start a series of dialog that the bot will have with the user

Well congratulations to everyone who suffered through this chapter in our bot series, in the next article we are going to learn able how to model chats with a nifty library called ChatDown. What ChatDown does is that it enables you make a prototype of what your bot will look like, which is basically one of the most important aspects of building a bot.

You can find the GitHub to this project here…

I hope the echo-bot annoys you enough to do more……..

🀣 Until the next time



Read More

LEAVE A REPLY

Please enter your comment!
Please enter your name here