Navigation

Send a chat to a Google chat room using cURL

You can send messages to Google chat rooms by invoking Google API with necessary permissions. This will guide you to send such messages to Google chat rooms simply using a 'curl' command.

Prerequisites

  • Webhook URL for a Google chat room.
  • Access to a terminal with 'curl' installed.

Steps to be followed

1. Generate a webhook URL for the required Google chat room. 
  1. Click on the chat room name and select Manage webhooks.



  2. Provide a name to the Webhook in the Name field. Then, click on Save. (Avatar URL is optional and you can put a link to an icon that you need to show as the sender's avatar)



  3. Once the URL is generated, copy the URL.

  4. Then use the following code snippet to send the message to the chat room.

    GOOGLE_CHAT_URL="<copied-url>"
    curl \
    -X POST \
    -H 'Content-Type: application/json' \
    "${GOOGLE_CHAT_URL}" \
    -d '{"text": "Hello from Witcentre!"}'
    You can see a new chat in your chat room. Following is a sample message received.     







Share

WitCentre

Post A Comment:

0 comments: