Action
nesneleri, etkileşimli derlemeler yapmanıza olanak tanır.
Google Workspace eklentilerine aktarmanızı sağlar. Bu özellikler
Kullanıcı bir widget'la (örneğin, düğme) etkileşimde bulunduğunda ne olur?
kullanıcı arayüzünü görürsünüz.
Bir eylem, belirli bir widget'a widget işleyici işlevinden yararlanın. Bu değer, işlemi tetikleyen koşulu da tanımlar. Tetiklendiğinde, belirlenen bir hedefe yönelik geri çağırma işlevinden yararlanın. Geri çağırma işlevi, etkinlik nesnesi Kullanıcının istemci tarafı etkileşimleriyle ilgili bilgiler. Şunu uygulamanız gerekir: geri çağırma işlevine gidin ve belirli bir yanıt nesnesini döndürmesini sağlayın.
Örneğin, bir düğmeyle etkileşime girdiğinizde yeni bir kart oluşturan ve görüntüleyen
tıklandı. Bunun için yeni bir düğme widget'ı oluşturmalı ve düğme widget'ını
işleyici işlevi
setOnClickAction(action)
kart oluşturma Action
özelliğini ayarlayın. İlgili içeriği oluşturmak için kullanılan
Tanımladığınız Action
bir Apps Komut Dosyası belirtiyor
geri çağırma işlevi vardır. Böyle durumlarda
istediğiniz kartı oluşturmak için geri çağırma işlevini uygulayın ve
ActionResponse
nesnesini tanımlayın. Yanıt nesnesi, eklentiye geri çağırma için kartı görüntülemesini söyler
fonksiyonunu geliştiriyoruz.
Bu sayfada, ekleyebilirsiniz.
Takvim etkileşimleri
Takvim'in kapsamını genişleten Google Workspace Eklentileri Takvim'e özel birkaç ek widget işlemi içerebilir. Bu işlemler ilişkili geri çağırma işlevini gerektirir. işlevini kullanın:
Yapılmak istenen işlem | Geri çağırma işlevi şunu döndürmelidir: |
---|---|
Katılımcılar ekleme | CalendarEventActionResponse |
Konferans verilerini ayarlama | CalendarEventActionResponse |
Dosya ekleme | CalendarEventActionResponse |
Bu widget işlemleri ve yanıt nesnelerinden yararlanmak için aşağıdakilerin tümü doğru olmalıdır:
- İşlem, kullanıcı bir Takvim etkinliği açıkken tetiklenir.
- Eklentinin
addOns.calendar.currentEventAccess
manifest alanıWRITE
veyaREAD_WRITE
olarak ayarlanmış olmalıdır. - Eklenti
https://www.googleapis.com/auth/calendar.addons.current.event.write
. Takvim kapsamı.
Ayrıca geri çağırma işlevinde yapılan değişiklikler, Kullanıcı Takvim etkinliğini kaydeder.
Geri çağırma işleviyle katılımcılar ekleme
Aşağıdaki örnekte, belirli bir etiket eklemek için bir düğmenin nasıl katılımcısı belirleniyor:
/**
* Build a simple card with a button that sends a notification.
* This function is called as part of the eventOpenTrigger that builds
* a UI when the user opens an event.
*
* @param e The event object passed to eventOpenTrigger function.
* @return {Card}
*/
function buildSimpleCard(e) {
var buttonAction = CardService.newAction()
.setFunctionName('onAddAttendeesButtonClicked');
var button = CardService.newTextButton()
.setText('Add new attendee')
.setOnClickAction(buttonAction);
// Check the event object to determine if the user can add
// attendees and disable the button if not.
if (!e.calendar.capabilities.canAddAttendees) {
button.setDisabled(true);
}
// ...continue creating card sections and widgets, then create a Card
// object to add them to. Return the built Card object.
}
/**
* Callback function for a button action. Adds attendees to the
* Calendar event being edited.
*
* @param {Object} e The action event object.
* @return {CalendarEventActionResponse}
*/
function onAddAttendeesButtonClicked (e) {
return CardService.newCalendarEventActionResponseBuilder()
.addAttendees(["aiko@example.com", "malcom@example.com"])
.build();
}
Geri çağırma işleviyle konferans verilerini ayarlama
Bu işlem, açık etkinlikteki konferans verilerini ayarlar. Bu konferans verileri için konferans çözümü kimliğinin belirtilmesi gerekir, çünkü işlem Kullanıcının istenen çözümü seçmesiyle tetiklenir.
Aşağıdaki örnekte, konferans verilerini ayarlayan bir düğmenin nasıl oluşturulacağı gösterilmektedir Düzenlenen etkinlik için:
/**
* Build a simple card with a button that sends a notification.
* This function is called as part of the eventOpenTrigger that builds
* a UI when the user opens a Calendar event.
*
* @param e The event object passed to eventOpenTrigger function.
* @return {Card}
*/
function buildSimpleCard(e) {
var buttonAction = CardService.newAction()
.setFunctionName('onSaveConferenceOptionsButtonClicked')
.setParameters(
{'phone': "1555123467", 'adminEmail': "joyce@example.com"});
var button = CardService.newTextButton()
.setText('Add new attendee')
.setOnClickAction(buttonAction);
// Check the event object to determine if the user can set
// conference data and disable the button if not.
if (!e.calendar.capabilities.canSetConferenceData) {
button.setDisabled(true);
}
// ...continue creating card sections and widgets, then create a Card
// object to add them to. Return the built Card object.
}
/**
* Callback function for a button action. Sets conference data for the
* Calendar event being edited.
*
* @param {Object} e The action event object.
* @return {CalendarEventActionResponse}
*/
function onSaveConferenceOptionsButtonClicked(e) {
var parameters = e.commonEventObject.parameters;
// Create an entry point and a conference parameter.
var phoneEntryPoint = ConferenceDataService.newEntryPoint()
.setEntryPointType(ConferenceDataService.EntryPointType.PHONE)
.setUri('tel:' + parameters['phone']);
var adminEmailParameter = ConferenceDataService.newConferenceParameter()
.setKey('adminEmail')
.setValue(parameters['adminEmail']);
// Create a conference data object to set to this Calendar event.
var conferenceData = ConferenceDataService.newConferenceDataBuilder()
.addEntryPoint(phoneEntryPoint)
.addConferenceParameter(adminEmailParameter)
.setConferenceSolutionId('myWebScheduledMeeting')
.build();
return CardService.newCalendarEventActionResponseBuilder()
.setConferenceData(conferenceData)
.build();
}
Geri çağırma işleviyle ekler ekleyebilirsiniz
Aşağıdaki örnekte, Düzenlenen takvim etkinliği:
/**
* Build a simple card with a button that creates a new attachment.
* This function is called as part of the eventAttachmentTrigger that
* builds a UI when the user goes through the add-attachments flow.
*
* @param e The event object passed to eventAttachmentTrigger function.
* @return {Card}
*/
function buildSimpleCard(e) {
var buttonAction = CardService.newAction()
.setFunctionName('onAddAttachmentButtonClicked');
var button = CardService.newTextButton()
.setText('Add a custom attachment')
.setOnClickAction(buttonAction);
// Check the event object to determine if the user can add
// attachments and disable the button if not.
if (!e.calendar.capabilities.canAddAttachments) {
button.setDisabled(true);
}
// ...continue creating card sections and widgets, then create a Card
// object to add them to. Return the built Card object.
}
/**
* Callback function for a button action. Adds attachments to the Calendar
* event being edited.
*
* @param {Object} e The action event object.
* @return {CalendarEventActionResponse}
*/
function onAddAttachmentButtonClicked(e) {
return CardService.newCalendarEventActionResponseBuilder()
.addAttachments([
CardService.newAttachment()
.setResourceUrl("https://example.com/test")
.setTitle("Custom attachment")
.setMimeType("text/html")
.setIconUrl("https://example.com/test.png")
])
.build();
}
Ek simgesini ayarlama
Ek simgesi Google'ın altyapısında barındırılmalıdır. Daha fazla bilgi için ek simgeleri inceleyebilirsiniz.