No version for distro humble. Known supported distros are highlighted in the buttons above.
No version for distro galactic. Known supported distros are highlighted in the buttons above.
No version for distro foxy. Known supported distros are highlighted in the buttons above.
No version for distro rolling. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 2.1.25
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/jsk-ros-pkg/jsk_3rdparty.git
VCS Type git
VCS Version master
Last Updated 2022-11-12
Dev Status DEVELOPED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

Use Google Chat API clients via ROS

Additional Links

No additional links.

Maintainers

  • Kei Okada

Authors

  • Yoshiki Obinata

Google Chat ROS

The ROS wrapper for Google Chat API 1. Installation Guide 1. Sending the message 1. Receiving the message 1. Handling the event 1. Optional functions 1. Helper nodes

1. Installation Guide

1.1 Get the API KEY

At first, you should have the permission to access the Google Chat API. See Google Official Document. Please ensure to get JSON credetial file and save it. DO NOT LOST IT!
For JSK members, all keys are available at Google Drive. If you make new API keys, please upload them here.

1.2 Select the way how to recieve Google Chat event

The way you recieve Google Chat event from API server depends on your system. If your system has static IP and is allowed to recieve https request with specific port, please see HTTPS mode. If not, please see Pub/Sub mode.

HTTPS mode

When you send the message, the node uses Google REST API. When you recieve the message, Google Chat API sends https request to your machine and the node handles it.

google_chat_https_system

You have to prepare SSL certificate. Self-signed one is not available because of Google security issue. Please use the service like Let's Encrypt. In Google Cloud console, please choose App URL as connection settings and fill the URL in the App URL form.

google_chat_https

Pub/Sub mode

When you send the message, the node uses Google REST API. When you recieve the message, the node uses Google Pub/Sub API's subscription. The node has already established its connection to Google Pub/Sub API when you launch it.

google_chat_pubsub_system

The way how to set up in Google Cloud console shows below.

1. Authorize the existing Google Chat API project to access Google Cloud Pub/Sub service

In IAM settings in the console, please add the role Pub/Sub Admin to service account.

pubsub_admin_mosaic

2. Create Pub/Sub topic and subscriber

In Pub/Sub settings in the console, please add the topic and subscriptions. In the figure, we set the topic name chat, the subscription name chat-sub as an example.

pubsub_topic_mosaic

pubsub_subscription

Note that if you set the topic name chat, the full name of it becomes projects/<project_name>/topics/chat. Please confirm the subsciptions subscribes the full name not short one.

3. Grant publish rigts on your topic

In order for Google Chat to publish messages to your topic, it must have publishing rights to the topic. To grant Google Chat these permissions, assign the Pub/Sub Publisher role to the following service account

chat-api-push@system.gserviceaccount.com

google_chat_pubsub_permission

4. Set Google Chat API Connection settings

Please choose Cloud Pub/Sub as connection settings and fill the full topic name in the Topic Name form.

google_chat_pubsub

1.3 Install/Build the ROS node

If you want to build from the source

source /opt/ros/${ROS_DISTRO}/setup.bash
mkdir -p ~/catkin_ws/src && cd ~/catkin_ws/src
git clone https://github.com/jsk-ros-pkg/jsk_3rdparty
rosdep install --ignore-src --from-paths . -y -r
cd ..
catkin build

1.4 Launch the node

HTTPS mode

You have to set rosparams receiving_mode=https, google_cloud_credentials_json, host, port, ssl_certfile, ssl_keyfile.

Pub/Sub mode

You have to set rosparams receiving_mode=pubsub, google_cloud_credentials_json, project_id, subscription_id. subscription_id would be chat-sub if you follow Pub/Sub mode example.

Example
roslaunch google_chat_ros google_chat.launch receiving_mode:=pubsub google_cloud_credentials_json:=/path/to/<project_id>-XXXXXXXX.json project_id:=<project_id> subscription_id:=chat-sub

2. Sending the message

2.1 Understanding Google Chat Room

When you see Google Chat UI with browsers or smartphone's apps, you may see space, thread. If you send new message, you must specify the space or thread you want to send the message to. You can get the space name from chat room's URL. If it is https://mail.google.com/chat/u/0/#chat/space/XXXXXXXXXXX, XXXXXXXXXXX becomes the space name.

2.2 Message format

There are 2 types of messages, text and card. The card basically follows the original json structure. As the node covers all the units in here with ros action msgs, it may be complicated for you if you want to use all of them. So in Examples sections, we'll show you simple ones.

2.3 Sending the message by actionlib

All you have to do is send Actionlib goal to ~send/goal.

2.4 Examples

Showing the message examples with rostopic pub -1 command on bash.

Sending a text message

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  text: 'Hello!'
  space: 'spaces/<space name>'"

google_chat_text

Sending a message with KeyValue card

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  text: 'Something FATAL errors have happened in my computer, please fix ASAP'
  cards:
    -
      sections:
        -
          widgets:
            -
              key_value:
                top_label: 'Process ID'
                content: '1234'
                bottom_label: 'rospy'
                icon: 'DESCRIPTION'
  space: 'spaces/<space name>'"

google_chat_keyvalue

Sending an Interactive button

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      header:
        title: 'What do you want to eat?'
        subtitle: 'Please choose the food shop!'
      sections:
        -
          widgets:
            -
              buttons:
                -
                  text_button_name: 'STARBUCKS'
                  text_button_on_click:
                    action:
                      action_method_name: 'vote_starbucks'
                      parameters:
                        -
                          key: 'shop'
                          value: 'starbucks'
                -
                  text_button_name: 'SUBWAY'
                  text_button_on_click:
                    action:
                      action_method_name: 'vote_subway'
                      parameters:
                        -
                          key: 'shop'
                          value: 'subway'

  space: 'spaces/<space name>'"

google_chat_interactive_button

Sending a message with an image

See Here.

3. Receiving the messages

3.1 ROS Topic

When the bot was mentioned, the node publishes ~message_activity topic.

3.2 Examples

Receiving a text message

event_time: "2022-04-28T06:25:26.884623Z"
space:
  name: "spaces/<space name>"
  display_name: ''
  room: False
  dm: True
message:
  name: "spaces/<space name>/messages/<message id>"
  sender:
    name: "users/<user id>"
    display_name: "Yoshiki Obinata"
    avatar_url: "<avatar url>"
    avatar: []
    email: "<email>"
    bot: False
    human: True
  create_time: "2022-04-28T06:25:26.884623Z"
  text: "Hello!"
  thread_name: "spaces/<space name>/threads/<thread name>"
  annotations: []
  argument_text: "Hello!"
  attachments: []
user:
  name: "users/<user id>"
  display_name: "Yoshiki Obinata"
  avatar_url: "<avatar url>"
  avatar: []
  email: "<email>"
  bot: False
  human: True

Receiving a message with an image or gdrive file and download it

4. Handling the interactive event

If you've already sent the interactive card like Interactive card example, you can receive the activity of buttons. Suppose someone pressed the button STARBUCKS, the node publishes a ~card_activity topic like

event_time: "2022-05-02T00:23:47.855023Z"
space:
  name: "spaces/<space name>"
  display_name: "robotroom_with_thread"
  room: True
  dm: False
message:
  name: "spaces/<space name>/messages/Go__sDfIdec.Go__sDfIdec"
  sender:
    name: "users/100406614699672138585"
    display_name: "Fetch1075"
    avatar_url: "https://lh4.googleusercontent.com/proxy/hWEAWt6fmHsFAzeiEoV5FMOx5-jmU3OnzQxCtrr9unyt73NNwv0lh7InFzOh-0yO3jOPgtColHBywnZnJvl4SVqqqrYkyT1uf18k_hDIVYrAv87AY7lM0hp5KtQ1m9br-aPFE98QwNnSTYc2LQ"
    avatar: []
    email: ''
    bot: True
    human: False
  create_time: "2022-05-02T00:23:47.855023Z"
  text: ''
  thread_name: "spaces/<space name>/threads/Go__sDfIdec"
  annotations: []
  argument_text: ''
  attachments: []
user:
  name: "users/103866924487978823908"
  display_name: "Yoshiki Obinata"
  avatar_url: "https://lh3.googleusercontent.com/a-/AOh14GgexXiq8ImuKMgOq6QG-4geIzz5IC1-xa0Caead=k"
  avatar: []
  email: "<your email>"
  bot: False
  human: True
action:
  action_method_name: "vote_starbucks"
  parameters:
    -
      key: "shop"
      value: "starbucks"

After the node which handles the chat event subscribed the topic, it can respond with text message like

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      sections:
        -
          widgets:
            -
              key_value:
                top_label: 'The shop accepted!'
                content: 'You choose STARBUCKS!!'
                icon: 'DESCRIPTION'
  space: 'spaces/<space name>'
  thread_name: 'spaces/<space name>/threads/<thread name>'"

google_chat_interact

The important point is that the client node has to remember the thread_name which the card event was occured at and send response to it.

5. Optional functions

5.1 Sending a message with an image

To send an image, you have to use card type message. If you want to add the image uploaded to a storage server available for everyone, you just add its URI like

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      sections:
        -
          widgets:
            -
              image:
                image_url: 'https://media-cdn.tripadvisor.com/media/photo-s/11/fb/90/e4/dsc-7314-largejpg.jpg'
  space: 'spaces/<your space>'"

If you want to attach image saved at your host, you have to launch (gdrive_ros)[https://github.com/jsk-ros-pkg/jsk_3rdparty/tree/master/gdrive_ros] at first and set ~gdrive_upload_service param with gdrive_ros/Upload service name. Then publish topic like

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      sections:
        -
          widgets:
            -
              image:
                localpath: '/home/user/Pictures/image.png'
  space: 'spaces/<your space>'

5.2 Receiving a message with images or gdrive file

You have to set rosparam ~download_data True, ~download_directory. If the node recieved the message with image or google drive file, it automatically downloads to ~donwload_directory path.

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

See ROS Wiki Tutorials for more details.

Source Tutorials

Not currently indexed.

Launch files

  • launch/google_chat.launch
      • receiving_mode [default: url] — Google Chat API settings. Choose from url, dialogflow, pubsub, none.
      • gdrive_upload_service [default: /gdrive_ros/upload] — The ROS service name of gdrive_ros upload
      • upload_data_timeout [default: 20]
      • download_data [default: true]
      • download_data_timeout [default: 10]
      • download_directory [default: /tmp]
      • download_avatar [default: false]
      • google_cloud_credentials_json [default: ]
      • use_yaml [default: false] — Whether you use yaml file or not.
      • yaml_file [default: ] — Yaml file of web settings.
      • respawn [default: true]
      • host [default: localhost]
      • port [default: 443]
      • ssl_certfile [default: default]
      • ssl_keyfile [default: default]
      • project_id [default: default]
      • subscription_id [default: default]
      • use_helper [default: true]
      • to_dialogflow_client [default: false]
      • debug_sound [default: false]

Services

No service files found

Plugins

No plugins found.

Recent questions tagged google_chat_ros at answers.ros.org

Package Summary

Tags No category tags.
Version 2.1.25
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/jsk-ros-pkg/jsk_3rdparty.git
VCS Type git
VCS Version master
Last Updated 2022-11-12
Dev Status DEVELOPED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

Use Google Chat API clients via ROS

Additional Links

No additional links.

Maintainers

  • Kei Okada

Authors

  • Yoshiki Obinata

Google Chat ROS

The ROS wrapper for Google Chat API 1. Installation Guide 1. Sending the message 1. Receiving the message 1. Handling the event 1. Optional functions 1. Helper nodes

1. Installation Guide

1.1 Get the API KEY

At first, you should have the permission to access the Google Chat API. See Google Official Document. Please ensure to get JSON credetial file and save it. DO NOT LOST IT!
For JSK members, all keys are available at Google Drive. If you make new API keys, please upload them here.

1.2 Select the way how to recieve Google Chat event

The way you recieve Google Chat event from API server depends on your system. If your system has static IP and is allowed to recieve https request with specific port, please see HTTPS mode. If not, please see Pub/Sub mode.

HTTPS mode

When you send the message, the node uses Google REST API. When you recieve the message, Google Chat API sends https request to your machine and the node handles it.

google_chat_https_system

You have to prepare SSL certificate. Self-signed one is not available because of Google security issue. Please use the service like Let's Encrypt. In Google Cloud console, please choose App URL as connection settings and fill the URL in the App URL form.

google_chat_https

Pub/Sub mode

When you send the message, the node uses Google REST API. When you recieve the message, the node uses Google Pub/Sub API's subscription. The node has already established its connection to Google Pub/Sub API when you launch it.

google_chat_pubsub_system

The way how to set up in Google Cloud console shows below.

1. Authorize the existing Google Chat API project to access Google Cloud Pub/Sub service

In IAM settings in the console, please add the role Pub/Sub Admin to service account.

pubsub_admin_mosaic

2. Create Pub/Sub topic and subscriber

In Pub/Sub settings in the console, please add the topic and subscriptions. In the figure, we set the topic name chat, the subscription name chat-sub as an example.

pubsub_topic_mosaic

pubsub_subscription

Note that if you set the topic name chat, the full name of it becomes projects/<project_name>/topics/chat. Please confirm the subsciptions subscribes the full name not short one.

3. Grant publish rigts on your topic

In order for Google Chat to publish messages to your topic, it must have publishing rights to the topic. To grant Google Chat these permissions, assign the Pub/Sub Publisher role to the following service account

chat-api-push@system.gserviceaccount.com

google_chat_pubsub_permission

4. Set Google Chat API Connection settings

Please choose Cloud Pub/Sub as connection settings and fill the full topic name in the Topic Name form.

google_chat_pubsub

1.3 Install/Build the ROS node

If you want to build from the source

source /opt/ros/${ROS_DISTRO}/setup.bash
mkdir -p ~/catkin_ws/src && cd ~/catkin_ws/src
git clone https://github.com/jsk-ros-pkg/jsk_3rdparty
rosdep install --ignore-src --from-paths . -y -r
cd ..
catkin build

1.4 Launch the node

HTTPS mode

You have to set rosparams receiving_mode=https, google_cloud_credentials_json, host, port, ssl_certfile, ssl_keyfile.

Pub/Sub mode

You have to set rosparams receiving_mode=pubsub, google_cloud_credentials_json, project_id, subscription_id. subscription_id would be chat-sub if you follow Pub/Sub mode example.

Example
roslaunch google_chat_ros google_chat.launch receiving_mode:=pubsub google_cloud_credentials_json:=/path/to/<project_id>-XXXXXXXX.json project_id:=<project_id> subscription_id:=chat-sub

2. Sending the message

2.1 Understanding Google Chat Room

When you see Google Chat UI with browsers or smartphone's apps, you may see space, thread. If you send new message, you must specify the space or thread you want to send the message to. You can get the space name from chat room's URL. If it is https://mail.google.com/chat/u/0/#chat/space/XXXXXXXXXXX, XXXXXXXXXXX becomes the space name.

2.2 Message format

There are 2 types of messages, text and card. The card basically follows the original json structure. As the node covers all the units in here with ros action msgs, it may be complicated for you if you want to use all of them. So in Examples sections, we'll show you simple ones.

2.3 Sending the message by actionlib

All you have to do is send Actionlib goal to ~send/goal.

2.4 Examples

Showing the message examples with rostopic pub -1 command on bash.

Sending a text message

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  text: 'Hello!'
  space: 'spaces/<space name>'"

google_chat_text

Sending a message with KeyValue card

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  text: 'Something FATAL errors have happened in my computer, please fix ASAP'
  cards:
    -
      sections:
        -
          widgets:
            -
              key_value:
                top_label: 'Process ID'
                content: '1234'
                bottom_label: 'rospy'
                icon: 'DESCRIPTION'
  space: 'spaces/<space name>'"

google_chat_keyvalue

Sending an Interactive button

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      header:
        title: 'What do you want to eat?'
        subtitle: 'Please choose the food shop!'
      sections:
        -
          widgets:
            -
              buttons:
                -
                  text_button_name: 'STARBUCKS'
                  text_button_on_click:
                    action:
                      action_method_name: 'vote_starbucks'
                      parameters:
                        -
                          key: 'shop'
                          value: 'starbucks'
                -
                  text_button_name: 'SUBWAY'
                  text_button_on_click:
                    action:
                      action_method_name: 'vote_subway'
                      parameters:
                        -
                          key: 'shop'
                          value: 'subway'

  space: 'spaces/<space name>'"

google_chat_interactive_button

Sending a message with an image

See Here.

3. Receiving the messages

3.1 ROS Topic

When the bot was mentioned, the node publishes ~message_activity topic.

3.2 Examples

Receiving a text message

event_time: "2022-04-28T06:25:26.884623Z"
space:
  name: "spaces/<space name>"
  display_name: ''
  room: False
  dm: True
message:
  name: "spaces/<space name>/messages/<message id>"
  sender:
    name: "users/<user id>"
    display_name: "Yoshiki Obinata"
    avatar_url: "<avatar url>"
    avatar: []
    email: "<email>"
    bot: False
    human: True
  create_time: "2022-04-28T06:25:26.884623Z"
  text: "Hello!"
  thread_name: "spaces/<space name>/threads/<thread name>"
  annotations: []
  argument_text: "Hello!"
  attachments: []
user:
  name: "users/<user id>"
  display_name: "Yoshiki Obinata"
  avatar_url: "<avatar url>"
  avatar: []
  email: "<email>"
  bot: False
  human: True

Receiving a message with an image or gdrive file and download it

4. Handling the interactive event

If you've already sent the interactive card like Interactive card example, you can receive the activity of buttons. Suppose someone pressed the button STARBUCKS, the node publishes a ~card_activity topic like

event_time: "2022-05-02T00:23:47.855023Z"
space:
  name: "spaces/<space name>"
  display_name: "robotroom_with_thread"
  room: True
  dm: False
message:
  name: "spaces/<space name>/messages/Go__sDfIdec.Go__sDfIdec"
  sender:
    name: "users/100406614699672138585"
    display_name: "Fetch1075"
    avatar_url: "https://lh4.googleusercontent.com/proxy/hWEAWt6fmHsFAzeiEoV5FMOx5-jmU3OnzQxCtrr9unyt73NNwv0lh7InFzOh-0yO3jOPgtColHBywnZnJvl4SVqqqrYkyT1uf18k_hDIVYrAv87AY7lM0hp5KtQ1m9br-aPFE98QwNnSTYc2LQ"
    avatar: []
    email: ''
    bot: True
    human: False
  create_time: "2022-05-02T00:23:47.855023Z"
  text: ''
  thread_name: "spaces/<space name>/threads/Go__sDfIdec"
  annotations: []
  argument_text: ''
  attachments: []
user:
  name: "users/103866924487978823908"
  display_name: "Yoshiki Obinata"
  avatar_url: "https://lh3.googleusercontent.com/a-/AOh14GgexXiq8ImuKMgOq6QG-4geIzz5IC1-xa0Caead=k"
  avatar: []
  email: "<your email>"
  bot: False
  human: True
action:
  action_method_name: "vote_starbucks"
  parameters:
    -
      key: "shop"
      value: "starbucks"

After the node which handles the chat event subscribed the topic, it can respond with text message like

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      sections:
        -
          widgets:
            -
              key_value:
                top_label: 'The shop accepted!'
                content: 'You choose STARBUCKS!!'
                icon: 'DESCRIPTION'
  space: 'spaces/<space name>'
  thread_name: 'spaces/<space name>/threads/<thread name>'"

google_chat_interact

The important point is that the client node has to remember the thread_name which the card event was occured at and send response to it.

5. Optional functions

5.1 Sending a message with an image

To send an image, you have to use card type message. If you want to add the image uploaded to a storage server available for everyone, you just add its URI like

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      sections:
        -
          widgets:
            -
              image:
                image_url: 'https://media-cdn.tripadvisor.com/media/photo-s/11/fb/90/e4/dsc-7314-largejpg.jpg'
  space: 'spaces/<your space>'"

If you want to attach image saved at your host, you have to launch (gdrive_ros)[https://github.com/jsk-ros-pkg/jsk_3rdparty/tree/master/gdrive_ros] at first and set ~gdrive_upload_service param with gdrive_ros/Upload service name. Then publish topic like

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      sections:
        -
          widgets:
            -
              image:
                localpath: '/home/user/Pictures/image.png'
  space: 'spaces/<your space>'

5.2 Receiving a message with images or gdrive file

You have to set rosparam ~download_data True, ~download_directory. If the node recieved the message with image or google drive file, it automatically downloads to ~donwload_directory path.

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

See ROS Wiki Tutorials for more details.

Source Tutorials

Not currently indexed.

Launch files

  • launch/google_chat.launch
      • receiving_mode [default: url] — Google Chat API settings. Choose from url, dialogflow, pubsub, none.
      • gdrive_upload_service [default: /gdrive_ros/upload] — The ROS service name of gdrive_ros upload
      • upload_data_timeout [default: 20]
      • download_data [default: true]
      • download_data_timeout [default: 10]
      • download_directory [default: /tmp]
      • download_avatar [default: false]
      • google_cloud_credentials_json [default: ]
      • use_yaml [default: false] — Whether you use yaml file or not.
      • yaml_file [default: ] — Yaml file of web settings.
      • respawn [default: true]
      • host [default: localhost]
      • port [default: 443]
      • ssl_certfile [default: default]
      • ssl_keyfile [default: default]
      • project_id [default: default]
      • subscription_id [default: default]
      • use_helper [default: true]
      • to_dialogflow_client [default: false]
      • debug_sound [default: false]

Services

No service files found

Plugins

No plugins found.

Recent questions tagged google_chat_ros at answers.ros.org

No version for distro ardent. Known supported distros are highlighted in the buttons above.
No version for distro bouncy. Known supported distros are highlighted in the buttons above.
No version for distro crystal. Known supported distros are highlighted in the buttons above.
No version for distro eloquent. Known supported distros are highlighted in the buttons above.
No version for distro dashing. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 2.1.25
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/jsk-ros-pkg/jsk_3rdparty.git
VCS Type git
VCS Version master
Last Updated 2022-11-12
Dev Status DEVELOPED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

Use Google Chat API clients via ROS

Additional Links

No additional links.

Maintainers

  • Kei Okada

Authors

  • Yoshiki Obinata

Google Chat ROS

The ROS wrapper for Google Chat API 1. Installation Guide 1. Sending the message 1. Receiving the message 1. Handling the event 1. Optional functions 1. Helper nodes

1. Installation Guide

1.1 Get the API KEY

At first, you should have the permission to access the Google Chat API. See Google Official Document. Please ensure to get JSON credetial file and save it. DO NOT LOST IT!
For JSK members, all keys are available at Google Drive. If you make new API keys, please upload them here.

1.2 Select the way how to recieve Google Chat event

The way you recieve Google Chat event from API server depends on your system. If your system has static IP and is allowed to recieve https request with specific port, please see HTTPS mode. If not, please see Pub/Sub mode.

HTTPS mode

When you send the message, the node uses Google REST API. When you recieve the message, Google Chat API sends https request to your machine and the node handles it.

google_chat_https_system

You have to prepare SSL certificate. Self-signed one is not available because of Google security issue. Please use the service like Let's Encrypt. In Google Cloud console, please choose App URL as connection settings and fill the URL in the App URL form.

google_chat_https

Pub/Sub mode

When you send the message, the node uses Google REST API. When you recieve the message, the node uses Google Pub/Sub API's subscription. The node has already established its connection to Google Pub/Sub API when you launch it.

google_chat_pubsub_system

The way how to set up in Google Cloud console shows below.

1. Authorize the existing Google Chat API project to access Google Cloud Pub/Sub service

In IAM settings in the console, please add the role Pub/Sub Admin to service account.

pubsub_admin_mosaic

2. Create Pub/Sub topic and subscriber

In Pub/Sub settings in the console, please add the topic and subscriptions. In the figure, we set the topic name chat, the subscription name chat-sub as an example.

pubsub_topic_mosaic

pubsub_subscription

Note that if you set the topic name chat, the full name of it becomes projects/<project_name>/topics/chat. Please confirm the subsciptions subscribes the full name not short one.

3. Grant publish rigts on your topic

In order for Google Chat to publish messages to your topic, it must have publishing rights to the topic. To grant Google Chat these permissions, assign the Pub/Sub Publisher role to the following service account

chat-api-push@system.gserviceaccount.com

google_chat_pubsub_permission

4. Set Google Chat API Connection settings

Please choose Cloud Pub/Sub as connection settings and fill the full topic name in the Topic Name form.

google_chat_pubsub

1.3 Install/Build the ROS node

If you want to build from the source

source /opt/ros/${ROS_DISTRO}/setup.bash
mkdir -p ~/catkin_ws/src && cd ~/catkin_ws/src
git clone https://github.com/jsk-ros-pkg/jsk_3rdparty
rosdep install --ignore-src --from-paths . -y -r
cd ..
catkin build

1.4 Launch the node

HTTPS mode

You have to set rosparams receiving_mode=https, google_cloud_credentials_json, host, port, ssl_certfile, ssl_keyfile.

Pub/Sub mode

You have to set rosparams receiving_mode=pubsub, google_cloud_credentials_json, project_id, subscription_id. subscription_id would be chat-sub if you follow Pub/Sub mode example.

Example
roslaunch google_chat_ros google_chat.launch receiving_mode:=pubsub google_cloud_credentials_json:=/path/to/<project_id>-XXXXXXXX.json project_id:=<project_id> subscription_id:=chat-sub

2. Sending the message

2.1 Understanding Google Chat Room

When you see Google Chat UI with browsers or smartphone's apps, you may see space, thread. If you send new message, you must specify the space or thread you want to send the message to. You can get the space name from chat room's URL. If it is https://mail.google.com/chat/u/0/#chat/space/XXXXXXXXXXX, XXXXXXXXXXX becomes the space name.

2.2 Message format

There are 2 types of messages, text and card. The card basically follows the original json structure. As the node covers all the units in here with ros action msgs, it may be complicated for you if you want to use all of them. So in Examples sections, we'll show you simple ones.

2.3 Sending the message by actionlib

All you have to do is send Actionlib goal to ~send/goal.

2.4 Examples

Showing the message examples with rostopic pub -1 command on bash.

Sending a text message

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  text: 'Hello!'
  space: 'spaces/<space name>'"

google_chat_text

Sending a message with KeyValue card

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  text: 'Something FATAL errors have happened in my computer, please fix ASAP'
  cards:
    -
      sections:
        -
          widgets:
            -
              key_value:
                top_label: 'Process ID'
                content: '1234'
                bottom_label: 'rospy'
                icon: 'DESCRIPTION'
  space: 'spaces/<space name>'"

google_chat_keyvalue

Sending an Interactive button

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      header:
        title: 'What do you want to eat?'
        subtitle: 'Please choose the food shop!'
      sections:
        -
          widgets:
            -
              buttons:
                -
                  text_button_name: 'STARBUCKS'
                  text_button_on_click:
                    action:
                      action_method_name: 'vote_starbucks'
                      parameters:
                        -
                          key: 'shop'
                          value: 'starbucks'
                -
                  text_button_name: 'SUBWAY'
                  text_button_on_click:
                    action:
                      action_method_name: 'vote_subway'
                      parameters:
                        -
                          key: 'shop'
                          value: 'subway'

  space: 'spaces/<space name>'"

google_chat_interactive_button

Sending a message with an image

See Here.

3. Receiving the messages

3.1 ROS Topic

When the bot was mentioned, the node publishes ~message_activity topic.

3.2 Examples

Receiving a text message

event_time: "2022-04-28T06:25:26.884623Z"
space:
  name: "spaces/<space name>"
  display_name: ''
  room: False
  dm: True
message:
  name: "spaces/<space name>/messages/<message id>"
  sender:
    name: "users/<user id>"
    display_name: "Yoshiki Obinata"
    avatar_url: "<avatar url>"
    avatar: []
    email: "<email>"
    bot: False
    human: True
  create_time: "2022-04-28T06:25:26.884623Z"
  text: "Hello!"
  thread_name: "spaces/<space name>/threads/<thread name>"
  annotations: []
  argument_text: "Hello!"
  attachments: []
user:
  name: "users/<user id>"
  display_name: "Yoshiki Obinata"
  avatar_url: "<avatar url>"
  avatar: []
  email: "<email>"
  bot: False
  human: True

Receiving a message with an image or gdrive file and download it

4. Handling the interactive event

If you've already sent the interactive card like Interactive card example, you can receive the activity of buttons. Suppose someone pressed the button STARBUCKS, the node publishes a ~card_activity topic like

event_time: "2022-05-02T00:23:47.855023Z"
space:
  name: "spaces/<space name>"
  display_name: "robotroom_with_thread"
  room: True
  dm: False
message:
  name: "spaces/<space name>/messages/Go__sDfIdec.Go__sDfIdec"
  sender:
    name: "users/100406614699672138585"
    display_name: "Fetch1075"
    avatar_url: "https://lh4.googleusercontent.com/proxy/hWEAWt6fmHsFAzeiEoV5FMOx5-jmU3OnzQxCtrr9unyt73NNwv0lh7InFzOh-0yO3jOPgtColHBywnZnJvl4SVqqqrYkyT1uf18k_hDIVYrAv87AY7lM0hp5KtQ1m9br-aPFE98QwNnSTYc2LQ"
    avatar: []
    email: ''
    bot: True
    human: False
  create_time: "2022-05-02T00:23:47.855023Z"
  text: ''
  thread_name: "spaces/<space name>/threads/Go__sDfIdec"
  annotations: []
  argument_text: ''
  attachments: []
user:
  name: "users/103866924487978823908"
  display_name: "Yoshiki Obinata"
  avatar_url: "https://lh3.googleusercontent.com/a-/AOh14GgexXiq8ImuKMgOq6QG-4geIzz5IC1-xa0Caead=k"
  avatar: []
  email: "<your email>"
  bot: False
  human: True
action:
  action_method_name: "vote_starbucks"
  parameters:
    -
      key: "shop"
      value: "starbucks"

After the node which handles the chat event subscribed the topic, it can respond with text message like

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      sections:
        -
          widgets:
            -
              key_value:
                top_label: 'The shop accepted!'
                content: 'You choose STARBUCKS!!'
                icon: 'DESCRIPTION'
  space: 'spaces/<space name>'
  thread_name: 'spaces/<space name>/threads/<thread name>'"

google_chat_interact

The important point is that the client node has to remember the thread_name which the card event was occured at and send response to it.

5. Optional functions

5.1 Sending a message with an image

To send an image, you have to use card type message. If you want to add the image uploaded to a storage server available for everyone, you just add its URI like

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      sections:
        -
          widgets:
            -
              image:
                image_url: 'https://media-cdn.tripadvisor.com/media/photo-s/11/fb/90/e4/dsc-7314-largejpg.jpg'
  space: 'spaces/<your space>'"

If you want to attach image saved at your host, you have to launch (gdrive_ros)[https://github.com/jsk-ros-pkg/jsk_3rdparty/tree/master/gdrive_ros] at first and set ~gdrive_upload_service param with gdrive_ros/Upload service name. Then publish topic like

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      sections:
        -
          widgets:
            -
              image:
                localpath: '/home/user/Pictures/image.png'
  space: 'spaces/<your space>'

5.2 Receiving a message with images or gdrive file

You have to set rosparam ~download_data True, ~download_directory. If the node recieved the message with image or google drive file, it automatically downloads to ~donwload_directory path.

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

See ROS Wiki Tutorials for more details.

Source Tutorials

Not currently indexed.

Launch files

  • launch/google_chat.launch
      • receiving_mode [default: url] — Google Chat API settings. Choose from url, dialogflow, pubsub, none.
      • gdrive_upload_service [default: /gdrive_ros/upload] — The ROS service name of gdrive_ros upload
      • upload_data_timeout [default: 20]
      • download_data [default: true]
      • download_data_timeout [default: 10]
      • download_directory [default: /tmp]
      • download_avatar [default: false]
      • google_cloud_credentials_json [default: ]
      • use_yaml [default: false] — Whether you use yaml file or not.
      • yaml_file [default: ] — Yaml file of web settings.
      • respawn [default: true]
      • host [default: localhost]
      • port [default: 443]
      • ssl_certfile [default: default]
      • ssl_keyfile [default: default]
      • project_id [default: default]
      • subscription_id [default: default]
      • use_helper [default: true]
      • to_dialogflow_client [default: false]
      • debug_sound [default: false]

Services

No service files found

Plugins

No plugins found.

Recent questions tagged google_chat_ros at answers.ros.org

Package Summary

Tags No category tags.
Version 2.1.25
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/jsk-ros-pkg/jsk_3rdparty.git
VCS Type git
VCS Version master
Last Updated 2022-11-12
Dev Status DEVELOPED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

Use Google Chat API clients via ROS

Additional Links

No additional links.

Maintainers

  • Kei Okada

Authors

  • Yoshiki Obinata

Google Chat ROS

The ROS wrapper for Google Chat API 1. Installation Guide 1. Sending the message 1. Receiving the message 1. Handling the event 1. Optional functions 1. Helper nodes

1. Installation Guide

1.1 Get the API KEY

At first, you should have the permission to access the Google Chat API. See Google Official Document. Please ensure to get JSON credetial file and save it. DO NOT LOST IT!
For JSK members, all keys are available at Google Drive. If you make new API keys, please upload them here.

1.2 Select the way how to recieve Google Chat event

The way you recieve Google Chat event from API server depends on your system. If your system has static IP and is allowed to recieve https request with specific port, please see HTTPS mode. If not, please see Pub/Sub mode.

HTTPS mode

When you send the message, the node uses Google REST API. When you recieve the message, Google Chat API sends https request to your machine and the node handles it.

google_chat_https_system

You have to prepare SSL certificate. Self-signed one is not available because of Google security issue. Please use the service like Let's Encrypt. In Google Cloud console, please choose App URL as connection settings and fill the URL in the App URL form.

google_chat_https

Pub/Sub mode

When you send the message, the node uses Google REST API. When you recieve the message, the node uses Google Pub/Sub API's subscription. The node has already established its connection to Google Pub/Sub API when you launch it.

google_chat_pubsub_system

The way how to set up in Google Cloud console shows below.

1. Authorize the existing Google Chat API project to access Google Cloud Pub/Sub service

In IAM settings in the console, please add the role Pub/Sub Admin to service account.

pubsub_admin_mosaic

2. Create Pub/Sub topic and subscriber

In Pub/Sub settings in the console, please add the topic and subscriptions. In the figure, we set the topic name chat, the subscription name chat-sub as an example.

pubsub_topic_mosaic

pubsub_subscription

Note that if you set the topic name chat, the full name of it becomes projects/<project_name>/topics/chat. Please confirm the subsciptions subscribes the full name not short one.

3. Grant publish rigts on your topic

In order for Google Chat to publish messages to your topic, it must have publishing rights to the topic. To grant Google Chat these permissions, assign the Pub/Sub Publisher role to the following service account

chat-api-push@system.gserviceaccount.com

google_chat_pubsub_permission

4. Set Google Chat API Connection settings

Please choose Cloud Pub/Sub as connection settings and fill the full topic name in the Topic Name form.

google_chat_pubsub

1.3 Install/Build the ROS node

If you want to build from the source

source /opt/ros/${ROS_DISTRO}/setup.bash
mkdir -p ~/catkin_ws/src && cd ~/catkin_ws/src
git clone https://github.com/jsk-ros-pkg/jsk_3rdparty
rosdep install --ignore-src --from-paths . -y -r
cd ..
catkin build

1.4 Launch the node

HTTPS mode

You have to set rosparams receiving_mode=https, google_cloud_credentials_json, host, port, ssl_certfile, ssl_keyfile.

Pub/Sub mode

You have to set rosparams receiving_mode=pubsub, google_cloud_credentials_json, project_id, subscription_id. subscription_id would be chat-sub if you follow Pub/Sub mode example.

Example
roslaunch google_chat_ros google_chat.launch receiving_mode:=pubsub google_cloud_credentials_json:=/path/to/<project_id>-XXXXXXXX.json project_id:=<project_id> subscription_id:=chat-sub

2. Sending the message

2.1 Understanding Google Chat Room

When you see Google Chat UI with browsers or smartphone's apps, you may see space, thread. If you send new message, you must specify the space or thread you want to send the message to. You can get the space name from chat room's URL. If it is https://mail.google.com/chat/u/0/#chat/space/XXXXXXXXXXX, XXXXXXXXXXX becomes the space name.

2.2 Message format

There are 2 types of messages, text and card. The card basically follows the original json structure. As the node covers all the units in here with ros action msgs, it may be complicated for you if you want to use all of them. So in Examples sections, we'll show you simple ones.

2.3 Sending the message by actionlib

All you have to do is send Actionlib goal to ~send/goal.

2.4 Examples

Showing the message examples with rostopic pub -1 command on bash.

Sending a text message

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  text: 'Hello!'
  space: 'spaces/<space name>'"

google_chat_text

Sending a message with KeyValue card

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  text: 'Something FATAL errors have happened in my computer, please fix ASAP'
  cards:
    -
      sections:
        -
          widgets:
            -
              key_value:
                top_label: 'Process ID'
                content: '1234'
                bottom_label: 'rospy'
                icon: 'DESCRIPTION'
  space: 'spaces/<space name>'"

google_chat_keyvalue

Sending an Interactive button

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      header:
        title: 'What do you want to eat?'
        subtitle: 'Please choose the food shop!'
      sections:
        -
          widgets:
            -
              buttons:
                -
                  text_button_name: 'STARBUCKS'
                  text_button_on_click:
                    action:
                      action_method_name: 'vote_starbucks'
                      parameters:
                        -
                          key: 'shop'
                          value: 'starbucks'
                -
                  text_button_name: 'SUBWAY'
                  text_button_on_click:
                    action:
                      action_method_name: 'vote_subway'
                      parameters:
                        -
                          key: 'shop'
                          value: 'subway'

  space: 'spaces/<space name>'"

google_chat_interactive_button

Sending a message with an image

See Here.

3. Receiving the messages

3.1 ROS Topic

When the bot was mentioned, the node publishes ~message_activity topic.

3.2 Examples

Receiving a text message

event_time: "2022-04-28T06:25:26.884623Z"
space:
  name: "spaces/<space name>"
  display_name: ''
  room: False
  dm: True
message:
  name: "spaces/<space name>/messages/<message id>"
  sender:
    name: "users/<user id>"
    display_name: "Yoshiki Obinata"
    avatar_url: "<avatar url>"
    avatar: []
    email: "<email>"
    bot: False
    human: True
  create_time: "2022-04-28T06:25:26.884623Z"
  text: "Hello!"
  thread_name: "spaces/<space name>/threads/<thread name>"
  annotations: []
  argument_text: "Hello!"
  attachments: []
user:
  name: "users/<user id>"
  display_name: "Yoshiki Obinata"
  avatar_url: "<avatar url>"
  avatar: []
  email: "<email>"
  bot: False
  human: True

Receiving a message with an image or gdrive file and download it

4. Handling the interactive event

If you've already sent the interactive card like Interactive card example, you can receive the activity of buttons. Suppose someone pressed the button STARBUCKS, the node publishes a ~card_activity topic like

event_time: "2022-05-02T00:23:47.855023Z"
space:
  name: "spaces/<space name>"
  display_name: "robotroom_with_thread"
  room: True
  dm: False
message:
  name: "spaces/<space name>/messages/Go__sDfIdec.Go__sDfIdec"
  sender:
    name: "users/100406614699672138585"
    display_name: "Fetch1075"
    avatar_url: "https://lh4.googleusercontent.com/proxy/hWEAWt6fmHsFAzeiEoV5FMOx5-jmU3OnzQxCtrr9unyt73NNwv0lh7InFzOh-0yO3jOPgtColHBywnZnJvl4SVqqqrYkyT1uf18k_hDIVYrAv87AY7lM0hp5KtQ1m9br-aPFE98QwNnSTYc2LQ"
    avatar: []
    email: ''
    bot: True
    human: False
  create_time: "2022-05-02T00:23:47.855023Z"
  text: ''
  thread_name: "spaces/<space name>/threads/Go__sDfIdec"
  annotations: []
  argument_text: ''
  attachments: []
user:
  name: "users/103866924487978823908"
  display_name: "Yoshiki Obinata"
  avatar_url: "https://lh3.googleusercontent.com/a-/AOh14GgexXiq8ImuKMgOq6QG-4geIzz5IC1-xa0Caead=k"
  avatar: []
  email: "<your email>"
  bot: False
  human: True
action:
  action_method_name: "vote_starbucks"
  parameters:
    -
      key: "shop"
      value: "starbucks"

After the node which handles the chat event subscribed the topic, it can respond with text message like

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      sections:
        -
          widgets:
            -
              key_value:
                top_label: 'The shop accepted!'
                content: 'You choose STARBUCKS!!'
                icon: 'DESCRIPTION'
  space: 'spaces/<space name>'
  thread_name: 'spaces/<space name>/threads/<thread name>'"

google_chat_interact

The important point is that the client node has to remember the thread_name which the card event was occured at and send response to it.

5. Optional functions

5.1 Sending a message with an image

To send an image, you have to use card type message. If you want to add the image uploaded to a storage server available for everyone, you just add its URI like

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      sections:
        -
          widgets:
            -
              image:
                image_url: 'https://media-cdn.tripadvisor.com/media/photo-s/11/fb/90/e4/dsc-7314-largejpg.jpg'
  space: 'spaces/<your space>'"

If you want to attach image saved at your host, you have to launch (gdrive_ros)[https://github.com/jsk-ros-pkg/jsk_3rdparty/tree/master/gdrive_ros] at first and set ~gdrive_upload_service param with gdrive_ros/Upload service name. Then publish topic like

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      sections:
        -
          widgets:
            -
              image:
                localpath: '/home/user/Pictures/image.png'
  space: 'spaces/<your space>'

5.2 Receiving a message with images or gdrive file

You have to set rosparam ~download_data True, ~download_directory. If the node recieved the message with image or google drive file, it automatically downloads to ~donwload_directory path.

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

See ROS Wiki Tutorials for more details.

Source Tutorials

Not currently indexed.

Launch files

  • launch/google_chat.launch
      • receiving_mode [default: url] — Google Chat API settings. Choose from url, dialogflow, pubsub, none.
      • gdrive_upload_service [default: /gdrive_ros/upload] — The ROS service name of gdrive_ros upload
      • upload_data_timeout [default: 20]
      • download_data [default: true]
      • download_data_timeout [default: 10]
      • download_directory [default: /tmp]
      • download_avatar [default: false]
      • google_cloud_credentials_json [default: ]
      • use_yaml [default: false] — Whether you use yaml file or not.
      • yaml_file [default: ] — Yaml file of web settings.
      • respawn [default: true]
      • host [default: localhost]
      • port [default: 443]
      • ssl_certfile [default: default]
      • ssl_keyfile [default: default]
      • project_id [default: default]
      • subscription_id [default: default]
      • use_helper [default: true]
      • to_dialogflow_client [default: false]
      • debug_sound [default: false]

Services

No service files found

Plugins

No plugins found.

Recent questions tagged google_chat_ros at answers.ros.org

Package Summary

Tags No category tags.
Version 2.1.25
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/jsk-ros-pkg/jsk_3rdparty.git
VCS Type git
VCS Version master
Last Updated 2022-11-12
Dev Status DEVELOPED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

Use Google Chat API clients via ROS

Additional Links

No additional links.

Maintainers

  • Kei Okada

Authors

  • Yoshiki Obinata

Google Chat ROS

The ROS wrapper for Google Chat API 1. Installation Guide 1. Sending the message 1. Receiving the message 1. Handling the event 1. Optional functions 1. Helper nodes

1. Installation Guide

1.1 Get the API KEY

At first, you should have the permission to access the Google Chat API. See Google Official Document. Please ensure to get JSON credetial file and save it. DO NOT LOST IT!
For JSK members, all keys are available at Google Drive. If you make new API keys, please upload them here.

1.2 Select the way how to recieve Google Chat event

The way you recieve Google Chat event from API server depends on your system. If your system has static IP and is allowed to recieve https request with specific port, please see HTTPS mode. If not, please see Pub/Sub mode.

HTTPS mode

When you send the message, the node uses Google REST API. When you recieve the message, Google Chat API sends https request to your machine and the node handles it.

google_chat_https_system

You have to prepare SSL certificate. Self-signed one is not available because of Google security issue. Please use the service like Let's Encrypt. In Google Cloud console, please choose App URL as connection settings and fill the URL in the App URL form.

google_chat_https

Pub/Sub mode

When you send the message, the node uses Google REST API. When you recieve the message, the node uses Google Pub/Sub API's subscription. The node has already established its connection to Google Pub/Sub API when you launch it.

google_chat_pubsub_system

The way how to set up in Google Cloud console shows below.

1. Authorize the existing Google Chat API project to access Google Cloud Pub/Sub service

In IAM settings in the console, please add the role Pub/Sub Admin to service account.

pubsub_admin_mosaic

2. Create Pub/Sub topic and subscriber

In Pub/Sub settings in the console, please add the topic and subscriptions. In the figure, we set the topic name chat, the subscription name chat-sub as an example.

pubsub_topic_mosaic

pubsub_subscription

Note that if you set the topic name chat, the full name of it becomes projects/<project_name>/topics/chat. Please confirm the subsciptions subscribes the full name not short one.

3. Grant publish rigts on your topic

In order for Google Chat to publish messages to your topic, it must have publishing rights to the topic. To grant Google Chat these permissions, assign the Pub/Sub Publisher role to the following service account

chat-api-push@system.gserviceaccount.com

google_chat_pubsub_permission

4. Set Google Chat API Connection settings

Please choose Cloud Pub/Sub as connection settings and fill the full topic name in the Topic Name form.

google_chat_pubsub

1.3 Install/Build the ROS node

If you want to build from the source

source /opt/ros/${ROS_DISTRO}/setup.bash
mkdir -p ~/catkin_ws/src && cd ~/catkin_ws/src
git clone https://github.com/jsk-ros-pkg/jsk_3rdparty
rosdep install --ignore-src --from-paths . -y -r
cd ..
catkin build

1.4 Launch the node

HTTPS mode

You have to set rosparams receiving_mode=https, google_cloud_credentials_json, host, port, ssl_certfile, ssl_keyfile.

Pub/Sub mode

You have to set rosparams receiving_mode=pubsub, google_cloud_credentials_json, project_id, subscription_id. subscription_id would be chat-sub if you follow Pub/Sub mode example.

Example
roslaunch google_chat_ros google_chat.launch receiving_mode:=pubsub google_cloud_credentials_json:=/path/to/<project_id>-XXXXXXXX.json project_id:=<project_id> subscription_id:=chat-sub

2. Sending the message

2.1 Understanding Google Chat Room

When you see Google Chat UI with browsers or smartphone's apps, you may see space, thread. If you send new message, you must specify the space or thread you want to send the message to. You can get the space name from chat room's URL. If it is https://mail.google.com/chat/u/0/#chat/space/XXXXXXXXXXX, XXXXXXXXXXX becomes the space name.

2.2 Message format

There are 2 types of messages, text and card. The card basically follows the original json structure. As the node covers all the units in here with ros action msgs, it may be complicated for you if you want to use all of them. So in Examples sections, we'll show you simple ones.

2.3 Sending the message by actionlib

All you have to do is send Actionlib goal to ~send/goal.

2.4 Examples

Showing the message examples with rostopic pub -1 command on bash.

Sending a text message

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  text: 'Hello!'
  space: 'spaces/<space name>'"

google_chat_text

Sending a message with KeyValue card

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  text: 'Something FATAL errors have happened in my computer, please fix ASAP'
  cards:
    -
      sections:
        -
          widgets:
            -
              key_value:
                top_label: 'Process ID'
                content: '1234'
                bottom_label: 'rospy'
                icon: 'DESCRIPTION'
  space: 'spaces/<space name>'"

google_chat_keyvalue

Sending an Interactive button

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      header:
        title: 'What do you want to eat?'
        subtitle: 'Please choose the food shop!'
      sections:
        -
          widgets:
            -
              buttons:
                -
                  text_button_name: 'STARBUCKS'
                  text_button_on_click:
                    action:
                      action_method_name: 'vote_starbucks'
                      parameters:
                        -
                          key: 'shop'
                          value: 'starbucks'
                -
                  text_button_name: 'SUBWAY'
                  text_button_on_click:
                    action:
                      action_method_name: 'vote_subway'
                      parameters:
                        -
                          key: 'shop'
                          value: 'subway'

  space: 'spaces/<space name>'"

google_chat_interactive_button

Sending a message with an image

See Here.

3. Receiving the messages

3.1 ROS Topic

When the bot was mentioned, the node publishes ~message_activity topic.

3.2 Examples

Receiving a text message

event_time: "2022-04-28T06:25:26.884623Z"
space:
  name: "spaces/<space name>"
  display_name: ''
  room: False
  dm: True
message:
  name: "spaces/<space name>/messages/<message id>"
  sender:
    name: "users/<user id>"
    display_name: "Yoshiki Obinata"
    avatar_url: "<avatar url>"
    avatar: []
    email: "<email>"
    bot: False
    human: True
  create_time: "2022-04-28T06:25:26.884623Z"
  text: "Hello!"
  thread_name: "spaces/<space name>/threads/<thread name>"
  annotations: []
  argument_text: "Hello!"
  attachments: []
user:
  name: "users/<user id>"
  display_name: "Yoshiki Obinata"
  avatar_url: "<avatar url>"
  avatar: []
  email: "<email>"
  bot: False
  human: True

Receiving a message with an image or gdrive file and download it

4. Handling the interactive event

If you've already sent the interactive card like Interactive card example, you can receive the activity of buttons. Suppose someone pressed the button STARBUCKS, the node publishes a ~card_activity topic like

event_time: "2022-05-02T00:23:47.855023Z"
space:
  name: "spaces/<space name>"
  display_name: "robotroom_with_thread"
  room: True
  dm: False
message:
  name: "spaces/<space name>/messages/Go__sDfIdec.Go__sDfIdec"
  sender:
    name: "users/100406614699672138585"
    display_name: "Fetch1075"
    avatar_url: "https://lh4.googleusercontent.com/proxy/hWEAWt6fmHsFAzeiEoV5FMOx5-jmU3OnzQxCtrr9unyt73NNwv0lh7InFzOh-0yO3jOPgtColHBywnZnJvl4SVqqqrYkyT1uf18k_hDIVYrAv87AY7lM0hp5KtQ1m9br-aPFE98QwNnSTYc2LQ"
    avatar: []
    email: ''
    bot: True
    human: False
  create_time: "2022-05-02T00:23:47.855023Z"
  text: ''
  thread_name: "spaces/<space name>/threads/Go__sDfIdec"
  annotations: []
  argument_text: ''
  attachments: []
user:
  name: "users/103866924487978823908"
  display_name: "Yoshiki Obinata"
  avatar_url: "https://lh3.googleusercontent.com/a-/AOh14GgexXiq8ImuKMgOq6QG-4geIzz5IC1-xa0Caead=k"
  avatar: []
  email: "<your email>"
  bot: False
  human: True
action:
  action_method_name: "vote_starbucks"
  parameters:
    -
      key: "shop"
      value: "starbucks"

After the node which handles the chat event subscribed the topic, it can respond with text message like

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      sections:
        -
          widgets:
            -
              key_value:
                top_label: 'The shop accepted!'
                content: 'You choose STARBUCKS!!'
                icon: 'DESCRIPTION'
  space: 'spaces/<space name>'
  thread_name: 'spaces/<space name>/threads/<thread name>'"

google_chat_interact

The important point is that the client node has to remember the thread_name which the card event was occured at and send response to it.

5. Optional functions

5.1 Sending a message with an image

To send an image, you have to use card type message. If you want to add the image uploaded to a storage server available for everyone, you just add its URI like

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      sections:
        -
          widgets:
            -
              image:
                image_url: 'https://media-cdn.tripadvisor.com/media/photo-s/11/fb/90/e4/dsc-7314-largejpg.jpg'
  space: 'spaces/<your space>'"

If you want to attach image saved at your host, you have to launch (gdrive_ros)[https://github.com/jsk-ros-pkg/jsk_3rdparty/tree/master/gdrive_ros] at first and set ~gdrive_upload_service param with gdrive_ros/Upload service name. Then publish topic like

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      sections:
        -
          widgets:
            -
              image:
                localpath: '/home/user/Pictures/image.png'
  space: 'spaces/<your space>'

5.2 Receiving a message with images or gdrive file

You have to set rosparam ~download_data True, ~download_directory. If the node recieved the message with image or google drive file, it automatically downloads to ~donwload_directory path.

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

See ROS Wiki Tutorials for more details.

Source Tutorials

Not currently indexed.

Launch files

  • launch/google_chat.launch
      • receiving_mode [default: url] — Google Chat API settings. Choose from url, dialogflow, pubsub, none.
      • gdrive_upload_service [default: /gdrive_ros/upload] — The ROS service name of gdrive_ros upload
      • upload_data_timeout [default: 20]
      • download_data [default: true]
      • download_data_timeout [default: 10]
      • download_directory [default: /tmp]
      • download_avatar [default: false]
      • google_cloud_credentials_json [default: ]
      • use_yaml [default: false] — Whether you use yaml file or not.
      • yaml_file [default: ] — Yaml file of web settings.
      • respawn [default: true]
      • host [default: localhost]
      • port [default: 443]
      • ssl_certfile [default: default]
      • ssl_keyfile [default: default]
      • project_id [default: default]
      • subscription_id [default: default]
      • use_helper [default: true]
      • to_dialogflow_client [default: false]
      • debug_sound [default: false]

Services

No service files found

Plugins

No plugins found.

Recent questions tagged google_chat_ros at answers.ros.org

Package Summary

Tags No category tags.
Version 2.1.25
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/jsk-ros-pkg/jsk_3rdparty.git
VCS Type git
VCS Version master
Last Updated 2022-11-12
Dev Status DEVELOPED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

Use Google Chat API clients via ROS

Additional Links

No additional links.

Maintainers

  • Kei Okada

Authors

  • Yoshiki Obinata

Google Chat ROS

The ROS wrapper for Google Chat API 1. Installation Guide 1. Sending the message 1. Receiving the message 1. Handling the event 1. Optional functions 1. Helper nodes

1. Installation Guide

1.1 Get the API KEY

At first, you should have the permission to access the Google Chat API. See Google Official Document. Please ensure to get JSON credetial file and save it. DO NOT LOST IT!
For JSK members, all keys are available at Google Drive. If you make new API keys, please upload them here.

1.2 Select the way how to recieve Google Chat event

The way you recieve Google Chat event from API server depends on your system. If your system has static IP and is allowed to recieve https request with specific port, please see HTTPS mode. If not, please see Pub/Sub mode.

HTTPS mode

When you send the message, the node uses Google REST API. When you recieve the message, Google Chat API sends https request to your machine and the node handles it.

google_chat_https_system

You have to prepare SSL certificate. Self-signed one is not available because of Google security issue. Please use the service like Let's Encrypt. In Google Cloud console, please choose App URL as connection settings and fill the URL in the App URL form.

google_chat_https

Pub/Sub mode

When you send the message, the node uses Google REST API. When you recieve the message, the node uses Google Pub/Sub API's subscription. The node has already established its connection to Google Pub/Sub API when you launch it.

google_chat_pubsub_system

The way how to set up in Google Cloud console shows below.

1. Authorize the existing Google Chat API project to access Google Cloud Pub/Sub service

In IAM settings in the console, please add the role Pub/Sub Admin to service account.

pubsub_admin_mosaic

2. Create Pub/Sub topic and subscriber

In Pub/Sub settings in the console, please add the topic and subscriptions. In the figure, we set the topic name chat, the subscription name chat-sub as an example.

pubsub_topic_mosaic

pubsub_subscription

Note that if you set the topic name chat, the full name of it becomes projects/<project_name>/topics/chat. Please confirm the subsciptions subscribes the full name not short one.

3. Grant publish rigts on your topic

In order for Google Chat to publish messages to your topic, it must have publishing rights to the topic. To grant Google Chat these permissions, assign the Pub/Sub Publisher role to the following service account

chat-api-push@system.gserviceaccount.com

google_chat_pubsub_permission

4. Set Google Chat API Connection settings

Please choose Cloud Pub/Sub as connection settings and fill the full topic name in the Topic Name form.

google_chat_pubsub

1.3 Install/Build the ROS node

If you want to build from the source

source /opt/ros/${ROS_DISTRO}/setup.bash
mkdir -p ~/catkin_ws/src && cd ~/catkin_ws/src
git clone https://github.com/jsk-ros-pkg/jsk_3rdparty
rosdep install --ignore-src --from-paths . -y -r
cd ..
catkin build

1.4 Launch the node

HTTPS mode

You have to set rosparams receiving_mode=https, google_cloud_credentials_json, host, port, ssl_certfile, ssl_keyfile.

Pub/Sub mode

You have to set rosparams receiving_mode=pubsub, google_cloud_credentials_json, project_id, subscription_id. subscription_id would be chat-sub if you follow Pub/Sub mode example.

Example
roslaunch google_chat_ros google_chat.launch receiving_mode:=pubsub google_cloud_credentials_json:=/path/to/<project_id>-XXXXXXXX.json project_id:=<project_id> subscription_id:=chat-sub

2. Sending the message

2.1 Understanding Google Chat Room

When you see Google Chat UI with browsers or smartphone's apps, you may see space, thread. If you send new message, you must specify the space or thread you want to send the message to. You can get the space name from chat room's URL. If it is https://mail.google.com/chat/u/0/#chat/space/XXXXXXXXXXX, XXXXXXXXXXX becomes the space name.

2.2 Message format

There are 2 types of messages, text and card. The card basically follows the original json structure. As the node covers all the units in here with ros action msgs, it may be complicated for you if you want to use all of them. So in Examples sections, we'll show you simple ones.

2.3 Sending the message by actionlib

All you have to do is send Actionlib goal to ~send/goal.

2.4 Examples

Showing the message examples with rostopic pub -1 command on bash.

Sending a text message

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  text: 'Hello!'
  space: 'spaces/<space name>'"

google_chat_text

Sending a message with KeyValue card

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  text: 'Something FATAL errors have happened in my computer, please fix ASAP'
  cards:
    -
      sections:
        -
          widgets:
            -
              key_value:
                top_label: 'Process ID'
                content: '1234'
                bottom_label: 'rospy'
                icon: 'DESCRIPTION'
  space: 'spaces/<space name>'"

google_chat_keyvalue

Sending an Interactive button

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      header:
        title: 'What do you want to eat?'
        subtitle: 'Please choose the food shop!'
      sections:
        -
          widgets:
            -
              buttons:
                -
                  text_button_name: 'STARBUCKS'
                  text_button_on_click:
                    action:
                      action_method_name: 'vote_starbucks'
                      parameters:
                        -
                          key: 'shop'
                          value: 'starbucks'
                -
                  text_button_name: 'SUBWAY'
                  text_button_on_click:
                    action:
                      action_method_name: 'vote_subway'
                      parameters:
                        -
                          key: 'shop'
                          value: 'subway'

  space: 'spaces/<space name>'"

google_chat_interactive_button

Sending a message with an image

See Here.

3. Receiving the messages

3.1 ROS Topic

When the bot was mentioned, the node publishes ~message_activity topic.

3.2 Examples

Receiving a text message

event_time: "2022-04-28T06:25:26.884623Z"
space:
  name: "spaces/<space name>"
  display_name: ''
  room: False
  dm: True
message:
  name: "spaces/<space name>/messages/<message id>"
  sender:
    name: "users/<user id>"
    display_name: "Yoshiki Obinata"
    avatar_url: "<avatar url>"
    avatar: []
    email: "<email>"
    bot: False
    human: True
  create_time: "2022-04-28T06:25:26.884623Z"
  text: "Hello!"
  thread_name: "spaces/<space name>/threads/<thread name>"
  annotations: []
  argument_text: "Hello!"
  attachments: []
user:
  name: "users/<user id>"
  display_name: "Yoshiki Obinata"
  avatar_url: "<avatar url>"
  avatar: []
  email: "<email>"
  bot: False
  human: True

Receiving a message with an image or gdrive file and download it

4. Handling the interactive event

If you've already sent the interactive card like Interactive card example, you can receive the activity of buttons. Suppose someone pressed the button STARBUCKS, the node publishes a ~card_activity topic like

event_time: "2022-05-02T00:23:47.855023Z"
space:
  name: "spaces/<space name>"
  display_name: "robotroom_with_thread"
  room: True
  dm: False
message:
  name: "spaces/<space name>/messages/Go__sDfIdec.Go__sDfIdec"
  sender:
    name: "users/100406614699672138585"
    display_name: "Fetch1075"
    avatar_url: "https://lh4.googleusercontent.com/proxy/hWEAWt6fmHsFAzeiEoV5FMOx5-jmU3OnzQxCtrr9unyt73NNwv0lh7InFzOh-0yO3jOPgtColHBywnZnJvl4SVqqqrYkyT1uf18k_hDIVYrAv87AY7lM0hp5KtQ1m9br-aPFE98QwNnSTYc2LQ"
    avatar: []
    email: ''
    bot: True
    human: False
  create_time: "2022-05-02T00:23:47.855023Z"
  text: ''
  thread_name: "spaces/<space name>/threads/Go__sDfIdec"
  annotations: []
  argument_text: ''
  attachments: []
user:
  name: "users/103866924487978823908"
  display_name: "Yoshiki Obinata"
  avatar_url: "https://lh3.googleusercontent.com/a-/AOh14GgexXiq8ImuKMgOq6QG-4geIzz5IC1-xa0Caead=k"
  avatar: []
  email: "<your email>"
  bot: False
  human: True
action:
  action_method_name: "vote_starbucks"
  parameters:
    -
      key: "shop"
      value: "starbucks"

After the node which handles the chat event subscribed the topic, it can respond with text message like

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      sections:
        -
          widgets:
            -
              key_value:
                top_label: 'The shop accepted!'
                content: 'You choose STARBUCKS!!'
                icon: 'DESCRIPTION'
  space: 'spaces/<space name>'
  thread_name: 'spaces/<space name>/threads/<thread name>'"

google_chat_interact

The important point is that the client node has to remember the thread_name which the card event was occured at and send response to it.

5. Optional functions

5.1 Sending a message with an image

To send an image, you have to use card type message. If you want to add the image uploaded to a storage server available for everyone, you just add its URI like

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      sections:
        -
          widgets:
            -
              image:
                image_url: 'https://media-cdn.tripadvisor.com/media/photo-s/11/fb/90/e4/dsc-7314-largejpg.jpg'
  space: 'spaces/<your space>'"

If you want to attach image saved at your host, you have to launch (gdrive_ros)[https://github.com/jsk-ros-pkg/jsk_3rdparty/tree/master/gdrive_ros] at first and set ~gdrive_upload_service param with gdrive_ros/Upload service name. Then publish topic like

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      sections:
        -
          widgets:
            -
              image:
                localpath: '/home/user/Pictures/image.png'
  space: 'spaces/<your space>'

5.2 Receiving a message with images or gdrive file

You have to set rosparam ~download_data True, ~download_directory. If the node recieved the message with image or google drive file, it automatically downloads to ~donwload_directory path.

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

See ROS Wiki Tutorials for more details.

Source Tutorials

Not currently indexed.

Launch files

  • launch/google_chat.launch
      • receiving_mode [default: url] — Google Chat API settings. Choose from url, dialogflow, pubsub, none.
      • gdrive_upload_service [default: /gdrive_ros/upload] — The ROS service name of gdrive_ros upload
      • upload_data_timeout [default: 20]
      • download_data [default: true]
      • download_data_timeout [default: 10]
      • download_directory [default: /tmp]
      • download_avatar [default: false]
      • google_cloud_credentials_json [default: ]
      • use_yaml [default: false] — Whether you use yaml file or not.
      • yaml_file [default: ] — Yaml file of web settings.
      • respawn [default: true]
      • host [default: localhost]
      • port [default: 443]
      • ssl_certfile [default: default]
      • ssl_keyfile [default: default]
      • project_id [default: default]
      • subscription_id [default: default]
      • use_helper [default: true]
      • to_dialogflow_client [default: false]
      • debug_sound [default: false]

Services

No service files found

Plugins

No plugins found.

Recent questions tagged google_chat_ros at answers.ros.org

Package Summary

Tags No category tags.
Version 2.1.25
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/jsk-ros-pkg/jsk_3rdparty.git
VCS Type git
VCS Version master
Last Updated 2022-11-12
Dev Status DEVELOPED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

Use Google Chat API clients via ROS

Additional Links

No additional links.

Maintainers

  • Kei Okada

Authors

  • Yoshiki Obinata

Google Chat ROS

The ROS wrapper for Google Chat API 1. Installation Guide 1. Sending the message 1. Receiving the message 1. Handling the event 1. Optional functions 1. Helper nodes

1. Installation Guide

1.1 Get the API KEY

At first, you should have the permission to access the Google Chat API. See Google Official Document. Please ensure to get JSON credetial file and save it. DO NOT LOST IT!
For JSK members, all keys are available at Google Drive. If you make new API keys, please upload them here.

1.2 Select the way how to recieve Google Chat event

The way you recieve Google Chat event from API server depends on your system. If your system has static IP and is allowed to recieve https request with specific port, please see HTTPS mode. If not, please see Pub/Sub mode.

HTTPS mode

When you send the message, the node uses Google REST API. When you recieve the message, Google Chat API sends https request to your machine and the node handles it.

google_chat_https_system

You have to prepare SSL certificate. Self-signed one is not available because of Google security issue. Please use the service like Let's Encrypt. In Google Cloud console, please choose App URL as connection settings and fill the URL in the App URL form.

google_chat_https

Pub/Sub mode

When you send the message, the node uses Google REST API. When you recieve the message, the node uses Google Pub/Sub API's subscription. The node has already established its connection to Google Pub/Sub API when you launch it.

google_chat_pubsub_system

The way how to set up in Google Cloud console shows below.

1. Authorize the existing Google Chat API project to access Google Cloud Pub/Sub service

In IAM settings in the console, please add the role Pub/Sub Admin to service account.

pubsub_admin_mosaic

2. Create Pub/Sub topic and subscriber

In Pub/Sub settings in the console, please add the topic and subscriptions. In the figure, we set the topic name chat, the subscription name chat-sub as an example.

pubsub_topic_mosaic

pubsub_subscription

Note that if you set the topic name chat, the full name of it becomes projects/<project_name>/topics/chat. Please confirm the subsciptions subscribes the full name not short one.

3. Grant publish rigts on your topic

In order for Google Chat to publish messages to your topic, it must have publishing rights to the topic. To grant Google Chat these permissions, assign the Pub/Sub Publisher role to the following service account

chat-api-push@system.gserviceaccount.com

google_chat_pubsub_permission

4. Set Google Chat API Connection settings

Please choose Cloud Pub/Sub as connection settings and fill the full topic name in the Topic Name form.

google_chat_pubsub

1.3 Install/Build the ROS node

If you want to build from the source

source /opt/ros/${ROS_DISTRO}/setup.bash
mkdir -p ~/catkin_ws/src && cd ~/catkin_ws/src
git clone https://github.com/jsk-ros-pkg/jsk_3rdparty
rosdep install --ignore-src --from-paths . -y -r
cd ..
catkin build

1.4 Launch the node

HTTPS mode

You have to set rosparams receiving_mode=https, google_cloud_credentials_json, host, port, ssl_certfile, ssl_keyfile.

Pub/Sub mode

You have to set rosparams receiving_mode=pubsub, google_cloud_credentials_json, project_id, subscription_id. subscription_id would be chat-sub if you follow Pub/Sub mode example.

Example
roslaunch google_chat_ros google_chat.launch receiving_mode:=pubsub google_cloud_credentials_json:=/path/to/<project_id>-XXXXXXXX.json project_id:=<project_id> subscription_id:=chat-sub

2. Sending the message

2.1 Understanding Google Chat Room

When you see Google Chat UI with browsers or smartphone's apps, you may see space, thread. If you send new message, you must specify the space or thread you want to send the message to. You can get the space name from chat room's URL. If it is https://mail.google.com/chat/u/0/#chat/space/XXXXXXXXXXX, XXXXXXXXXXX becomes the space name.

2.2 Message format

There are 2 types of messages, text and card. The card basically follows the original json structure. As the node covers all the units in here with ros action msgs, it may be complicated for you if you want to use all of them. So in Examples sections, we'll show you simple ones.

2.3 Sending the message by actionlib

All you have to do is send Actionlib goal to ~send/goal.

2.4 Examples

Showing the message examples with rostopic pub -1 command on bash.

Sending a text message

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  text: 'Hello!'
  space: 'spaces/<space name>'"

google_chat_text

Sending a message with KeyValue card

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  text: 'Something FATAL errors have happened in my computer, please fix ASAP'
  cards:
    -
      sections:
        -
          widgets:
            -
              key_value:
                top_label: 'Process ID'
                content: '1234'
                bottom_label: 'rospy'
                icon: 'DESCRIPTION'
  space: 'spaces/<space name>'"

google_chat_keyvalue

Sending an Interactive button

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      header:
        title: 'What do you want to eat?'
        subtitle: 'Please choose the food shop!'
      sections:
        -
          widgets:
            -
              buttons:
                -
                  text_button_name: 'STARBUCKS'
                  text_button_on_click:
                    action:
                      action_method_name: 'vote_starbucks'
                      parameters:
                        -
                          key: 'shop'
                          value: 'starbucks'
                -
                  text_button_name: 'SUBWAY'
                  text_button_on_click:
                    action:
                      action_method_name: 'vote_subway'
                      parameters:
                        -
                          key: 'shop'
                          value: 'subway'

  space: 'spaces/<space name>'"

google_chat_interactive_button

Sending a message with an image

See Here.

3. Receiving the messages

3.1 ROS Topic

When the bot was mentioned, the node publishes ~message_activity topic.

3.2 Examples

Receiving a text message

event_time: "2022-04-28T06:25:26.884623Z"
space:
  name: "spaces/<space name>"
  display_name: ''
  room: False
  dm: True
message:
  name: "spaces/<space name>/messages/<message id>"
  sender:
    name: "users/<user id>"
    display_name: "Yoshiki Obinata"
    avatar_url: "<avatar url>"
    avatar: []
    email: "<email>"
    bot: False
    human: True
  create_time: "2022-04-28T06:25:26.884623Z"
  text: "Hello!"
  thread_name: "spaces/<space name>/threads/<thread name>"
  annotations: []
  argument_text: "Hello!"
  attachments: []
user:
  name: "users/<user id>"
  display_name: "Yoshiki Obinata"
  avatar_url: "<avatar url>"
  avatar: []
  email: "<email>"
  bot: False
  human: True

Receiving a message with an image or gdrive file and download it

4. Handling the interactive event

If you've already sent the interactive card like Interactive card example, you can receive the activity of buttons. Suppose someone pressed the button STARBUCKS, the node publishes a ~card_activity topic like

event_time: "2022-05-02T00:23:47.855023Z"
space:
  name: "spaces/<space name>"
  display_name: "robotroom_with_thread"
  room: True
  dm: False
message:
  name: "spaces/<space name>/messages/Go__sDfIdec.Go__sDfIdec"
  sender:
    name: "users/100406614699672138585"
    display_name: "Fetch1075"
    avatar_url: "https://lh4.googleusercontent.com/proxy/hWEAWt6fmHsFAzeiEoV5FMOx5-jmU3OnzQxCtrr9unyt73NNwv0lh7InFzOh-0yO3jOPgtColHBywnZnJvl4SVqqqrYkyT1uf18k_hDIVYrAv87AY7lM0hp5KtQ1m9br-aPFE98QwNnSTYc2LQ"
    avatar: []
    email: ''
    bot: True
    human: False
  create_time: "2022-05-02T00:23:47.855023Z"
  text: ''
  thread_name: "spaces/<space name>/threads/Go__sDfIdec"
  annotations: []
  argument_text: ''
  attachments: []
user:
  name: "users/103866924487978823908"
  display_name: "Yoshiki Obinata"
  avatar_url: "https://lh3.googleusercontent.com/a-/AOh14GgexXiq8ImuKMgOq6QG-4geIzz5IC1-xa0Caead=k"
  avatar: []
  email: "<your email>"
  bot: False
  human: True
action:
  action_method_name: "vote_starbucks"
  parameters:
    -
      key: "shop"
      value: "starbucks"

After the node which handles the chat event subscribed the topic, it can respond with text message like

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      sections:
        -
          widgets:
            -
              key_value:
                top_label: 'The shop accepted!'
                content: 'You choose STARBUCKS!!'
                icon: 'DESCRIPTION'
  space: 'spaces/<space name>'
  thread_name: 'spaces/<space name>/threads/<thread name>'"

google_chat_interact

The important point is that the client node has to remember the thread_name which the card event was occured at and send response to it.

5. Optional functions

5.1 Sending a message with an image

To send an image, you have to use card type message. If you want to add the image uploaded to a storage server available for everyone, you just add its URI like

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      sections:
        -
          widgets:
            -
              image:
                image_url: 'https://media-cdn.tripadvisor.com/media/photo-s/11/fb/90/e4/dsc-7314-largejpg.jpg'
  space: 'spaces/<your space>'"

If you want to attach image saved at your host, you have to launch (gdrive_ros)[https://github.com/jsk-ros-pkg/jsk_3rdparty/tree/master/gdrive_ros] at first and set ~gdrive_upload_service param with gdrive_ros/Upload service name. Then publish topic like

rostopic pub -1 /google_chat_ros/send/goal google_chat_ros/SendMessageActionGoal "goal:
  cards:
    -
      sections:
        -
          widgets:
            -
              image:
                localpath: '/home/user/Pictures/image.png'
  space: 'spaces/<your space>'

5.2 Receiving a message with images or gdrive file

You have to set rosparam ~download_data True, ~download_directory. If the node recieved the message with image or google drive file, it automatically downloads to ~donwload_directory path.

CHANGELOG
No CHANGELOG found.

Wiki Tutorials

See ROS Wiki Tutorials for more details.

Source Tutorials

Not currently indexed.

Launch files

  • launch/google_chat.launch
      • receiving_mode [default: url] — Google Chat API settings. Choose from url, dialogflow, pubsub, none.
      • gdrive_upload_service [default: /gdrive_ros/upload] — The ROS service name of gdrive_ros upload
      • upload_data_timeout [default: 20]
      • download_data [default: true]
      • download_data_timeout [default: 10]
      • download_directory [default: /tmp]
      • download_avatar [default: false]
      • google_cloud_credentials_json [default: ]
      • use_yaml [default: false] — Whether you use yaml file or not.
      • yaml_file [default: ] — Yaml file of web settings.
      • respawn [default: true]
      • host [default: localhost]
      • port [default: 443]
      • ssl_certfile [default: default]
      • ssl_keyfile [default: default]
      • project_id [default: default]
      • subscription_id [default: default]
      • use_helper [default: true]
      • to_dialogflow_client [default: false]
      • debug_sound [default: false]

Services

No service files found

Plugins

No plugins found.

Recent questions tagged google_chat_ros at answers.ros.org