Backend ๐Ÿ“š/Node.js

[Node] Dialogflow API๋ฅผ ํ™œ์šฉํ•œ ์ฑ—๋ด‡ ์‚ฌ์ดํŠธ - 1. Dialogflow API

leejaejae 2024. 8. 12. 18:57

0. ๋“ค์–ด๊ฐ€๊ธฐ ์•ž์„œ!

1) ๋ฐฑ์—”๋“œ ์„œ๋ฒ„ ๋งŒ๋“ค๊ธฐ & ๊นƒํ—ˆ๋ธŒ ์›๊ฒฉ์ €์žฅ์†Œ(Repository) ์—ฐ๊ฒฐ(์ด์ „ ํฌ์ŠคํŒ… ์ฐธ๊ณ !)

2024.07.30 - [Backend ๐Ÿ“š/Node.js] - [Node] NODE JS, EXPRESS JS ๋‹ค์šด๋กœ๋“œ ํ•˜๊ธฐ

 

[Node] NODE JS, EXPRESS JS ๋‹ค์šด๋กœ๋“œ ํ•˜๊ธฐ

0. ๋“ค์–ด๊ฐ€๊ธฐ ์•ž์„œ!node.js๋ž€node.js๋Š” ๋ธŒ๋ผ์šฐ์ € ์™ธ๋ถ€์—์„œ JavaScript ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•˜๋Š” ์˜คํ”ˆ ์†Œ์Šค, ํฌ๋กœ์Šค ํ”Œ๋žซํผ, JavaScript ๋Ÿฐํƒ€์ž„ ํ™˜๊ฒฝ์ž„node.js๊ฐ€ ๋‚˜์˜ค๊ธฐ ์ „๊นŒ์ง€๋Š” ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋ฅผ ํ•ญ์ƒ ๋ธŒ๋ผ์šฐ์ € ์†์—์„œ

jaejae-sosp.tistory.com

2024.07.31 - [Backend ๐Ÿ“š/Node.js] - [Node] GIT ์„ค์น˜, Github ์—ฐ๊ฒฐ

 

[Node] GIT ์„ค์น˜, Github ์—ฐ๊ฒฐ

0. ๋“ค์–ด๊ฐ€๊ธฐ ์•ž์„œ!git ์ด๋ž€๋ถ„์‚ฐ ๋ฒ„์ „ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ, ์ฝ”๋“œ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ์ด๋ผ๊ณ  ๋ณด๋ฉด ๋จ ์—ฌ๋Ÿฌ ๋ช…์ด ํ•œ ์‚ฌ์ดํŠธ๋ฅผ ์œ„ํ•ด ์ฝ”๋“œ๋ฅผ ์ง ๋‹ค๋ฉด ๊นƒ์„ ํ†ตํ•ด ์ฝ”๋“œ๋ฅผ ํ•ฉ์น  ์ˆ˜ ์žˆ๊ณ , ์–ด๋–ค ์‚ฌ๋žŒ์ด ์–ด๋–ค ๋ถ€๋ถ„์„ ๋งŒ๋“ค์—ˆ๋Š”

jaejae-sosp.tistory.com


2) ๊ธฐ๋ณธ ์ฝ”๋“œ ๊ตฌ์กฐ


3) /server/config์— dev.js ํŒŒ์ผ ๋งŒ๋“ค๊ธฐ

 

2. Goole Project ๋งŒ๋“ค๊ธฐ

- Google Cloud CONSOLE์—์„œ ์ƒˆ๋กœ์šด Google Project ๋งŒ๋“ค๊ธฐ

-  Google Project ID dev.js ์— ๋„ฃ๊ธฐ

 

3. Dialogflow์—์„œ ์ƒˆ๋กœ์šด Agent ๋งŒ๋“ค๊ธฐ

-  Dialogflow์—์„œ ์ƒˆ๋กœ์šด Agent ๋งŒ๋“ค๊ธฐ(์ด๋•Œ ๋‚ด๊ฐ€ google project์—์„œ ๋งŒ๋“  ํ”„๋กœ์ ํŠธ ์ฐพ์•„์„œ ์—ฐ๊ฒฐ)

 

4. Goole Project์—์„œ  Service Account ๋งŒ๋“ค๊ธฐ

- service account ๋งŒ๋“ค๊ณ  private key ์ƒ์„ฑํ•ด json ํŒŒ์ผ๋กœ ์ €์žฅ(ํ›„ ๋‹ค์šด๋กœ๋“œ)

- json์— ์žˆ๋Š” ์ •๋ณด dev.js ์— ๋„ฃ๊ธฐ

 

5. private key ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ์„ค์ •ํ•˜๊ธฐ

- ํ„ฐ๋ฏธ๋„์—์„œ GOOGLE_APPLICATION_CREDENTIALS๋ผ๋Š” ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ๊ฐœ์ธ ํ‚ค๋กœ ์„ค์ •

export GOOGLE_APPLICATION_CREDENTIALS= /path-to-keys/key.json

 

TIPS. ์—๋””ํ„ฐ๋ฅผ ๊ป๋‹ค ์ผœ๋„ ์‚ฌ๋ผ์ง€์ง€ ์•Š๊ฒŒ ํ™˜๊ฒฝ๋ณ€์ˆ˜๋ฅผ ์„ค์ •ํ•˜๋Š” ๋ฒ•

1. ํ„ฐ๋ฏธ๋„์—์„œ `touch ~/.zshrc` ํŒŒ์ผ์„ ๋งŒ๋“ค์–ด ์คŒ
2. `open ~/.zshrc` ๋งŒ๋“  ํŒŒ์ผ๋กœ ๋“ค์–ด๊ฐ
3. ๊ทธ ์•ˆ์—๋‹ค๊ฐ€ `export GOOGLE_APPLICATION_CREDENTIALS=/path-to-keys/key.json` ๋‹ค์‹œ ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ์ •ํ•ด์คŒ
4. Command(โŒ˜) + Q๋กœ ๋‚˜์˜ค๊ธฐ
5. `source ~/.zshrc` ๋กœ ์ ์šฉ
6. ์—๋””ํ„ฐ๋ฅผ ๊ป๋‹ค ๋‹ค์‹œ ์ผ  ํ›„ `echo $GOOGLE_APPLICATION_CREDENTIALS` ์ด๊ฑธ ํ•ด๋ณด์‹œ๋ฉด ๊ฒฝ๋กœ๊ฐ€ ์•Œ๋งž๊ฒŒ ๋‚˜์˜ค๋Š” ๊ฑธ ํ™•์ธ ํ•  ์ˆ˜ ์žˆ์Œ


โ˜… ๋”ฐ๋ผํ•˜๋ฉฐ ๋ฐฐ์šฐ๋Š” ๋…ธ๋“œ, ๋ฆฌ์•กํŠธ ์‹œ๋ฆฌ์ฆˆ - ์ฑ—๋ด‡ ์‚ฌ์ดํŠธ ๋งŒ๋“ค๊ธฐ ๊ฐ•์˜๋ฅผ ์ฐธ๊ณ ํ•ฉ๋‹ˆ๋‹ค.