prackky-blog
prackky-blog
Prakhar
5 posts
Don't wanna be here? Send us removal request.
prackky-blog · 8 years ago
Text
Hello Sailors, chatbot has been the buzz-word these days, many businesses are looking to implement chatbots to their sites or facebook pages to convert traffic into customers. Today in this tutorial, we are going to create a simple conversational facebook chatbot which can send you jokes, images and also it can do a small talk.
Messenger bots simply blend artificial intelligence with human interaction. User asks a question and chatbot gives relevant answer to serve the purpose.
What do we need to build our facebook chatbot?
API.AI account – A natural language understanding platform to design and integrate intelligent sophisticated conversational user interfaces.
Facebook for developers account – To create a facebook app.
Facebook page – Chatbot feature is only available to pages, not personal accounts.
What we are going to do
We are going to subscribe our API.AI agent to read all messages we receive on our Facebook page and in turn our agent processes the message and responds the way we have trained it.
Steps to setup API.AI and Facebook Messenger
Create a facebook page, I have named it TestBot.
Make facebook app with your facebook developers account.
Set up your API.AI account and create a new agent.
Create a new API.AI agent
Next, we will add product(Messenger and Webhooks) to our Facebook app. Click on Add Product button and then click on Set Up in both Messenger and Webhooks boxes.Once both Messenger and Webhooks are added, you will see them added under PRODUCTS tab.
Products added
Now, under PRODUCTS tab click on messenger and under Token Generation tab select your page to get the token.
Facebook token generation
Open the Integrations tab in API.AI and Turn ON the Messenger integration. Click on Settings, paste the facebook access token copied in above step, write the unique VERIFY TOKEN and hit START.  Also copy the callback URL.
API facebook integration
In Facebook developers page click on Messenger tab then select Setup Webhooks and paste your Callback URL and the Verify token from API.AI page. Click Verify and Save.
facebook webhook setup
Also, make sure that your facebook webhook is subscribed to your page events:
subscribe to page events
Now, API.AI and page messenger are connected which means we can now process messages received on our page and respond accordingly.
Setup responses in API.AI
We are already provided with 2 default intents. The Default Welcome intent replies to greeting messages and the Default Fallback intent replies if bot doesn’t understands something. That’s a good starting point.
Before we start, let’s understand 2 important things: Intents and Entities
Intent: We classify user’s queries as intents which means how a user is going to ask something from the bot. Example: send me some cool jokes
Entity: This is what we are looking from user as a value, let’s say “send me 3 jokes”, here we can consider 3 as a number entity and jokes as category entity(not required though). Then we process this on our webhook and send the response. Don’t worry if you are not getting this, we are going to work only with intents right now.
Let’s create some intents:
Create a joke intent. Add a few queries, the way user can ask for a joke i.e. send me a joke, or simply joke.
create joke intent
Now, come down the screen and add a response to this query, a joke. For this, we need to add a FACEBOOK MESSENGER response by clicking the + button next to Default Response and then add the Text Message.
facebook response
Same way we are going to create an image intent, add a user query and submit the response as image, so that the image is displayed for the query. #gallery-0-5 { margin: auto; } #gallery-0-5 .gallery-item { float: left; margin-top: 10px; text-align: center; width: 50%; } #gallery-0-5 img { border: 2px solid #cfcfcf; } #gallery-0-5 .gallery-caption { margin-left: 0; } /* see gallery_shortcode() in wp-includes/media.php */
Image search intent
Image reponse
This way we can add as many intents we want and facebook chatbot will respond accordingly.
These are only static responses, for dynamic responses we need to create a webhook which is not covered in this tutorial.
Final Check:
Facebook webhook setup subscribed to TestBot page.  Check
API.AI connected to Facebook page. Check
Intents created. Check
That’s it. Time to check the response on facebook messenger.
Final bot response on messenger
Wow, we have made our first simple chatbot which sends joke and a capuchin pic on demand. Now, go ahead and try to use this to create awesome chatbots.
Chatbot responses shall only work for page admins/moderators not for public until they are verified by facebook.
Additionally, we can also give some small talk sense to our chatbot by importing the smalltalk pre-built agent from the Pre-Built agent tab. Oh yeah!
If you have any queries/suggestions write below in the comments or send me a mail at [email protected]. See you in the next tutorial!
  Build a facebook chatbot with API.AI (zero coding) Hello Sailors, chatbot has been the buzz-word these days, many businesses are looking to implement chatbots to their sites or facebook pages to convert traffic into customers.
0 notes
prackky-blog · 8 years ago
Text
Automate irrigation system over internet
Automate irrigation system over internet #IOT #AutomateIrrigation #Blynk
Hello Sailors! We are back with one more awesome IOT project where we are going to automate irrigation system. The system can be used in homes to water the plants any time and can also be scheduled so even if you forget to water plants (lazy like me), just schedule the device and your plants get water regularly. That’s another great use of IOT, aah!
Overview
We are going to control an AC water…
View On WordPress
0 notes
prackky-blog · 8 years ago
Text
Setup Mosquitto MQTT broker in Windows
Setup Mosquitto MQTT broker in Windows #MQTT #IoTBasics
What is MQTT?
MQTT(Message Queueing Telemetry Transport) is a Client Server messaging transport protocol. It provides a lightweight method of carrying messages using a publish/subscribe model. The pub/sub model being lighweight makes it suitable for IOT messaging with low power devices, sensors, phones or microcontrollers.
How MQTT works?
MQTT follows publish/subscribe model which is alternative…
View On WordPress
0 notes
prackky-blog · 8 years ago
Text
Most of the times when we go out of home for some days, we think of having some device that could switch ON/OFF (let’s say) Refrigerator (or any other important appliance)for some hours during the day.
Today, we are going to make such time scheduled electric switch which switches ON/OFF at times which we set the in our Blynk app. Woah!
Let’s begin!
Things we need:
Tumblr media
Components
Hardware:
5V relay
NodeMCU
Jumper wires
Breadboard
3V3 and 5V power source
Electrical Wires
Software:
Arduino IDE
BLYNK app
It’s circuit is same as we have created for our Smart Switch. So, if you already have that circuit set up, go ahead with Blynk app set up and Start playing.
Circuit:
Tumblr media
Smart switch circuit
Connections:
D5 pin of NodeMCU connects to IN1 pin of 5V relay.
3V3 of NodeMCU connects to 3V3 powers source and GND to GND.
Vcc of relay connects to 5V source and GND to GND.
Live wire is connected directly to appliance.
Neutral wire from source comes to relay NC pin and another wire goes out from COM pin which is connected to the appliance.
Let’s set up the Blynk app:
Create a New Project in BLYNK app.
Write Project Name and Select NodeMCU from dropdown and WiFi as connection type.
An AUTH token will be sent to your registered email, note this down.
Tap on the screen and add the Eventor widget to the screen.
Tap on the Eventor widget and click Add New Event.
Select Time button and choose DAYS OF THE WEEK and START AT time and TIME ZONE. SET THE TIME, then tap OK.
Now, select turn ON pin and add D5 pin as we have connected our relay to PIN D5. Tap OK to finalize your Start Event.
Same way create a new event and select START time that will Switch OFF the relay at PIN D5.
#gallery-0-5 { margin: auto; } #gallery-0-5 .gallery-item { float: left; margin-top: 10px; text-align: center; width: 33%; } #gallery-0-5 img { border: 2px solid #cfcfcf; } #gallery-0-5 .gallery-caption { margin-left: 0; } /* see gallery_shortcode() in wp-includes/media.php */
Tumblr media
Tap Eventor
Tumblr media
Add New Event
Tumblr media
Tap on time
Tumblr media
Select pin and notification
Tumblr media
Time pin and notification to turn off
Tumblr media
Events added
We have completed the circuit and set up our BLYNK. Let’s do some coding.
Code:
#define BLYNK_PRINT Serial #include <ESP8266WiFi.h> #include <BlynkSimpleEsp8266.h> // You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = "YOUR_AUTH_ID"; // Your WiFi credentials. // Set password to "" for open networks. char ssid[] = "WIFI_SSID"; char pass[] = "WIFI_PASSWORD"; void setup() { // Debug console Serial.begin(115200); Blynk.begin(auth, ssid, pass); // You can also specify server: //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442); //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442); } void loop() { Blynk.run(); // You can inject your own code or combine it with other sketches. // Check other examples on how to communicate with Blynk. Remember // to avoid delay() function! }
Make sure to change the AUTH_KEY, SSID and PASSWORD before uploading the code to NodeMCU.
Upload and Play: Connect NodeMCU using the MicroUSB cable and upload the code using Arduino IDE.
Once uploaded, click Play button on the BLYNK app and we can now close the app. The app will do rest.
Tumblr media
Upload and Play.
And yes, the button we added in our previous (Smart Switch Project) still works like a charm. So, scheduled or manual, everything is awesome!
Oh yeah!
We can now schedule our appliances to turn ON/OFF when ever we want. That’s what we call some good use of technology.
Suggestions and comments are always welcome. Feel Free!
Keep breaking, keep making!
Schedule turning ON/OFF of your home appliances with Blynk and ESP8266. #homeAutomation #IOT  
0 notes
prackky-blog · 8 years ago
Text
Yo… yo… yo… Shippers! It’s been quite a few days that we have not built anything awesome. Come let’s gather up the stuff and get ready to roll.
Today, it’s time for smart switch which we are going to control over internet using our very precious BLYNK app. Cool!
Overview:
The 5V relay connected to D5 pin of NodeMCU goes ON when D5 pin is set LOW and relay goes OFF when D5 pin is set HIGH.
We are simply going to set D5 pin HIGH to turn ON the appliance and D5 as LOW to turn OFF the appliance, considering the neutral wire is passing through the NC and COM of the relay.
Stuff required:
Hardware:
5V relay
NodeMCU
Jumper wires
Breadboard
3V3 and 5V power source
Electrical Wires
Software:
Arduino IDE
BLYNK app
Circuit:
Smart switch circuit
Connections:
D5 pin of NodeMCU connects to IN1 pin of 5V relay.
3V3 of NodeMCU connects to 3V3 powers source and GND to GND.
Vcc of relay connects to 5V source and GND to GND.
Live wire is connected directly to appliance.
Neutral wire from source comes to relay NC pin and another wire goes out from COM pin which is connected to the appliance.
Technically, we are connecting our switch on the neutral wire of the appliance, which is turning ON/OFF the appliance. Simple!
Let’s set up our BLYNK app:
Create a New Project in BLYNK app.
Write Project Name and Select NodeMCU from dropdown.
An AUTH token will be sent to your registered email, note this down.
Tap on the screen and add a Button.
Tap on the Widget and select D5 pin, then change MODE to SWITCH. #gallery-0-8 { margin: auto; } #gallery-0-8 .gallery-item { float: left; margin-top: 10px; text-align: center; width: 33%; } #gallery-0-8 img { border: 2px solid #cfcfcf; } #gallery-0-8 .gallery-caption { margin-left: 0; } /* see gallery_shortcode() in wp-includes/media.php */
Create Project
Select NodeMCU adn WiFi
Add Button widget
Play the BLYNK button
Select PIN D5 and MODE as SWITCH
Auth Token
We have completed the circuit and set up our BLYNK. Let’s do some coding.
Code:
#define BLYNK_PRINT Serial #include <ESP8266WiFi.h> #include <BlynkSimpleEsp8266.h> // You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = "YOUR_AUTH_ID"; // Your WiFi credentials. // Set password to "" for open networks. char ssid[] = "WIFI_SSID"; char pass[] = "WIFI_PASSWORD"; void setup() { // Debug console Serial.begin(115200); Blynk.begin(auth, ssid, pass); // You can also specify server: //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442); //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442); } void loop() { Blynk.run(); // You can inject your own code or combine it with other sketches. // Check other examples on how to communicate with Blynk. Remember // to avoid delay() function! }
Make sure to change the AUTH_KEY, SSID and PASSWORD before uploading the code to NodeMCU.
Upload and Play: Connect NodeMCU using the MicroUSB cable and upload the code using Arduino IDE.
Once uploaded, click Play button on the BLYNK app and start turning ON/OFF your devices from anywhere in the world.
Play the BLYNK button
Oh Yeah!
That’s it for now, Shippers. See you in the next awesome IOT project.
Keep breaking, keep making!
Control switch over internet with BLYNK Yo... yo... yo... Shippers! It's been quite a few days that we have not built anything awesome.
0 notes