#chat #google #api-bindings #googlechat

google-chat-types

types collection of google chat response

3 releases

0.1.5 Jun 13, 2022
0.1.4 Jun 12, 2022

#1943 in Development tools

MIT license

46KB
231 lines

Google Chat Types

type helper for construct Google Chat message

About Google Chat Message

There two type of Google Chat message

  • Text Message
  • Card Message

they are all represented as a json string.

Text Message represented like

{
  "text": "some text"
}

Card Message represented like

{
  "cards": [
    {
      "sections": [
        {
          "widgets": [
            {
              "image": { "imageUrl": "https://..." }
            },
            {
              "buttons": [
                {
                  "textButton": {
                    "text": "OPEN IN GOOGLE MAPS",
                    "onClick": {
                      "openLink": {
                        "url": "https://..."
                      }
                    }
                  }
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

the relationship between elements of cards should looks like below

Alt text

How to use this crate

you should construct Cards or Text struct, then serialize them to json string as a Google Chat API(for instance incoming webhook) http request body.

Dependencies

~2.5MB
~51K SLoC