googleworkspace / hubot-google-hangouts-chat Goto Github PK
View Code? Open in Web Editor NEWHubot adapter for Google Chat.
License: Apache License 2.0
Hubot adapter for Google Chat.
License: Apache License 2.0
Hi all, I've been playing around with hubot integration of hangouts chat and is not working is said in the documentation, according to it, hubot should answer back on any mention as:
MYHUBOT help
myhubot help
@myhubot help
myhubot: help
but with google chat integration bot only reacts when it's mentioned with @
when it's mentioned twice, for example:
@myhubot myhubot help
after enabling DEBUG=true
I've seen that in the received body is getting the raw
message as text
field but it's processing the field argumentedText
which strips user's mention.
I've made a small change on the HangoutsChatTextMessage
object creation to use received message.text
and then it works as expected, any reason why on the implementation the object is being created with argumentText
? I haven't seen any difference but mentioned removed from the message.
...
"text": "@myhubot help",
"annotations": [
{
"type": "USER_MENTION",
"startIndex": 0,
"length": 8,
"userMention": {
"user": {
"name": "users/USER-ID",
"displayName": "myhubot",
"avatarUrl": "https://lh4.googleusercontent.com/proxy/URL",
"type": "BOT"
},
"type": "MENTION"
}
}
],
"thread": {
"name": "spaces/THREAD-ID,
"retentionSettings": {
"state": "PERMANENT"
}
},
"space": {
"name": "spaces/SPACE-ID",
"type": "ROOM",
"displayName": "test-room"
},
"argumentText": " help"
...
Thanks!
npm I
fails with compile errors using Node v12.4.0.
Failed to validate the config schema at '.github/sync-repo-settings.yaml': [
{
"instancePath": "/permissionRules/1/permission",
"schemaPath": "#/properties/permissionRules/items/properties/permission/enum",
"keyword": "enum",
"params": {
"allowedValues": [
"pull",
"push",
"admin"
]
},
"message": "must be equal to one of the allowed values"
}
]
Schema can be found at https://github.com/googleapis/repo-automation-bots/blob/main/packages/sync-repo-settings/src/schema.json
Don't need to start a duplicate express server. Just use Hubot's Express server.
} else {
// Begin listening at HTTP endpoint
// Replace startHttpServer
this.startHttpServer();
// with this. That way, it can just use Hubot's HTTP server.
this.robot.router.post('/', (req, res) => {
this.onEventReceived(req.body, res);
});
}
Reading #5 i'm confused if it will ever be possible for a bot to react to messages without its name mentioned.
Right now I can only seem to get messages sent with @ in a room - everything else is ignored. That makes log keeping and meeting notes bots and the likes hard to implement so i'm sure i'm missing something.
Reading https://developers.google.com/hangouts/chat/concepts/bots "Just like people, bots can participate in chat rooms, and they can respond to direct messages. But unlike people, bots only see messages directed to them when a person @mentions them in a chat room, or when a person sends them a direct message."
if the above is the hard limitation I guess I answered my own question and it is not possible with google hangouts to make a bot that can i.e. convert a #5 to a github link or have short cuts, like ".meet start" rather than "@meetbot meet start" or be able to make a bot that will help transcribe and archive content.
Are my observations correct and there are no way around this ?
Hi,
I'm trying to run hubot locally and configured it using gcp pub/sub adapter. I published my bot on hangout chat as well following this guide https://developers.google.com/hangouts/chat/how-tos/integrate-hubot
It shows up as green in chat (so I think it is connecting with my app), but I don't get any response back from the bot.
So, I tried getting logs from my docker container, where I'm running it. But, it doesn't contain any relevant information. This blocks me to do anything further. Any help is appreciated.
Here is my Dockerfile
FROM node:latest
ENV DEBIAN_FRONTEND=noninteractive \
HUBOT_NAME=myhubot \
HUBOT_OWNER=none \
HUBOT_DESCRIPTION=Hubot \
EXTERNAL_SCRIPTS="hubot-help,hubot-pugme" \
PORT=8080 \
EXPRESS_PORT=8081 \
IS_PUBSUB=true \
PUBSUB_PROJECT_ID='hubot-hangout-project' \
PUBSUB_SUBSCRIPTION_ID='testsub' \
GOOGLE_APPLICATION_CREDENTIALS='/home/hubot/cred/hubot-hangout-project-07a6200156ce.json'
RUN useradd hubot -m && \
npm install -g hubot coffeescript yo generator-hubot && \
npm install hubot-google-hangouts-chat
USER hubot
WORKDIR /home/hubot
RUN yo hubot --owner="${HUBOT_OWNER}" --name="${HUBOT_NAME}" --description="${HUBOT_DESCRIPTION}" --defaults && \
sed -i /heroku/d ./external-scripts.json && \
sed -i /redis-brain/d ./external-scripts.json && \
npm install hubot-scripts --save && \
node -e "console.log(JSON.stringify('$EXTERNAL_SCRIPTS'.split(',')))" > external-scripts.json && \
npm install $(node -e "console.log('$EXTERNAL_SCRIPTS'.split(',').join(' '))")
EXPOSE 8080 8081
VOLUME ["/home/hubot/scripts"]
CMD bin/hubot -n $HUBOT_NAME --adapter google-hangouts-chat
And here are my logs
audited 178 packages in 1.296s
found 0 vulnerabilitiesbody-parser deprecated undefined extended: provide extended option node_modules/hubot/src/robot.js:445:21
[Fri Dec 07 2018 15:31:43 GMT+0000 (Coordinated Universal Time)] INFO Connecting to Pub/Sub subscription - projects/hubot-hangout-project/subscriptions/testsub
[Fri Dec 07 2018 15:31:43 GMT+0000 (Coordinated Universal Time)] INFO Hangouts Chat adapter initialized successfully
[Fri Dec 07 2018 15:31:43 GMT+0000 (Coordinated Universal Time)] WARNING Loading scripts from hubot-scripts.json is deprecated and will be removed in 3.0 (github/hubot-scripts#1113) in favor of packages for each script.Your hubot-scripts.json is empty, so you just need to remove it.
(node:8) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
When users request help from the chatbot the Hangouts Chat API is erroring due to the length of the message being sent.
(node:74910) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:74910) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:74910) UnhandledPromiseRejectionWarning: Error: Maximum length of the field is 4096. Field: apps.dynamite.CreateMessageInfo.text_body
at createError (/hubot/node_modules/axios/lib/core/createError.js:16:15)
at settle (/hubot/node_modules/axios/lib/core/settle.js:18:12)
at Unzip.handleStreamEnd (/hubot/node_modules/axios/lib/adapters/http.js:202:11)
at Unzip.emit (events.js:208:15)
at Unzip.EventEmitter.emit (domain.js:476:20)
at endReadableNT (_stream_readable.js:1168:12)
at processTicksAndRejections (internal/process/task_queues.js:77:11)
Depending on the content that may need to be sent the limitation of the Hangouts Chat API and how the adapter interacts with it could present a problem with sending appropriate responses.
This issue provides visibility into Renovate updates and their statuses. Learn more
These updates are currently rate limited. Click on a checkbox below to force their creation now.
chai
, hubot
, mocha
)These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
package.json
@google-cloud/pubsub ^0.29.1
body-parser ^1.18.2
express ^4.16.2
google-auth-library ^1.6.1
googleapis ^41.0.1
request ^2.87.0
chai ^4.2.0
hubot >=3.3.2
mocha ^6.1.4
hubot >=3.3.2
Hello ๐
I could not find in the docs if it's possible to reply to a message in the same thread.
That would be ideal especially for multiple interactions.
Thanks
Originally posted by @rochejeremy in #2 (comment)
Hello
The adapter works pretty well for synchronous queries. But I am testing to use the robot.router.post
method that allow asynchronous queries:
In exemple.coffee
:
robot.router.post '/hubot/chatsecrets/:room', (req, res) ->
room = req.params.room
console.log req.body
data = req.body
secret = data.secret
robot.messageRoom room, "I have a secret: #{secret}"
res.send 'OK'
And I have this result:
TypeError: Cannot read property 'thread' of undefined
at HangoutsChatBot.sendMessage (/home/julien/web/hubot-google-hangouts-chat/src/bot.js:58:34)
at HangoutsChatBot.send (/home/julien/web/hubot-google)hangouts-chat/src/bot.js:77:10)
at Robot.messageRoom (/home/julien/web/myhubot/node_modules/hubot/src/robot.js:608:23)
at /home/julien/web/myhubot/scripts/example.coffee:92:5, <js>:9:13
I assume that using HTTP mode we can only use today synchronous queries (it post data using httpRes sent in the message). Any option to have asynchronous ? :)
Hi,
I'm trying to run this app in docker and get the port in use error with any port I use. Please help
Here is my Dockerfile:
FROM node:latest
ENV DEBIAN_FRONTEND noninteractive
ENV HUBOT_NAME myhubot
ENV HUBOT_OWNER none
ENV HUBOT_DESCRIPTION Hubot
ENV EXTERNAL_SCRIPTS "hubot-help,hubot-pugme"
RUN useradd hubot -m
RUN npm install -g hubot coffeescript yo generator-hubot && \
npm install --save hubot-google-hangouts-chat
USER hubot
WORKDIR /home/hubot
RUN yo hubot --owner="${HUBOT_OWNER}" --name="${HUBOT_NAME}" --description="${HUBOT_DESCRIPTION}" --defaults && sed -i /heroku/d ./external-scripts.json && sed -i /redis-brain/d ./external-scripts.json && npm install hubot-scripts --save
EXPOSE 8080
VOLUME ["/home/hubot/scripts"]
CMD node -e "console.log(JSON.stringify('$EXTERNAL_SCRIPTS'.split(',')))" > external-scripts.json && \
npm install $(node -e "console.log('$EXTERNAL_SCRIPTS'.split(',').join(' '))") && \
bin/hubot -n $HUBOT_NAME --adapter google-hangouts-chat
And here is the error I get while trying to the run the image created from above:
- [email protected]
- [email protected]
updated 2 packages and audited 178 packages in 1.283s
found 0 vulnerabilitiesaudited 178 packages in 1.277s
found 0 vulnerabilitiesbody-parser deprecated undefined extended: provide extended option node_modules/hubot/src/robot.js:445:21
[Mon Nov 19 2018 16:26:45 GMT+0000 (Coordinated Universal Time)] INFO Hangouts Chat adapter initialized successfully
[Mon Nov 19 2018 16:26:45 GMT+0000 (Coordinated Universal Time)] WARNING Loading scripts from hubot-scripts.json is deprecated and will be removed in 3.0 (github/hubot-scripts#1113) in favor of packages for each script.Your hubot-scripts.json is empty, so you just need to remove it.
[Mon Nov 19 2018 16:26:45 GMT+0000 (Coordinated Universal Time)] INFO Server is running in port - 8080
[Mon Nov 19 2018 16:26:45 GMT+0000 (Coordinated Universal Time)] ERROR Error: listen EADDRINUSE: address already in use 0.0.0.0:8080
at Server.setupListenHandle [as _listen2] (net.js:1290:14)
at listenInCluster (net.js:1338:12)
at doListen (net.js:1469:7)
at process.internalTickCallback (internal/process/next_tick.js:72:19)
Hi,
we are migrating from slack to Google Chat and we have a couple of bots that we want to bring with us from Slack that are based on Hubot.
Is this project maintained and secure?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.