We’ve been thinking about where we’re going with the way we work in the future, and we found the answer for our time on ChatOps. ChatOps, the Past, Present and Future of ChatOps, is a more detailed introduction I have seen on the platform, so there is no need to repeat it here. While it liberates the tedious work content day after day, it also brings personalized working mode, with unexpected surprises.

Try to picture the future as you can imagine, with neon lights and leD-lit cyberpunk

Maybe there are flying machines that fly between buildings

There may be fully intelligent home appliances

But what is inevitable is a variety of exhaled intelligent assistants. Javis is a good sidekick to the charismatic tech hero in the classic marvel cinematic franchise iron Man. In addition to the ridicule in life

Javis is the right hand in the adrenaline-pumping battle of every mecha.

As prophetic as verne fiction, finding your own Javis is no longer a superhero fantasy these days. Today we introduce how to create a prototype of Javis – Turing robot.

Next, let’s make “Javis” born on Beqia in the shortest time:

The first thing you need to do is create a communication team on Bekah, which is the incubator for JavIS-1-Turing.

Then you need to register with Turing Robot and get the key to call the Turing Robot:

Next we’ll set the Outgoing robot on BearyChat and set the trigger word to the name of the robot you want. Is it really ‘JavIS-1 – Turing’? The name isn’t much simpler than Daenerys Targaryen’s prefix, so I named the robot Niu Meng, which sounds a little more down-to-earth than Javis’s sister Friday. In short, the “@ trigger word” can call the robot to talk at any time.

Considering the new village villagers in Beqia, you just need to follow the picture below, click the button next to the team domain name to find “Robot Management” in the drop-down menu, click into the robot management panel.

Click add Robot in the upper right corner

Outgoing can be found by selecting Custom Robot in the panel that pops up

Next you need to create a bearychat.php file:

<? PHP /** * @author aishan * @date 2015-10-26 * Bearychat: https://bearychat.com/ * Turing Robots: http://www.tuling123.com * Since the outgoing robot of Bearychat is to post specified type data to a certain place, while the Turing robot receives information in get mode, In addition, the data form returned by The Turing robot is somewhat different from the data type returned by the Bearychat robot *, so this file needs to be transferred */ require_once'curl.php'; // add curl$content = file_get_contents("php://input"); // Read the data posted by bearychat$content_arr=json_decode($content); / / a json object$info=urlencode(substr($content_arr->text,11)); // Get the text field in the passed content and intercept the actual content, removing the prefix that triggers the Bearychat robot$key='2d6************************d52'; // Get the key from the Turing robot website$request_url="http://www.tuling123.com/openapi/api?key=".$key."&info=".$info; // Splice Turing robot required request URL$curl=new CURL();
$request=$curl->vget($request_url); // Send the request$request=json_decode($request, 1); // Convert the request into an array. Since the recipes, trains and other queries of The Turing robot will involve returning list data, and Bearychat robot cannot process them by default, the List data returned by the Turing robot will be converted into textif(isset($request['list'])){// If there is a list of data, then the conversion process$list=$request['list'];
    $text=$request['text'].PHP_EOL; // Get the text data and start the concatenationfor($i= 1;$i< = 3;$i++){// There may bea lot of data in the list. In order to prevent bearyChat from returning too much data, only the first three data will be taken at mostif(! isset($list[$i])){
            break;
        }
        $val=$list[$i];
        $list_key=array_keys($val);
        foreach($list_key as $key_val) {if(! in_array($key_val,array('icon'))){// The icon icon cannot be displayed on Bearychat, so it is discarded here$text. =$val[$key_val].PHP_EOL; }}}$request['text'] =$text; // Assign values to the concatenated text dataunset($request['list']); // Discard list data}if(isset($request['url'])){// When the Turing robot is asked "picture of XXX", it returns data in the form of a URL, which is also concatenated to text$text=$request['text'].PHP_EOL.$request['url'];
    $request['text'] =$text;
    unset($request['url']);
}
$request['text']=str_replace('<br>',PHP_EOL,$request['text']); // Finally, the Turing robot will return text data with <br> as a newline, and <br> is not escaped in BearyChat, so the <br> tag will be replaced hereecho json_encode($request);
Copy the code

The curl.php file is included:

<? php class CURL {function vget($url){// Simulate the fetch content function$curl= curl_init(); Curl_setopt ($curl, CURLOPT_URL, $url); Curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0); Curl_setopt ($curl, CURLOPT_SSL_VERIFYHOST, 0); // Check SSL encryption algorithm curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // Use automatic jump curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // Referer curl_setopt($curl, CURLOPT_HTTPGET, 1); // Send a regular Post request curl_setopt($curl, CURLOPT_TIMEOUT, 30); Curl_setopt (curl_setopt());$curl, CURLOPT_HEADER, 0); Curl_setopt (curl_setopt)$curl, CURLOPT_RETURNTRANSFER, 1); // The obtained information is returned as a file stream$tmpInfo = curl_exec($curl); // Perform the operationif (curl_errno($curl)) {
            echo 'Error'.curl_error($curl);
        }
        curl_close($curl); // Close the CURL sessionreturn $tmpInfo; // Return data}}Copy the code

Finally, all you need to do is set up the Turing robot website and your “Javis” will have incubated successfully.

I know, I know, don’t have to guess, you also named your robot Javis, OK, then just say the classic “secret phrase” :

This article references S & J’s blog

Bekah is a strong open platform. We embrace the future of openness and give our users maximum freedom by supporting service docking with open API interface and built-in “Incoming”, “Outgoing” and “Hubot”. Customize the way you work through the custom robot, giving you the freedom to personalize your work while greatly improving efficiency.