Bu kılavuzda,
get()
yöntemindeki ayrıntıları döndürmek için Google Chat API'nin Message
kaynağında
kısa mesaj veya kart mesajıyla gösterilir.
Chat API'de bir Chat mesajı
Message
kaynak.
Chat kullanıcıları yalnızca metin içeren mesajlar gönderebilirken Chat uygulamaları statik veya etkileşimli kullanıcı arayüzleri gösterme, kullanıcılardan bilgi toplama ve mesajları gizli olarak yayınlama gibi birçok mesajlaşma özelliğini kullanabilir. Mesajlaşma hakkında daha fazla bilgi edinmek için
özellikleri hakkında daha fazla bilgi için
Google Chat mesajlarına genel bakış
Ön koşullar
Node.js
- İşletme veya Kuruluş Şuna erişimi olan Google Workspace hesabı: Google Chat.
- Ortamınızı ayarlayın:
- Google Cloud projesi oluşturun.
- OAuth izin ekranını yapılandırın.
- Chat uygulamanız için bir ad, simge ve açıklamayla Google Chat API'yi etkinleştirip yapılandırın.
- Şunu yükleyin: Node.js Cloud İstemci Kitaplığı.
- Google Chat API'nizde nasıl kimlik doğrulama yapmak istediğinize bağlı olarak erişim kimlik bilgilerini oluşturun
istek:
- Chat kullanıcısı olarak kimlik doğrulamak için OAuth istemci kimliği kimlik bilgilerini oluşturun ve kimlik bilgilerini yerel dizininize
client_secrets.json
adlı bir JSON dosyası olarak kaydedin. - Chat uygulaması olarak kimlik doğrulamak için hizmet hesabı kimlik bilgileri oluşturun ve kimlik bilgilerini
credentials.json
adlı bir JSON dosyası olarak kaydedin.
- Chat kullanıcısı olarak kimlik doğrulamak için OAuth istemci kimliği kimlik bilgilerini oluşturun ve kimlik bilgilerini yerel dizininize
- Kullanıcı olarak mı yoksa Chat uygulaması olarak mı kimlik doğrulama yapmak istediğinize bağlı olarak bir yetkilendirme kapsamı seçin.
- Kimliği doğrulanmış kullanıcının veya Chat uygulamasını arayan kullanıcılar üye oldu. Chat uygulaması olarak kimlik doğrulama yapmak için Chat uygulamasını alana ekleyin.
Python
- Google Chat'e erişimi olan bir Business veya Enterprise Google Workspace hesabı
- Ortamınızı ayarlayın:
- Google Cloud projesi oluşturun.
- OAuth izin ekranını yapılandırın.
- Chat uygulamanız için bir ad, simge ve açıklamayla Google Chat API'yi etkinleştirip yapılandırın.
- Şunu yükleyin: Python Cloud İstemci Kitaplığı.
- Google Chat API isteğinizde kimliğinizi doğrulama yönteminize göre erişim kimlik bilgileri oluşturun:
- Chat kullanıcısı olarak kimliğinizi doğrulamak için:
OAuth istemci kimliği oluştur
kimlik bilgilerini iki kez tıklayın ve kimlik bilgilerini
client_secrets.json
dosyasını yerel dizininize ekleyin. - Chat uygulaması olarak kimlik doğrulamak için hizmet hesabı kimlik bilgileri oluşturun ve kimlik bilgilerini
credentials.json
adlı bir JSON dosyası olarak kaydedin.
- Chat kullanıcısı olarak kimliğinizi doğrulamak için:
OAuth istemci kimliği oluştur
kimlik bilgilerini iki kez tıklayın ve kimlik bilgilerini
- Kullanıcı olarak mı yoksa Chat uygulaması olarak mı kimlik doğrulama yapmak istediğinize bağlı olarak bir yetkilendirme kapsamı seçin.
- Kimliği doğrulanmış kullanıcının veya Chat uygulamasını arayan kullanıcılar üye oldu. Chat uygulaması olarak kimlik doğrulama yapmak için Chat uygulamasını alana ekleyin.
Java
- İşletme veya Kuruluş Şuna erişimi olan Google Workspace hesabı: Google Chat.
- Ortamınızı ayarlayın:
- Google Cloud projesi oluşturun.
- OAuth izin ekranını yapılandırın.
- Chat uygulamanız için bir ad, simge ve açıklamayla Google Chat API'yi etkinleştirip yapılandırın.
- Java Cloud İstemci Kitaplığı'nı yükleyin.
- Google Chat API isteğinizde kimliğinizi doğrulama yönteminize göre erişim kimlik bilgileri oluşturun:
- Chat kullanıcısı olarak kimliğinizi doğrulamak için:
OAuth istemci kimliği oluştur
kimlik bilgilerini iki kez tıklayın ve kimlik bilgilerini
client_secrets.json
dosyasını yerel dizininize ekleyin. - Chat uygulaması olarak kimliğinizi doğrulamak için:
hizmet hesabı oluştur
kimlik bilgilerini iki kez tıklayın ve kimlik bilgilerini
credentials.json
.
- Chat kullanıcısı olarak kimliğinizi doğrulamak için:
OAuth istemci kimliği oluştur
kimlik bilgilerini iki kez tıklayın ve kimlik bilgilerini
- Kimlik doğrulamasını kullanıcı olarak mı yoksa Chat uygulaması.
- Kimliği doğrulanmış kullanıcının veya Chat uygulamasını arayan kullanıcılar üye oldu. Chat uygulaması olarak kimlik doğrulama yapmak için Chat uygulamasını alana ekleyin.
Apps Komut Dosyası
- İşletme veya Kuruluş Şuna erişimi olan Google Workspace hesabı: Google Chat.
- Ortamınızı ayarlayın:
- Bir Google Cloud projesi oluşturun.
- OAuth izin ekranını yapılandırın.
- Google Chat API'yi etkinleştirin ve yapılandırın. Bunun için bir ad girin, Chat uygulamanızın simgesi ve açıklaması.
- Bağımsız bir Apps Komut Dosyası projesi oluşturun, ve Gelişmiş Sohbet Hizmeti'ni etkinleştirin.
- Bu kılavuzda kullanıcı veya uygulama kimlik doğrulamasını kullanmanız gerekir. Chat uygulaması olarak kimliğinizi doğrulamak için hizmet hesabı kimlik bilgileri. Adımlar için Google Chat uygulaması olarak kimlik doğrulama ve yetkilendirme başlıklı makaleyi inceleyin.
- Kimlik doğrulamasını kullanıcı olarak mı yoksa Chat uygulaması.
- Kimliği doğrulanmış kullanıcının veya arayan Chat uygulamasının üyesi olduğu bir Google Chat alanı. Chat uygulamasında Alana Chat uygulamasından ekleyin.
Kullanıcı kimlik doğrulaması yapılmış bir mesaj alma
Şununla bir mesajla ilgili ayrıntıları almak için: kullanıcı kimlik doğrulaması, isteğinizde aşağıdakileri iletin:
chat.messages.readonly
veyachat.messages
yetkilendirme kapsamını belirtin.GetMessage()
yöntemini çağırın.name
değerini, alınacak mesajın kaynak adı olarak ayarlayın.
Aşağıdaki örnekte, kullanıcı kimlik doğrulaması içeren bir mesaj alınır:
Node.js
Python
Java
Apps Komut Dosyası
Bu örneği çalıştırmak için aşağıdakileri değiştirin:
SPACE_NAME
: Alanınname
kimliği. Kimliği öğrenmek içinListSpaces()
yöntemini veya alanın URL'sini kullanın.MESSAGE_NAME
: İletininname
kimliği. Kimliği, aşağıdaki URL'yi oluşturduktan sonra döndürülen yanıt gövdesinden Chat API ile eşzamansız olarak veya özel ad , oluşturma sırasında mesaja atanır.
Chat API,
Message
öğesini tıklayın.
Uygulama kimlik doğrulaması içeren bir mesaj alma
Uygulama kimlik doğrulaması içeren bir mesajla ilgili ayrıntıları almak için isteğinizde aşağıdakileri iletin:
chat.bot
yetkilendirme kapsamını belirtin.GetMessage()
yöntemini çağırın.- Alınacak mesajın kaynak adına
name
değerini ayarlayın.
Aşağıdaki örnekte, uygulama kimlik doğrulaması içeren bir mesaj alınmaktadır:
Node.js
Python
Java
Apps Komut Dosyası
Bu örneği çalıştırmak için aşağıdaki kodu değiştirin:
SPACE_NAME
: Alanınname
kimliği. Kimliği öğrenmek içinListSpaces()
yöntemini veya alanın URL'sini kullanın.MESSAGE_NAME
: İletininname
bölümündeki kimlik. Kimliği, Chat API ile mesaj oluşturduktan sonra döndürülen yanıt gövdesinden veya mesaj oluşturulurken mesaja atanan özel addan elde edebilirsiniz.
Chat API,
Message
öğesini tıklayın.
İlgili konular
- Mesaj biçimlendirme
- Bir iletiyi silme.
- Bir alandaki mesajları listeleyin.
- Mesajları güncelleme
- Mesaj gönderin.