wingstop

Use Chatbots to Order Pizza Now

Want to order a Pizza?? You no longer need to call or go to restaurant’s website or use their mobile app. So, what is this new way to order Pizza then? Robots, E-mail or Fax? Nooooo!! From now on, use your Facebook or Twitter account. Yes, your food ordering experience now becomes more easy, time saving and smooth. Pizza Hut announced recently ( here ) that soon its customers can order their pizzas on Facebook and Twitter, while the chatbots helps you in the process.

It’s a good news for all foodies but the best part is, chatbots are not restricted to ordering pizza, it brings the potential to accomplish a lot more, some we may not have even imagined so far. You can ask the CNN bot to send you the links to the trending articles, ask a bot for the weather forecast..Bots based on natural language processing has the capacity to learn from each individual interaction with a human being and it only gets better with more and more interactions.

Bots ain’t the thing of future, its here and we see it on rise with likes of Pizza Hut, Whole Foods Market, Dominos, Burger King and Wingstop announcing to make it a part of their day to day operations soon. Bots are already serving as virtual assistant in Travels industry, want to try? Go here: https://taylorbot.com. Also, did I mention bots in Healthcare? Try Healthbot from TigerConnect.

Engineers across the globe are racing to build ‘bots’ or server-side agents that can interact with consumers via the various messaging channels like Slack or may be Applozic very soon.

Today, let me help you understand how you order your pizza via FB messenger or Twitter while bots are acting behind the conversation.

 

wingstop(Source: http://fortune.com/2016/06/07/wingstop-order-facebook-twitter/)

Here’s how you or your potential customers would order Pizza on FB or Twitter,

  • Feel like having pizza? tweet “order” or “#order” to the company’s Twitter handle, @company name
  • Send a direct message to the corporate page on Facebook Messenger to begin the ordering process.
  • In either case, the interaction is then handled via private conversation to complete the order.
  • Once the order is complete, its just usual, you receive your order.

Exciting and time saving? Isn’t it?

Though this still seems to be a niche category but the popularity is magnifying with each passing minute. The social ordering process would grow as the amount of time netizens spend on social media is on a rise with compounding effect. Take a look!

Slide037(Source: http://wearesocial.com/sg/wp-content/uploads/sites/9/2016/01/Slide037.png)

Conversational commerce expands the horizon of social ordering process. Real time chat (intelligent one) will save time and provide a smooth and hassle free experience for customers which in turn will build customer loyalty. Also, with expansion of internet across the globe, the probability of Chatbots tapping on new territories is increasing dramatically.

Check the exhaustive list of Chatbots here: https://www.chatbots.org

You must wondering by now how could you make one yourself, learn to make it in four simple steps.

We believe that chatbots can do great things and its potential is yet to be explored. At Applozic, We have built MQTT based native SDK’s with back-end for real time chat/messaging. You can call it “Feature-as-a-Service”for its simplicity of integration; adding just a few lines of code in your application is enough to get you started with cross platform multi device synced chat. We have started with Bots now so your ideas and suggestions are much appreciated.

 


Screen Shot 2016-08-07 at 3.32.41 PM

How to build bot using hubot?

Overview:

In this tutorial, you’ll learn how to develop bot using Hubot.

What you’ll learn

  • Build a basic chat bot using Hubot.

What you’ll need

  • Node and npm

What is Hubot?

Hubot is your scriptable robot friend. Hubot is open source, written in CoffeeScript on Node.js

You can use Hubot to automate your tasks, deploy website, test your apis and a lot more.

Screen Shot 2016-08-07 at 3.32.41 PM

Getting Started with Hubot

Step 1: Install node

https://docs.npmjs.com/getting-started/installing-node

Step 2: Install Hubot Generator

Open terminal and run the following:

%  npm install -g yo generator-hubot

Step 3: Make a bot called ‘hodor’

% mkdir hodor
% cd hodor
% yo hubot

Now, you will be asked a few questions like who is creating the bot and adapter you want to use.

Ignore adapter part for now, will come to it in our next blog,“Integrate Hubot to your Slack”.

Step 4:Run the functional hubot inside “bin/hubot” folder

% bin/hubot

Press enter

hodor>hodor ping

Hodor will reply with PONG.

Type hodor help to see the list of commands supported.

Now to the “hodor” folder in your system.

You can add your scripts inside “scripts” folder. Read more about coffeescript here.

Open “example.coffee” in editor.

Add the following after ‘module.exports = (robot) ->’

 robot.hear /hi|hello|hey|/i, (res) ->

res.reply ‘hey, whats up’

robot.respond /what is your name/i, (res) ->

res.reply ‘Hodor Hodor Hodor’

Stop and run hubot again by % bin/hubot

In script, if you want hubot to reply to chat which is directed to him, use robot.respond

If you want hubot to reply even if it is not directed to him then use robot.hear

Type any of hi, hello, hey and Hubot will reply with  “hey, whats up”

Type “hodor what is your name” and you will get the reply “Hodor Hodor Hodor”.

Screen Shot 2016-08-07 at 2.53.37 PM

Congrats for building your first bot.

Next we will cover adapters and how to integrate bot with Slack.

Subscribe to our newsletter to learn more about bots.


Easy Way to Manage Parallel and Sequential Tasks in Loop For iOS App Development

‘TaskLoop’ is a category of NSArray that is designed to manage asynchronous tasks in a loop. TaskLoop supports sequential task and parallel task. A Task represents an  asynchronous operation.  

Tracking completion of an asynchronous task is not so easy. It is quite difficult when there are multiple asynchronous tasks running. Worst of all, when all tasks are running parallel.

Let’s understand this by an example:

If you want to download images from an array of URLs with following conditions –

  •  Downloading should not block the main thread.
  •  It should track completion of Each download.
  •  It should track completion of ALL downloads.

First Method – A traditional Way

Create one method that will take imageURL as input and a completion block parameter to track completion of each download.

-(void)getImageFromURL:(NSString*)imageURL withCompletion:(void (^)(UIImage *image))completion{

 //download image and call completion block with image

}

Now, we have an array of URLs to call above method from inside ‘for loop’ like…

-(void)startDownloading{

 //arrURLs : array of NSString image URLs

   for (int i=0; i<arrURLs.count; i++) {

    NSString *strImageURL = [arrURLs objectAtIndex:i];

   [self getImageFromURL:strImageURL withCompletion:^(UIImage *image) {

   //completion block

    }];

}

}

In above code, the ‘completion block’ will call upon download of each image. However, it is not giving completion of all tasks. To achieve that we have to compare a number of images downloaded with the total available images.

-(void)startDownloading{

     //arrURLs : array of NSString image URLs

__block NSMutableArray *arrDownloaded = [NSMutableArray new];

   for (int i=0; i<arrURLs.count; i++) {

    NSString *strImageURL = [arrURLs objectAtIndex:i];

   [self getImageFromURL:strImageURL withCompletion:^(UIImage *image) {

        //completion block

        [arrDownloaded addObject:image];

        if (arrDownloaded.count == arrURLs.count) {

            //all image download completed

        }

    }];

}

}

What if images should download in sequence, i.e. one-by-one? We can call download function again with the next URL inside completion block.

After making changes in coding, it will look like this:

-(void)startDownloading{

   //arrURLs : mutable array of NSString image URLs

   NSString *strImageURL = [arrURLs firstObject];

   [self getImageFromURL:strImageURL withCompletion:^(UIImage *image) {

    //completion block

  [arrURLs removeObjectAtIndex:0];

    if (arrURLs.count) {

        //has

        [self startDownloading];

    }else{

        //all completed

    }

}];

}

After implementing this code, we will get the desired result.

Now, let’s use TaskLoop category of NSArray to solve this problem

TaskLoop has two simple category methods for NSArray

1) enumerateTaskParallely that will execute task parallely and give you completion block for all.

-(void)startDownloading{

   //arrURLs : array of NSString image URLs

[arrURLs enumerateTaskParallely:^(id obj, NSUInteger idx, BlockTaskCompletion completion) {

    [self getImageFromURL:obj withCompletion:^(UIImage *image) {

        //this is important to execute next task

        completion(image);

    }];

} blockCompleteAllTask:^{

    //completion for all

}];

}

2) enumerateTaskSequentially that will execute task sequentially and give you completion block for all.

-(void)startDownloading{

   //arrURLs : array of NSString image URLs

NSArray *arrURLs;

[arrURLs enumerateTaskSequentially:^(id obj, NSUInteger idx, BlockTaskCompletion completion) {

    [self getImageFromURL:obj withCompletion:^(UIImage *image) {

        //this is important to execute next task

        completion(image);

    }];

} blockCompleteAllTask:^{

    //completion for all

}];

}

We have used this category in many of our applications like Tuloko and Besana that allows users to manage tasks in loop. Taskloop help to easily manage async tasks.

If you want more information about Taskloop for iOS or want to download this category with an example then click here.    

 

This is a guest post by Sunil Vaishnav.
Author Bio:

Sunil is Sr. iPhone Developer at Space-O Technologies, trusted iPhone app development company in India. Apart from coding, he loves exploring new programming languages and their abilities. Facebook: https://www.facebook.com/sunil.vaishnav.790