במדריך הזה תלמדו איך ליצור אפליקציית Google Chat מגיבים לאירועים בזמן אמת. כשמגיבים לאירוע, האפליקציה יוצר ומאכלס מרחב ב-Chat, שמאפשר אירוע של הודעות, פקודות ותיבות דו-שיח, ומשתמשת ב-AI כדי לסכם על התגובה לאירוע במסמך Google Docs.
אירוע הוא אירוע שמחייב טיפול מיידי של צוות. של אנשים לפתור. דוגמאות לאירועים:
- בקשת תמיכה תלוית זמן נוצרת במערכת לניהול קשרי לקוחות (CRM) כך שצוות השירות צריך לשתף פעולה כדי להגיע לפתרון.
- מערכת עוברת למצב אופליין ומתריעה לקבוצה של מהנדסי Site Reliability (SRE) כדי שיוכלו לפעול יחד כדי להחזיר אותו לאינטרנט.
- מתרחשת רעידת אדמה בעוצמה גבוהה, ועובדי שירותי החירום צריכים כדי לתאם את התגובה שלהם.
למטרות המדריך הזה, ההתראה על אירוע מתחילה כשמישהו מדווח על התקרית בלחיצה על לחצן מדף אינטרנט. דף האינטרנט מדמה פרטי האירוע צריכים להזין את הפרטים הבסיסיים של האירוע: כותרת, וכתובות האימייל של המשיבים.
רוצה לראות את אפליקציית Chat לניהול אירועים?
-
איור 2. התראה על כך שנוצר מרחב משותף ב-Chat. -
איור 3. המרחב ב-Chat של התגובה לאירוע. -
איור 4. פתרון התקרית באמצעות פקודת קו נטוי. -
איור 5. תיבת דו-שיח לפתרון התקרית. -
איור 6. מסמך Google Docs של Google Docs משותף במרחב. -
איור 7. מסמך ב-Google Docs של סיכום האירוע על ידי AI.
דרישות מוקדמות
אם צריך להפעיל בארגון את הדרישות המוקדמות האלה, עליך לבקש כדי שהאדמין ב-Google Workspace יפעיל אותם:
- עסק או ארגון חשבון Google Workspace עם גישה אל Google Chat.
- כדי ספרייה (שיתוף אנשי קשר) מופעל ב-Google Workspace. אפליקציית האירוע משתמשת את הספרייה כדי לחפש את המגיבים פרטים ליצירת קשר, כמו שם וכתובת אימייל. המשיבים חייבים להיות משתמשים עם צ'אט של Google Chat חשבון Google Workspace של הארגון.
מטרות
- לפתח אפליקציה ל-Chat שמגיבה לתקריות.
- כדי לעזור למשתמשים להגיב לאירועים, צריך לבצע את הפעולות הבאות:
- יצירת מרחבי תגובה לתקריות.
- פרסום הודעות עם סיכום של אירועים ותגובות.
- תמיכה בשיתוף פעולה עם כלים אינטראקטיביים התכונות של אפליקציית Chat.
- סיכום שיחות ופתרונות באמצעות Vertex AI.
ארכיטקטורה
בתרשים הבא מוצגת הארכיטקטורה של Google Workspace המשאבים של Google Cloud שמשמשים את התגובה לאירוע אפליקציית Google Chat.
בארכיטקטורה אפשר לראות איך התגובה לאירוע אפליקציית Google Chat מעבדת את האירוע ואת הפתרון שלו.
משתמש מתחיל אירוע מאתר חיצוני שמתארח ב- Apps Script.
האתר שולח בקשת HTTP אסינכרונית אל אפליקציית Google Chat, גם מתארחת ב-Apps Script.
התגובה לאירוע Google Chat מעבדת את הבקשה:
שירות Apps Script Admin SDK מקבל חבר צוות מידע כמו מזהה משתמש וכתובת אימייל.
באמצעות קבוצה של בקשות HTTP ל-Chat API באמצעות שירות צ'אט מתקדם של Apps Script, התגובה לאירוע אפליקציית Google Chat יוצרת אירוע ב-Chat יאכלס אותו בחברי הצוות ושולח הודעה למרחב המשותף.
חברי הצוות מדברים על האירוע במרחב המשותף ב-Chat.
חבר צוות מפעיל פקודת לוכסן כדי לסמן שיש פתרון נוסף לתקרית.
קריאת HTTP ל-Chat API באמצעות Apps Script שירות Chat מתקדם מציג את כל רשימות הצ'אט הודעות במרחב המשותף.
Vertex AI מקבל את ההודעות שברשימה ויוצר סיכום.
שירות Apps Script
DocumentApp
יוצר ב-Docs ומוסיף את הסיכום של Vertex AI מהמסמך.התגובות לשיחות באפליקציית Google Chat Chat API לשליחת הודעה עם קישור לסיכום ב-Docs.
מכינים את הסביבה
בקטע הזה נסביר איך ליצור ולהגדיר פרויקט ב-Google Cloud עבור אפליקציית Chat.
יצירת פרויקט של Google Cloud
מסוף Google Cloud
- במסוף Google Cloud, נכנסים לתפריט > IAM & אדמין > יצירת פרויקט.
-
בשדה Project Name (שם הפרויקט), מזינים שם תיאורי לפרויקט.
אופציונלי: כדי לערוך את Project ID, לוחצים על Edit (עריכה). לא ניתן לשנות את מזהה הפרויקט אחרי שהפרויקט נוצר, לכן בחר מזהה שעונה על הצרכים שלך לכל משך החיים של הפרויקט פרויקט.
- בשדה מיקום לוחצים על עיון כדי להציג את המיקומים האפשריים של פרויקט. לאחר מכן לוחצים על בחירה.
- לוחצים על יצירה. במסוף Google Cloud עוברים לדף Dashboard ונוצר הפרויקט תוך כמה דקות.
CLI של gcloud
נכנסים ל-Google Cloud באחת מסביבות הפיתוח הבאות CLI (`gcloud`):
-
Cloud Shell: כדי להשתמש בטרמינל אונליין באמצעות ה-CLI של gcloud
כבר הוגדר, צריך להפעיל את Cloud Shell.
הפעלת Cloud Shell -
Local Shell: כדי להשתמש בסביבת פיתוח מקומית,
התקנה ו
אתחול
ב-CLI של gcloud.
כדי ליצור פרויקט ב-Cloud, משתמשים בפקודה 'gcloud projects create':gcloud projects create PROJECT_ID
הפעלת החיוב בפרויקט ב-Cloud
מסוף Google Cloud
- נכנסים לקטע Billing במסוף Google Cloud. לוחצים על תפריט > חיוב > הפרויקטים שלי.
- בקטע בחירת ארגון, בוחרים את הארגון שמשויך אליו. את הפרויקט ב-Google Cloud.
- בשורת הפרויקט, פותחים את התפריט Actions (פעולות) ( ), לוחצים על שינוי החיוב ובוחרים לחשבון לחיוב ב-Cloud.
- לוחצים על Set account.
CLI של gcloud
- כדי להציג רשימה של החשבונות הזמינים לחיוב, מריצים את הפקודה:
gcloud billing accounts list
- מקשרים חשבון לחיוב לפרויקט ב-Google Cloud:
gcloud billing projects link PROJECT_ID --billing-account=BILLING_ACCOUNT_ID
מחליפים את מה שכתוב בשדות הבאים:
PROJECT_ID
הוא מזהה הפרויקט של הפרויקט ב-Cloud שבו רוצים להפעיל את החיוב.BILLING_ACCOUNT_ID
הוא מזהה החשבון לחיוב שאליו יש לקשר בפרויקט ב-Google Cloud.
הפעלת ממשקי ה-API
מסוף Google Cloud
במסוף Google Cloud, מפעילים את Google Chat API, את Google Docs API, Admin SDK API ו-Vertex AI API.
עליכם לוודא שאתם מפעילים את ממשקי ה-API פרויקט ב-Cloud ולוחצים על Next.
מוודאים שאתם מפעילים את ממשקי ה-API הנכונים ולוחצים על הפעלה.
CLI של gcloud
אם צריך, מגדירים את הפרויקט הנוכחי ב-Cloud לפרויקט שיצרתם באמצעות הפקודה
gcloud config set project
:gcloud config set project PROJECT_ID
מחליפים את PROJECT_ID במזהה הפרויקט של הפרויקט ב-Cloud שיצרתם.
הפעלה של Google Chat API, Google Docs API, Admin SDK API ו-Vertex AI API באמצעות הפקודה
gcloud services enable
:gcloud services enable chat.googleapis.com docs.googleapis.com admin.googleapis.com aiplatform.googleapis.com
הגדרת אימות והרשאה
האימות וההרשאה מאפשרים משאבי גישה לאפליקציות Chat ב-Google Workspace Google Cloud לעיבוד התגובה לאירוע.
במדריך הזה נפרסם את האפליקציה באופן פנימי, ולכן מותר להשתמש ב-placeholder מידע. לפני פרסום האפליקציה באופן חיצוני, צריך להחליף את ה-placeholder עם מידע אמיתי למסך ההסכמה.
במסוף Google Cloud, נכנסים אל תפריט > ממשקי API ו- שירותים > מסך ההסכמה של OAuth
בקטע סוג משתמש, בוחרים באפשרות פנימי ולוחצים על יצירה.
בשדה App name, מקלידים
Incident Management
.בקטע User support email (אימייל לתמיכת משתמשים), בוחרים את כתובת האימייל שלכם או כתובת אחרת קבוצה ב-Google.
בקטע פרטים ליצירת קשר עם המפתח, מזינים את כתובת האימייל.
לוחצים על שמירה והמשך.
לוחצים על הוספה או הסרה של היקפי הרשאות. תופיע חלונית עם רשימה של היקפים לכל API שהפעלתם בפרויקט ב-Cloud.
בקטע הוספה ידנית של היקפים, מדביקים את ההיקפים הבאים:
https://www.googleapis.com/auth/chat.spaces.create
https://www.googleapis.com/auth/chat.memberships
https://www.googleapis.com/auth/chat.memberships.app
https://www.googleapis.com/auth/chat.messages
https://www.googleapis.com/auth/documents
https://www.googleapis.com/auth/admin.directory.user.readonly
https://www.googleapis.com/auth/script.external_request
https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/cloud-platform
לוחצים על הוספה לטבלה.
לוחצים על עדכון.
לוחצים על שמירה והמשך.
מעיינים בסיכום הרישום של האפליקציה ולוחצים על חזרה למרכז השליטה.
יצירה ופריסה של אפליקציית Chat
בקטע הבא מעתיקים ומעדכנים חשבון שלם פרויקט Apps Script שמכיל את כל האפליקציה הנדרשת לאפליקציה ל-Chat, כך שלא צריך להעתיק מדביקים כל קובץ.
פונקציות מסוימות כוללות קווים תחתונים בסוף השמות, למשל
processSlashCommand_()
מ-ChatApp.gs
. הקו התחתון מסתיר את הפונקציה
מדף האינטרנט של אתחול האירוע כשהוא פתוח בדפדפן. לקבלת מידע נוסף
מידע נוסף, ראה
פונקציות פרטיות.
ב-Apps Script יש תמיכה בשני סוגי קבצים: .gs
סקריפטים ו-.html
. כדי לציית לתמיכה הזו, ה-JavaScript בצד הלקוח כלול באפליקציה
בתוך תגי <script />
וה-CSS שלו כלול בתוך תגי <style />
שבתוכו
בקובץ HTML.
לחלופין, אפשר להציג את הפרויקט כולו ב-GitHub.
לפניכם סקירה כללית של כל אחד מהקבצים:
Consts.gs
מגדיר קבועים שקובצי קוד אחרים מפנים אליהם, כולל מזהה הפרויקט ב-Cloud, מזהה המיקום ב-Vertex AI מזהה הפקודה לסגירת אירוע.
הצגת הקוד מהאפליקציה
Consts.gs
ChatApp.gs
טיפול באירועי אינטראקציה ב-Chat, כולל הודעות, לחיצות על כרטיסים, פקודות ותיבות דו-שיח. מגיב ל הפקודה
/closeIncident
מאפשרת לפתוח תיבת דו-שיח לאיסוף אירוע פרטי הרזולוציה. רוצה לקרוא את ההודעות במרחב המשותף? ה-methodspaces.messages.list
ב-Chat API. מקבל מזהי משתמשים באמצעות השירות Admin SDK Directory ב- Apps Script.הצגת הקוד מהאפליקציה
ChatApp.gs
ChatSpaceCreator.gs
מקבלים את נתוני הטופס שהמשתמשים מזינים באירוע של דף האינטרנט החדש, ומשתמשת בו כדי להגדיר צ'אט. ליצור ואכלס אותו, ולאחר מכן לפרסם הודעה לגבי נוסף לתקרית.
הצגת הקוד מהאפליקציה
ChatSpaceCreator.gs
DocsApi.gs
קורא ל-Google Docs API כדי ליצור מסמך Google Docs משתמש Google Drive של המשתמש וכותב סיכום של פרטי האירוע, נוצר ב-
VertexAiApi.gs
למסמך.הצגת הקוד מהאפליקציה
DocsApi.gs
VertexAiApi.gs
סיכום השיחה ב-Chat באמצעות Vertex AI. הסיכום הזה מפורסם בקובץ שנוצר במיוחד במסמך
DocsAPI.gs
.הצגת הקוד של
VertexAiApi.gs
WebController.gs
משמש את האתר לאתחול האירוע.
הצגת הקוד מהאפליקציה
WebController.gs
Index.html
ה-HTML שמכיל את האתר של אתחול האירוע.
הצגת הקוד מהאפליקציה
Index.html
JavaScript.html
טיפול בהתנהגות הטפסים, כולל שליחות, וכל השגיאות באתר של אתחול התקרית. כלולה בתוך
Index.html
באמצעות הפונקציהinclude
בהתאמה אישית בפונקציהWebController.gs
.הצגת הקוד מהאפליקציה
JavaScript.html
Stylesheet.html
שירות ה-CSS של האתר לאתחול התקרית. זו נכללים בתוך
Index.html
על ידי הפונקציהinclude
בהתאמה אישית במסגרתWebController.gs
.הצגת הקוד מהאפליקציה
Stylesheet.html
איתור מספר הפרויקט ב-Cloud והמזהה שלו
במסוף Google Cloud, נכנסים לפרויקט ב-Cloud.
לוחצים על 'הגדרות ותוכניות שירות'. > הגדרות הפרויקט.
שימו לב לערכים בשדות Project number ו-Project ID. שלך להשתמש בהם בקטעים הבאים.
יצירת פרויקט Apps Script
כדי ליצור פרויקט ב-Apps Script ולחבר אותו אל פרויקט ב-Cloud:
- לוחצים על הלחצן הבא כדי לפתוח את הפרויקט מענה לאירועים באמצעות Google Chat ב-Apps Script.
פתיחת הפרויקט - לוחצים על סקירה כללית.
- בדף הסקירה הכללית לוחצים על יצירת עותק.
נותנים שם לעותק של פרויקט Apps Script:
לוחצים על עותק של התשובה לאירועים באמצעות Google Chat.
בשדה Project title, מקלידים
Incident Management Chat app
.לוחצים על Rename.
בעותק של פרויקט Apps Script, עוברים אל
Consts.gs
ומחליפים אתYOUR_PROJECT_ID
במזהה של פרויקט בענן.
הגדרת פרויקט Cloud של פרויקט Apps Script
- בפרויקט Apps Script, לוחצים על Project Settings (הגדרות הפרויקט).
- בקטע פרויקט ב-Google Cloud Platform (GCP), לוחצים על שינוי פרויקט.
- בקטע מספר הפרויקט ב-GCP, מדביקים את מספר הפרויקט ב-Cloud.
- לוחצים על Set project. הפרויקט ב-Cloud ו-Apps Script הפרויקטים מחוברים עכשיו.
יצירת פריסה של Apps Script
עכשיו, כשכל הקוד מוכן, פורסים את Apps Script פרויקט. משתמשים במזהה הפריסה כשמגדירים את של אפליקציית Chat ב-Google Cloud.
ב-Apps Script, פותחים את הפרויקט של אפליקציית התגובה לאירוע.
לוחצים על פריסה > פריסה חדשה.
אם עדיין לא נבחרו תוסף ואפליקציית אינטרנט, לצד בחירת סוג, לוחצים על סוגי הפריסה ובוחרים באפשרות תוסף ואפליקציית אינטרנט.
בקטע תיאור, מזינים תיאור של הגרסה הזו, למשל
Complete version of incident management app
.בקטע ביצוע כ, בוחרים באפשרות משתמש שניגש לאפליקציית האינטרנט.
בקטע למי יש גישה, בוחרים באפשרות כל אחד בארגון ב-Workspace. שבו 'הארגון ב-Workspace' הוא השם של ארגון ב-Google Workspace.
לוחצים על Deploy (פריסה). הדוחות של Apps Script בוצעו בהצלחה של האירוע, ומספק את מזהה הפריסה וכתובת ה-URL של האירוע דף האינטרנט לאתחול.
מומלץ לרשום לפניכם את כתובת ה-URL של אפליקציית האינטרנט כדי להיכנס אליה מאוחר יותר כשמתחילים אירוע. מעתיקים את Deployment ID. אתם משתמשים במזהה הזה בזמן שמגדירים את אפליקציית Chat במסוף Google Cloud.
לוחצים על סיום.
איך מגדירים את אפליקציית Chat במסוף Google Cloud
בקטע הזה מוסבר איך מגדירים את Google Chat API במסוף Google Cloud עם מידע על אפליקציית Chat, כולל מזהה הפריסה שיצרת עכשיו מה-Apps Script פרויקט.
במסוף Google Cloud, לוחצים על תפריט. > מוצרים נוספים > Google Workspace > ספריית המוצרים > Google Chat API > ניהול > הגדרה.
בשדה App name, מקלידים
Incident Management
.בשדה כתובת URL של הדמות, מקלידים
https://developers.google.com/chat/images/quickstart-app-avatar.png
.בשדה Description, מקלידים
Responds to incidents.
.מעבירים את המתג הפעלת תכונות אינטראקטיביות למצב פעיל.
בקטע פונקציונליות, בוחרים באפשרות קבלת הודעות אישיות והצטרפות למרחבים משותפים ולשיחות קבוצתיות.
בקטע Connection settings (הגדרות חיבור), בוחרים באפשרות Apps Script project (פרויקט Apps Script).
בקטע Deployment ID (מזהה הפריסה), מדביקים את מזהה הפריסה של Apps Script שהעתקת קודם לכן מפרויקט Apps Script בפריסה גמישה.
רושמים פקודת של קו נטוי אפליקציית Chat שהוטמעה במלואה כוללת:
בקטע SlashCommand, לוחצים על Add a לוכסן הפקודה.
בשדה Name, מקלידים
/closeIncident
.בשדה Command ID, מקלידים
1
.בשדה תיאור, מקלידים
Closes the incident being discussed in the space.
בוחרים באפשרות פתיחה של תיבת דו-שיח.
לוחצים על סיום. הפקודה של הלוכסן רשומה ומופיעה.
בקטע חשיפה, בוחרים רוצה שאפליקציית Chat הזו תהיה זמינה לאנשים ספציפיים ולקבוצות ספציפיות? הדומיין ב-Workspace ומזינים את כתובת האימייל שלכם.
בקטע Logs (יומנים), בוחרים באפשרות Log errors to Logging (רישום שגיאות ביומן).
לוחצים על שמירה. תופיע הודעה שנשמרה לגבי ההגדרות, כלומר האפליקציה מוכן לבדיקה.
בדיקת האפליקציה של Chat
כדי לבדוק את אפליקציית Chat לניהול אירועים, צריך להפעיל אירוע בדף האינטרנט ואימות שאפליקציית Chat פועלת כמצופה:
מעבר לכתובת ה-URL של אפליקציית האינטרנט לפריסת Apps Script.
כאשר Apps Script מבקש הרשאה לגשת לנתונים שלכם, לוחצים על בדיקת הרשאות ונכנסים באמצעות חשבון Google מתאים. בדומיין Google Workspace, ולוחצים על אישור.
דף האינטרנט של אתחול האירוע ייפתח. מזינים את פרטי הבדיקה:
- בקטע שם האירוע, מקלידים
The First Incident
. - אופציונלי: בשדה משיבים לאירוע, מזינים את כתובות האימייל של לצוותי החירום העמיתים שלכם. הם חייבים להיות משתמשים עם חשבון Google Chat ששייך לארגון שלכם ב-Google Workspace, או יצירת המרחב המשותף נכשלה. אל תזין את כתובת האימייל שלך, כי נכללים אוטומטית.
- בהודעה הראשונית, צריך להקליד
Testing the incident management Chat app.
- בקטע שם האירוע, מקלידים
לוחצים על יצירת מרחב ב-Chat. תופיע ההודעה
creating space
.אחרי שיוצרים את המרחב המשותף, מופיעה ההודעה
Space created!
. לוחצים על פתיחת מרחב משותף. המרחב המשותף ב-Chat ייפתח בכרטיסייה חדשה.אופציונלי: אתם ושאר המגיבים לאירוע תוכלו לשלוח הודעות המרחב המשותף. האפליקציה מסכמת את ההודעות האלה באמצעות Vertex AI ומשתפת מסמך רטרוספקטיבי.
כדי לסיים את התגובה לאירוע ולהתחיל בתהליך הפתרון, מרחב ב-Chat, מסוג
/closeIncident
. ניהול אירועי אבטחה נפתחת תיבת דו-שיח.בקטע סגירת האירוע, מזינים תיאור של הפתרון לאירוע. כמו
Test complete
.לוחצים על סגירת האירוע.
באפליקציית ניהול האירועים יופיעו רשימת ההודעות במרחב המשותף ומסכמת אותן. ב-Vertex AI, מדביק את הסיכום במסמך Google Docs ומשתף את את המסמך במרחב המשותף.
הסרת המשאבים
כדי להימנע מצבירת חיובים בחשבון Google Cloud עבור במשאבים שנעשה בהם שימוש במדריך הזה, מומלץ למחוק את פרויקט בענן.
- במסוף Google Cloud, עוברים לדף Manage resources. לוחצים על תפריט > IAM & Admin (אדמין) > לניהול משאבים
- ברשימת הפרויקטים, בוחרים את הפרויקט שרוצים למחוק ולוחצים על הסמל. מחיקה של .
- כדי למחוק, כותבים את מזהה הפרויקט בתיבת הדו-שיח ולוחצים על Shut down. את הפרויקט.
נושאים קשורים
- שימוש באפליקציית Gemini AI Chat כדי לענות על שאלות על סמך אינטראקציות ב-Chat
- ניהול פרויקטים באמצעות Google Chat, Vertex AI ו-Firestore
- אפליקציית התגובה לאירועים מבצעת אימות באמצעות פרטי הכניסה של המשתמשים כדי לקרוא לממשקי API
ולהפעיל את שירותי Google Cloud, כמו Chat API ו-Vertex AI API.
המשמעות היא שלמשתמש שמאתחל אירוע צריכה להיות גישה
שירותים שונים. כדי לשפר את האבטחה של האפליקציה, כדאי לקרוא ל-Vertex AI API
בתור חשבון שירות במקום פרטי הכניסה של המשתמש שהפעיל
פקודת הלוכסן
/closeIncident
. עזרה בהגדרת חשבון שירות של Vertex AI API: שימוש בחשבון שירות בהתאמה אישית.