- LINE Bot

Download -  LINE Bot

Post on 05-Apr-2017

289 views

Category:

Technology

0 download

TRANSCRIPT

PrologueSNSLINE Bot?LINE Bot!Bot TAR ARS DRIDwMakingTypeScript v.2.1+async / awaitfunction foo() {fizz().then(res1 => {buzz(res1);}).then(res2 => {fizzBuzz(res2);}) }function async foo() {fizz().then(res1 => {buzz(res1);}).then(res2 => {fizzBuzz(res2);}) }function async foo() {let res1 = await fizz();.then(res1 => {buzz(res1);}).then(res2 => {fizzBuzz(res2);}) }function async foo() {let res1 = await fizz();buzz(res1).then(res2 => {fizzBuzz(res2);}) }function async foo() {let res1 = await fizz();let res2 = await buzz(res1);.then(res2 => {fizzBuzz(res2);}) }function async foo() {let res1 = await fizz();let res2 = await buzz(res1);fizzBuzz(res2);}app.post('/webhook', (req, res) => {...let gotIntent = new Promise((resolve, reject) => {aiRequest.on('response', response => resolve(response));aiRequest.end();}) as any;let main = gotIntent.then(aiResponse => {// if (aiResponse.result.action == 'recommendation') {dietitian.dietitian.replyRecommendation(event.replyToken);main.Cancel();// }else {// // return mecab.parse(event.message.text);}}).then(res => {let gotAllNutrition = res.filter(r => r[1] == '').map(r => foodsDb.getNutrition(r[0]));return Promise.all(gotAllNutrition);}).then(responseList => {// ......})app.post('/webhook', (req, res) => {...let gotIntent = new Promise((resolve, reject) => {aiRequest.on('response', response => resolve(response));aiRequest.end();}) as any;let main = gotIntent.then(aiResponse => {// if (aiResponse.result.action == 'recommendation') {dietitian.dietitian.replyRecommendation(event.replyToken);main.Cancel();// }else {// // return mecab.parse(event.message.text);}}).then(res => {let gotAllNutrition = res.filter(r => r[1] == '').map(r => foodsDb.getNutrition(r[0]));return Promise.all(gotAllNutrition);}).then(responseList => {// ......})app.post('/webhook', async (req, res) => {...let aiResponse: any = await new Promise((resolve, reject)aiRequest.on('response', response => resolve(response));aiRequest.end();});// if (aiResponse.result.action == 'recommendation') {dietitian.dietitian.replyRecommendation(event.replyTokenreturn; // }// // let res = await mecab.parse(event.message.text);let gotAllNutrition = res.filter(r => r[1] == '').map(r => foodsDb.getNutrition(r[0]));let responseList = await Promise.all(gotAllNutrition);... return Bluebird wConclusionTypeScript async/await 1 Visual Studio CodeOut-of-Box1 ... async/await TypeScript JavaScript(ECMAScript) Babel 2 ... Visual Studio Code Atom Sublime Text IDETypeScriptHappy Coding :)Learn, Practice, Share. AIBot Part1 http://qiita.com/nkjm/items/0e9d24b2f3429bd33c8d Part2 LINEhttp://qiita.com/nkjm/items/daa4e34b26ef937446c6 Part3 Bothttp://qiita.com/nkjm/items/27d0131003a4b7ef02b9 Part4 http://qiita.com/nkjm/items/d46bd91e1784adf1434b Part5 Bothttp://qiita.com/nkjm/items/fe2db6b8c4ee2980e2b4 Oracle Cloud Developers Meetup@ - AIBot VSCode TypeScript http://qiita.com/jsakamoto/items/3f19cac806dc44c3dd50http://qiita.com/nkjm/items/0e9d24b2f3429bd33c8dhttp://qiita.com/nkjm/items/daa4e34b26ef937446c6http://qiita.com/nkjm/items/27d0131003a4b7ef02b9http://qiita.com/nkjm/items/d46bd91e1784adf1434bhttp://qiita.com/nkjm/items/fe2db6b8c4ee2980e2b4http://qiita.com/jsakamoto/items/3f19cac806dc44c3dd50