PARALLAX

google_chat

Send Google Chat notifications

Collection: community.general

Full Name: community.general.google_chat

Synopsis

Send Google Chat notifications

Parameters

NameTypeRequiredDefaultDescription
create_new_threadbooltrueControls behavior when O(thread_key) is set but no matching thread exists. When V(true), a new thread is started if no matching thread is found. When V(false), the message is only posted if a matching thread already exists, otherwise it fails. Only used when O(thread_key) is set.
keystringyesThe C(key) request parameter from the incoming webhook URL. Keep this value secret as it grants the ability to post to the space.
spacestringyesThe identifier of the Chat space to post to, taken from the incoming webhook URL. For a webhook URL of the form C(https://chat.googleapis.com/v1/spaces/AAAA/messages?key=...&token=...), this is the C(AAAA) part.
textstringyesThe text of the message to send. Emoji must be supplied as Unicode characters (for example V(πŸš€)). The Chat API does not render C(:shortcode:) style emoji in plain text messages as they appear as literal text.
thread_keystringAn arbitrary key used to start or reply to a message thread. When set, O(create_new_thread) controls the behavior when the thread is not found.
tokenstringyesThe C(token) request parameter from the incoming webhook URL. Keep this value secret as it grants the ability to post to the space.

Example

yaml
- name: Send a notification to Google Chat
  community.general.google_chat:
    space: SPACE_ID
    key: KEY
    token: TOKEN
    text: '{{ inventory_hostname }} completed'
  delegate_to: localhost

- name: Start a thread
  community.general.google_chat:
    space: SPACE_ID
    key: KEY
    token: TOKEN
    text: 'Starting a thread'
    thread_key: 'deploy-2026-06-01'
    create_new_thread: true

# Post each deploy step into a single thread. The first message creates the thread
# with create_new_thread=true. Follow-ups use create_new_thread=false so they only
# post if the opening message went through, rather than leaving orphan threads.
# Note: webhooks are rate-limited to 1 request per second per space.
- name: Announce deploy start (starts the thread)
  community.general.google_chat:
    space: "{{ chat_space }}"
    key: "{{ chat_key }}"
    token: "{{ chat_token }}"
    text: "\U0001F680 Starting deploy of *{{ app_version | default('latest') }}* to {{ inventory_hostname }}"
    thread_key: "{{ deploy_thread }}"
    create_new_thread: true
  delegate_to: localhost
  run_once: true
  # deploy_thread is defined once for the play, for example:
  #   deploy_thread: "deploy-{{ inventory_hostname }}-{{ ansible_date_time.iso8601_basic_short }}"

- name: Report a step into the same thread
  community.general.google_chat:
    space: "{{ chat_space }}"
    key: "{{ chat_key }}"
    token: "{{ chat_token }}"
    text: "βœ… Step 1/3 – code checked out"
    thread_key: "{{ deploy_thread }}"
    create_new_thread: false
  delegate_to: localhost
  run_once: true

- community.general.google_chat:
    create_new_thread: false
    key: '{{ chat_key }}'
    space: '{{ chat_space }}'
    text: "\U0001F389 Deploy to {{ inventory_hostname }} complete"
    thread_key: '{{ deploy_thread }}'
    token: '{{ chat_token }}'
  delegate_to: localhost
  name: Report success
  run_once: true

- community.general.google_chat:
    create_new_thread: false
    key: '{{ chat_key }}'
    space: '{{ chat_space }}'
    text: ❌ Deploy to {{ inventory_hostname }} *failed* – {{ ansible_failed_task.name }}
    thread_key: '{{ deploy_thread }}'
    token: '{{ chat_token }}'
  delegate_to: localhost
  name: Report failure into the thread
  run_once: true
Search
    ↑ ↓ move↡ openesc close