ライトニングトーク - とある LINE Bot の開発記「とても腹立たしいことがあったのです」

  • Published on
    05-Apr-2017

  • View
    301

  • Download
    0

Embed Size (px)

Transcript

  • Prologue

  • SNS

  • LINE Bot?

  • LINE Bot!

  • Bot

  • TAR ARS DRIDw

  • Making

  • TypeScript v.2.1+

  • async / await

  • function 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 w

  • Conclusion

  • TypeScript

    async/await 1

    Visual Studio CodeOut-of-Box

    1 ... async/await TypeScript JavaScript(ECMAScript)

    Babel

    2 ... Visual Studio Code Atom Sublime Text

    IDETypeScript

  • Happy 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/3f19cac806dc44c3dd50

    http://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

Recommended

View more >