Coding level : Intermediate
Duration : 25 minutes
Project type : Google Chat app
Цели
- Поймите, для чего предназначено это решение.
- Разберитесь, что делают службы Apps Script в рамках данного решения.
- Настройте свою среду.
- Настройте скрипт.
- Запустите скрипт.
Об этом решении
Запланируйте встречу в Google Календаре прямо из личного сообщения (DM) или в чате Google. Вы можете указать конкретные детали встречи, такие как тема, время начала или продолжительность, или использовать настройки по умолчанию для мгновенного планирования встреч.


Как это работает
The Chat app script uses slash commands and dialogs to get meeting details from users and schedule a Calendar event. The script includes default meeting settings that can be customized to fit your needs.
Сервисы Apps Script
Данное решение использует следующие сервисы:
- Calendar service –Creates the calendar event from the provided meeting info.
- Базовый сервис — использует класс
Sessionдля получения часового пояса скрипта. Календарь использует этот часовой пояс при планировании события. - Utilities service –Formats the date for the calendar event and encodes the event ID to help get the event URL.
Предварительные требования
- Корпоративный аккаунт Google Workspace с доступом к Google Chat .
- Create a Google Cloud project .
Настройте свою среду
Откройте свой облачный проект в консоли Google Cloud.
Если проект Cloud, который вы собираетесь использовать в этом примере, еще не открыт, откройте его:
- In the Google Cloud console, go to the Select a project page.
- Select the Google Cloud project you want to use. Or, click Create project and follow the on-screen instructions. If you create a Google Cloud project, you might need to turn on billing for the project .
Включите API
Перед использованием API Google необходимо включить их в проекте Google Cloud. В одном проекте Google Cloud можно включить один или несколько API.В своем облачном проекте включите Google Chat API.
Настройте экран согласия OAuth.
Для всех чат-приложений требуется настройка экрана согласия. Настройка экрана согласия OAuth в вашем приложении определяет, что Google отображает пользователям, и регистрирует ваше приложение, чтобы вы могли опубликовать его позже.
- In the Google Cloud console, go to Menu >Google Auth platform > Branding .
- Если вы уже настроили Google Auth platform, you can configure the following OAuth Consent Screen settings in Branding , Audience , and Data Access . If you see a message that says Google Auth platform not configured yet , click Get Started :
- Under App Information , in App name , enter a name for the app.
- In User support email , choose a support email address where users can contact you if they have questions about their consent.
- Нажмите «Далее» .
- Under Audience , select Internal .
- Click Next .
- Under Contact Information , enter an Email address where you can be notified about any changes to your project.
- Click Next .
- Under Finish , review the Google API Services User Data Policy and if you agree, select I agree to the Google API Services: User Data Policy .
- Click Continue .
- Click Create .
- For now, you can skip adding scopes. In the future, when you create an app for use outside of your Google Workspace organization, you must change the User type to External . Then add the authorization scopes that your app requires. To learn more, see the full Configure OAuth consent guide.
Настройте скрипт
Создайте проект Apps Script.
- Click the following button to open the Schedule meetings from Google Chat Apps Script project.
Откройте проект - Click Overview .
- На странице обзора нажмите «Создать копию».
.
В будущем, если вы захотите использовать определенные API Google или опубликовать свое приложение, вам необходимо будет связать свой проект Cloud с проектом Apps Script. В этом руководстве это делать не требуется. Для получения дополнительной информации см. руководство по проектам Google Cloud .
Создайте тестовое развертывание.
- In your copied Apps Script project, click Deploy > Test deployments .
- Copy the Head deployment ID for use in a later step and click Done .
Настройте API чата.
- In the Google Cloud console, go to the Chat API page.
Перейти к API чата - Нажмите «Конфигурация» .
- Clear Build this Chat app as a Google Workspace add-on . A dialog opens asking you to confirm. In the dialog, click Disable .
- Настройте API чата, указав следующую информацию:
- Name :
Meeting Scheduler - Avatar URL : Add a URL that points to an image with a minimum size of 256x256 pixels.
- Description :
Quickly create meetings. - Functionality : Check both boxes to let users message the app directly and add it to spaces.
- Настройки подключения : Нажмите «Apps Script» и введите идентификатор развертывания головного приложения.
- Slash commands : Add slash commands for
/helpand/schedule_Meetingby taking the following steps:- Click Add slash command and configure it with the following information:
- Name :
/help - Command ID :
1 - Description :
Learn what this app does.
- Name :
- Click Add slash command again and configure it with the following information:
- Name :
/schedule_Meeting - Command ID :
2 - Описание :
Schedule a meeting. - Check the Opens a dialog box.
- Name :
- Click Add slash command and configure it with the following information:
- Permissions : Select Specific people and groups in your domain and enter your email address.
- Name :
- Click Save and refresh the page.
- On the configuration page, under App status , set the status to Live - available to users .
- Click Save .
Запустите скрипт
- Open Google Chat .
- Click Start a chat .
- Search for the app's name,
Meeting Scheduler. - Send an initial message, such as
hello, to prompt authorization. When the app replies, click Configure and authorize the app. If the OAuth consent screen displays the warning, This app isn't verified , continue by selecting Advanced > Go to {Project Name} (unsafe) .
Send
/schedule_Meetingto the app.В диалоговом окне добавьте как минимум один адрес электронной почты приглашенного. Вы можете изменить остальные поля или использовать значения по умолчанию.
Click Submit .
To view the meeting, click Open Calendar event .
Просмотрите код
To review the Apps Script code for this solution, click View source code below: