Upgrade to Pro — share decks privately, control downloads, hide ads and more …

kintone & Backlogハンズオン / kintone devCamp 2018 h...

kintone & Backlogハンズオン / kintone devCamp 2018 handson

2018年8月2日の「kintone devCamp 2018」にて、Backlog SREの吉澤(@muziyoshiz)が、kintoneとBacklogの連携方法をハンズオン形式で解説しました。
前半はkintoneプラグインを用いたノンプログラミングでの連携、後半はwebhookとAWS Lambdaを用いた高度なAPI連携の解説です。

kintone devCamp 2018
https://developer.cybozu.io/hc/ja/articles/360001062323-kintone-devCamp-2018

サンプルコード
https://github.com/nulab/backlog-kintone-handson

株式会社ヌーラボ

August 02, 2018
Tweet

More Decks by 株式会社ヌーラボ

Other Decks in Programming

Transcript

  1. &( 1 @ /B8  • A L F L

    • 8 @ gNm : 2:@ @ -B B::E 2- • & iNnl • r cNjds v w y zekh a t • Rcp T S F) 8 @ 8 A : • 0 A :EI:E@:FF .E A: E s • u u ! : @ lp o b WT 
  2. .  • 82 • 82 8 1 • 82

    FI N S • PL W • .0 8 1 1 • PL N S AB 
  3. 0   • T 8 N   

     • 8 N . 1 8 • 11 B I8 • 2 . C I8 
  4. 0 1 2 !'%"  !'*2& +   /0

    .,&1  #$( -)+  74 $PQZSJHIU/VMBC*OD"MMSJHIUTSFTFSWFE . 1 2
  5. 0      • N8 . 1

    k B g aI • ib I • n c I8 W . 2 • a G • l G N l I 
  6.   • • . 4I 8 2 • 4

    8 2 0 N 1 • 8 2  ະରԠ ॲཧத ॲཧࡁΈ ׬ྃ
  7.    •    . 02 1

     λεΫ؅ཧ • λεΫͷ؅ཧ͕Ͱ͖Δ͔ʁ • λεΫ͔ΒࣗಈతʹΨϯτ νϟʔτ͕࡞੒Ͱ͖Δ͔ʁ จॻ؅ཧ • จॻΛΦϯϥΠϯ্Ͱ࡞੒ͯ͠ ڞ༗Ͱ͖Δ͔ʁ ϑΝΠϧ؅ཧ • ϑΝΠϧΛڞ༗Ͱ͖Δ͔ʁ • 8FC%"7Λ࢖ͬͯ1$͔Β௚ ઀ϑΝΠϧʹΞΫηεͰ͖Δ ͔ʁ ιʔείʔυ؅ཧ • (JUͰιʔείʔυ͕؅ཧͰ͖Δ ͔ʁ • 4VCWFSTJPOͰιʔείʔυ͕ ؅ཧͰ͖Δ͔ʁ ϞόΠϧରԠ • ެࣜͷϞόΠϧΞϓϦ͕ఏڙ͞ Ε͍ͯΔ͔ʁ ηΩϡϦςΟ • άϩʔόϧ*1ΞυϨεʹΑΔ αʔϏε΁ͷΞΫηε੍ݶ౳ͷ ઃఆ͕Ͱ͖Δ͔ʁ • ΞΫηεϩάͷఏڙαʔϏε͕ ͋Δ͔ʁ ֦ுੑ • "1*͕ఏڙ͞Ε͍ͯΔ͔ʁ • ৘ใͷߋ৽࣌ʹ֎෦γεςϜʹ ௨஌͢Δ࢓૊Έ 8FCIPPLͳͲ ͕ఏڙ͞Ε͍ͯΔ͔ʁ • ֎෦γεςϜͳͲ͔Βϝʔϧܦ ༝ͰλεΫΛ࡞੒Ͱ͖Δ͔ʁ
  8.   • 1 . . 20 . 8 

    $* *!'" *"!'" .O0<A[%)"LN6/,W\K .OP-VB  >SRGF (5? *)#CY &("* ;:3]E+ ZMJXQJ@HJ T= 9D4827 1[  ,W U .O&("*IQ  >SRGF  ཧ૝ઢ ࣮੷ઢ ܭըઢ
  9. 1 0. I NA k   • 2 W

    • i I 8 c • B I  ab l W c W I NA k
  10.  • l . N  0 • a I

    8 uc8     • n 2 . b • 1 IN • N .
  11.   • . 8. . 20 3 • 3

    . 1  ,0 ࡾҪॅ༑ۜߦ
  12. 0 1       02 •

    N • N a . . I B • Nc B N b i 8 NWge .1 21 • NU • l N • Bno 8 • k B k W
  13. 2.      • b .0 c

    i u 10 g • 10 u • 10 l • 10 u .0 tko • ne u N • 10 a .0 I B i 8 
  14.  • BI 20 : BI • N 2 .

     /:: 1 / 2 1 8 0 8: / /:
  15. 812      • abO SO 1

    8 T U n Ne T • 1 8 • 1 8 0 2 AB Hg O RuIU T • P o • 0 2 • O c kt LOW Bh N Bl N O U T .. .A
  16. C -. / • N e • .-/ :2 /:8

    - . :2 - .-/ :2 /- 1 0B • -/ :2GI NapH .iIdc -/ :2Hgo • jI m hm I - : Hlk  .I n -/ :2 Idc br
  17. -. 8/ • -8 -8ckbl • : .-/ 2 /

    - . 2 -8 -8 1-/0. : -/0 .-/ 2 • lr W me I : -/0 . -/0. ut • W N -/ 2 g  :-/0 W B s h pf -/ 2 W S an j owF
  18. . 80  • c v s N L •

    c v s . 2 bmZ F 8 2 . • uot rpu WIA • IA kud u PLW • Leni Z LW • a l NW • Sorgin LW • 8 82 kud u • , . 1. S 80 8 . . 2 02 kud u 
  19. /E 3 .  a 2: -:a Wi 0 B

    ow s m da. e c k 1 BF B CC -B3 B C Cu : D W W bI n a j c n a bI P i WShc 3 8 l I pt W l iN ar n W W bI avn g © a j c DDAC 3 8 3 AB: : 8 21 : :CDB3D B CC W W bI lro a j c 
  20. . 0    B . ! B 2

    1 . ! ( (1 3 3 . 8 (002 I A 2 2 2 ) . 2 8 4 F 
  21. % 3E 45 2 6 • k D 8aog hn

    • 8 8 8B 8DG B N 1 9 8d • aog leij :DD -## 8 8 8B 6 5 IE #:6# 4#4BD 6 8 # 8 8 8B 8DG B 0 % . 0 0 % 0 % 0 % / D8 • p D 8bc p 
  22. 1 0 • e c • . • . ab

    • e 8 2 . N I . e ab 
  23. 1 0. • S S I • 0. DH •

    S I • b A S I b • D 8A S I c • 28A HNO a 
  24. : 2 )    • /88 7( 12

    .  a b 12 . 0 N 12 .8 2 N 12 . c I
  25. -.    • D B A • D

    B A H - 2 1 - 08   • D B A    
  26. 2.      • B e8 c

    N • eBa I 10 • BI .0  I I e g i g k b g
  27. . 0  • 8 2 DN A .0 8

    N B a • .0 8 a N H B  ). 1 O DN O ) ( N SI  .0 8 a N H
  28. 0 81   ) 82 8H H S A

    H H ) (. O I 1 BP a 8 8 H H b 8 8 A c 1 O I d D e 8 8 BP BPHI N 8 8 BP
  29. 8 0 1 . • 1 1 .1 21-I I

     O HN H HN H
  30. . - .  4 1 20 8 2 8

    8    
  31. D B 12 * .  ( ) ( *

    ( * i i . B 2 n e B28 n t rk ) U C g I I I d I U sy 1 B g I a Ip Ip jR Ic d I a n 1 b 0. 1 * B 0. luo luo ( 1 C P Pm NS LLP
  32. -. . • NO N I DS ABN I H

    • N I - 2 1 - 08   • N I    
  33. 2. . • .0 b g • N u o

    elc 10 • it 8B elc a k B nI 
  34. . 4 . .    )4 8 S

    L 4 8 )4 8 (0 U H )4 8 (0 U )4 8 c U (. 2 . )4 8 c c U OIm DPO R b nl R b nl )4 8 a R b )4 8 1- u R b u B o gLk ALNNI O
  35. 8 3 4.  214 54 b N .2350 a

    G .2350 I I e 1 121 B .2350 W 214 54 c WGg I B 
  36. 81 ,  • t k g p • t

    k g . 2 • ic i r n uo • AN i i l • p Zb P t • t a • m Ic b e • 0 i i • 2 
  37. A # 812 3 ( ) 0 ,1 2 1

    • G I cC,1 2 1 I a • G WPJ bC I I S • . 1 1 LN  ,1 2 1 .
  38. 2 ( ) 8 • a c A WbGa P

    I • hWb L N d e A • .  . 0 1 .
  39. 1 • I b I L N • 2 .

    8 • 0 S F 2 . 2 . N a I 
  40. .C 23 • 10 el z s • b a

    gIM S& 2 n no cl g • vy • 2G 2 2 • N 10 ia 10 - C 12 L • gs 2A C C 2A L • d af p I8 P h mrw t • pu vy • p ,2 3 2 2 2 W A AA ln rL 
  41. 2.    10 N8 .0 B B I

    B N8 34 (4 )) 33 A ! . 33 ( 3.3 ! 
  42. 1 0. • N • N • Sb aN •

    u • • SW A • D I DA 2 Nl • Sb a • SW 2 c n M AI • I D SW 82 c I D Sb SW 8 
  43. .     • 20 2 81 

           
  44. L 0F 5 6 4 . • 0A78 h aM

    • 28 8 8 8 A h aM • /eM MW g h d wy • h aM sWonp • 385:AA Wru mk zvW 1 P . 57 jv 0A78 t SN WS Wbc il : F IA : : 8 5 A9 6A 8 I 
  45. . / . • 3 801 8:2 S 08 1:I

    L W • N I • T 
  46. :2 . • . . a I HN H _

    • / 8 . 8/ 0 . 1 • H  $ brew install npm
  47. 80 2 • .2 • .2 NS 11 2 1

    a O O W I • 1 • W I  $ npm install –g serverless
  48. .     • • I2 0 1

    8 N  $ sls config credentials --provider aws --key ID --secret   
  49. 2.      • B e8 c

    N • eBa I 10 • BI .0  I I e g i g k b g
  50. 2.    • 10 .0 8 • .0

    10 8  B   N I
  51. 801 2 0 dB . O DH N I 

     A c gN Ia kRb 02 8 0 1 0 U h 1 0 1 0 U a l Se m 1 n o LPH
  52. . 0 . 1 IP I Wb AO IP I

    O HD L   . 1. . 1. hN S d L e k I a c m . 1. O l e n 2 88 d o 2 88 d
  53. C 01 ) 2 • abNny c PD  

       m SR • LPD Luy c UI m          d j d j 2 1 o i . 1 2 o si k ( 2 e a B e a r . 0 o i 028 g 028 ) ltp ltp 0 B
  54. 1 • 2 N 0 .. 8 I  {

    "id": "ef84c2fb-63d5-4a14-9ebf-c301fbdec1e7", "type": "ADD_RECORD", "app": { "id": "13", "name": " " }, "record": { "Status": { "type": "DROP_DOWN", "value": " " }, "RecordNumber": { "type": "RECORD_NUMBER", "value": "1" },   
  55. . - . 2 • 0 N 0 8 

    P A 1 0 2 A P 1I 82 A
  56. 2 1 - 0. . 2  I 3 4

    3A N5 4 3A 5 8 4 5
  57. A /0 1 . • . /802/ ae W I

    • : L • : RLN L d  1 0: 1:8  bc • : S • U S DDDD 1 0: 1:8   bc 
  58. 8 . . • t l • 21 oIc bU

    c g R • .2 0L Rl LN A g P • t 21 c • 21 o c a g R • euA B c i L c k n R 
  59. 0 81 . • . 02 aA S D •

    OR H • W L H • L U • L 8 8 I N 
  60. . . • R PNO I . 2/. • R

    PNO U SHP 1 :EE D = A A? E0 A 8 E E A A 8 E LLLL LLLL 
  61. E 12 = . • R L • R L

    T NL0. ? & III 21 : 8 /D? 1 8 = 8 /D? 8 8 /D? ? L LU 
  62. A 01 2 . • IL DRU E • IL

    D8 N/. E • IL /. =? 1028 2 : 1A 02 0 1A 
  63. A . . • ic WC a S P ihC

    • ic WC Pu Lom g e t • sa S 01 Po • C C dSbdeLSi C • L chSPpn • Wi C h SiGI chS NLPlv • .0 • 8 1 • 8 8 0 82 
  64. -. 8/     • : 2 .

    / 8 -. .-/ 2 8 81 -80 8 • ID 81 0 8 -0 C 8 -0 
  65. 0 81   backlog-kintone-handson ├── README.md ├── serverless.yml ├──

    handler.js ├── backlog.js ├── kintone.js ├── package-lock.json ├── package.json └── conf ├── dev.yml.sample └── production.yml.sample Y NAS ej 02 & d 02 c al 82 G I LW 2 MAP b hc Y .
  66.     functions: add_issue_to_backlog: handler: handler.addIssueToBacklog events: -

    http: path: add_issue_to_backlog method: post environment: BACKLOG_SPACE: (.) ... module.exports.addIssueToBacklog = (event, context, callback) => { const backlog = new Backlog( process.env.BACKLOG_SPACE, process.env.BACKLOG_API_KEY, ( .) . A G
  67.     functions: add_issue_to_backlog: handler: handler.addIssueToBacklog events: -

    http: path: add_issue_to_backlog method: post environment: BACKLOG_SPACE: (.) ... module.exports.addIssueToBacklog = (event, context, callback) => { const backlog = new Backlog( process.env.BACKLOG_SPACE, process.env.BACKLOG_API_KEY, ( .) . . . .
  68. 8 0 1     • 388 •

    nN _ JO B l kU uI • 388 . 388 . 388 • nN _ JO BoeO 388 cg L a uI • 22. 3. .0 1 8 • 3 O 30 g l kU 1 8 Ob tw 3 Ob tw i • 2 3. 3. . 3 • 1 8 O 30 g l kU b d OR 3 O hp S _ s i 
  69. /   • 0/ . 2 .1 8 0/

    .  --- MESSAGE: Hello YEAR: "2018" BACKLOG_SPACE: YOUR_DOMAIN.backlog.com BACKLOG_API_KEY: YOUR_API_KEY BACKLOG_PROJECT_ID: "YOUR_PROJECT_ID" BACKLOG_ISSUE_TYPE_ID: "YOUR_ISSUE_TYPE_ID" KINTONE_DOMAIN: YOUR_DOMAIN KINTONE_APP_ID: "YOUR_APP_ID" KINTONE_API_TOKEN: YOUR_API_TOKEN BACKLOG_CFID_CREATED_BY: "YOUR_CUSTOM_FIELD_ID_1" BACKLOG_CFID_KINTONE_RECORD_URL: "YOUR_CUSTOM_FIELD_ID_2"    
  70.   • 201 8.  --- MESSAGE: Hello YEAR:

    "2018" BACKLOG_SPACE: YOUR_DOMAIN.backlog.com BACKLOG_API_KEY: YOUR_API_KEY BACKLOG_PROJECT_ID: "YOUR_PROJECT_ID" BACKLOG_ISSUE_TYPE_ID: "YOUR_ISSUE_TYPE_ID" KINTONE_DOMAIN: YOUR_DOMAIN KINTONE_APP_ID: "YOUR_APP_ID" KINTONE_API_TOKEN: YOUR_API_TOKEN BACKLOG_CFID_CREATED_BY: "YOUR_CUSTOM_FIELD_ID_1" BACKLOG_CFID_KINTONE_RECORD_URL: "YOUR_CUSTOM_FIELD_ID_2" 3 5 5 ik 5 I ( ik R gBc e ( ik R gB 5 PA 1/ ( ik OUB) ( ( ik fmB RO ( ik dH D nal 5 . UAO ik 23 . NA SL 23 R ARo
  71. 2- .     • I • a

    N 1 0 0- 11 - . 8  $ npm install
  72.   • 0 18 2  $ sls deploy

    $ sls deploy --profile N 1 2 . . I
  73.   • 2 0 18  $ sls deploy

    Serverless Warning -------------------------------------- A valid file to satisfy the declaration 'file(./conf/production.yml)' could not be found. Serverless: Packaging service... Serverless: Excluding development dependencies... Serverless: Creating Stack... Serverless: Checking Stack create progress... ..... Serverless: Stack create finished... Serverless: Uploading CloudFormation file to S3... Serverless: Uploading artifacts... Serverless: Uploading service .zip file to S3 (2.27 MB)... .
  74.   • 01 2 8 .  . Serverless:

    Stack update finished... Service Information service: backlog-kintone-handson stage: dev region: ap-northeast-1 stack: backlog-kintone-handson-dev api keys: None endpoints: POST - https://NNNNNNNNNN.execute-api.ap-northeast-1.amazonaws.com/dev/hello GET - https://NNNNNNNNNN.execute-api.ap-northeast-1.amazonaws.com/dev/hello_ hello_hello POST - https://NNNNNNNNNN.execute-api.ap-northeast-1.amazonaws.com/dev/add_i ssue_to_backlog POST - https://NNNNNNNNNN.execute-api.ap-northeast-1.amazonaws.com/dev/updat e_issue_on_kintone     
  75. - . . . • 0 288 0 2 0W

     N U I U RL 0-1 RL
  76. 801 2 . .  _ 0 4 6 4

    76 4 I4 6 I- L _ I W L N _ .415 7 L U _ .415 7L R LN N
  77. 82   • 8. 12 o • tk a

    I b T e c d ps 10 . g O • il IB N • 8 . 8. 0 .o • 12 n n 10 . g • n nK 10 . u 
  78. 

  79. .  • . 1L c S g g e

    b • 2 8 0L b • . 1 2 8 0 a W kIut Pm • L . 1I 2 8 0 l Po B N • L 2 8 0 a d ni AN d d • L ni AN d d 
  80. 

  81. . 12 - 3 . • 13: /37 • 13:

    v N ina ew S u cjf • N I7BB 4 4 B 5 9 4 4 B 5 7 • • 13: t r • 13: gob o • w koe W • oe l e • 08:8 • h m • p 13: s 
  82. .B:12 . . • : 0 A MN 1 :

    a bc • AA 8A B2 B:12 21 : 2B: 8 B 8 A 1A8 1 2: 2 1 A / - • : R S E G I D 1 : a bc N E 
  83. 1F? 0 . . • x q = A 9

    feb q ?A p = A 9 oc 34z • / 2 h ln k n 34k an z QN BD : C I A F = :A ?B D AB9 I A F 9 = A 9 .9 =? DB =8 ?A t V 34k an w ?A qs e og d i S qs yu 
  84. # - 01 2 3 . • 0G . 0

    4 0FN I I b • # d c S I a A 0 A 0 0G 2 01 0 A 0 A 4 # # 0 0G 0 8 0 4 0F A A 4A 24 8284A • /4 4 4AA 0 4 : I P . 0 4 0FN I I S I • A A4 4 4AA 2 0 4 : 2A 8 4 A 0 A 4 4 A 0 8 0 4 0F 4A 24 82F 
  85.     provider: name: aws ( .) resourcePolicy:

    - Effect: Allow Principal: "*" Action: execute-api:Invoke Resource: - execute-api:/*/*/* Condition: IpAddress: aws:SourceIp: - "52.199.190.133" - "54.238.59.48" ... .
  86. 8 . :/      • /

    8 1. KI • . / 8 / 1/ B1. • : :1 1. KI • 18 : :1 / 1:1 8 0 : 8 2 00 1 8 
  87. 8 1 2  • I Pai e I P

    B ln • o 01 . 0 2 2 N 2 0 2 2 01 . N • P i I g_P kb e P i dc ln  resourcePolicy: - Effect: Allow Principal: "*" Action: execute-api:Invoke Resource: - execute-api:/*/*/*
  88. 8 4 . . • 34 1 N B 0.2

    3 A B      D P     I P
  89. 801 92 . • NP /. • 5 34 48:

    4 2 1: : 52 70 0 284 • I • 5 34 48: 4 2 1: : 52 70 0 284