How do you respond to a thread in Google Chat from an incoming webhook? - google-chat

There's a thread that my webhook has previously created that it wants to reply to. Is this possible using a webhook? It seems to be possible with a bot, see this answer:
https://stackoverflow.com/a/58657945/3832377
But I can't find any documentation on doing it from a webhook. As I've created the original message in the thread, I can guarentee a consistent threadId.
I tried to send a body that looked like:
{
"cards": [/* a card */]
"thread": { "name": "some_thread_name" }
}
But received a 500 error.

Documentation: https://developers.google.com/hangouts/chat/reference/rest/v1/spaces.messages/create
States you have to add the threadKey as a query parameter, not in the request body.

Related

Firebase push notifications always arrive as an empty message

I have been trying to get push notifications working using firebase. So far I have got as far as successfully sending an empty message "tickle". The problem is adding the message payload seems to have no affect on what the client receives. That is the service worker just sees it as another empty message.
I started by going through googles guide here - https://developers.google.com/web/ilt/pwa/introduction-to-push-notifications
After going through how to send an empty message it says the message payload must be encrypted and suggests using an existing library to do it. To quote - "As with anything related to encryption, it's usually easier to use an actively maintained library than to write your own code".
I tried to use web-push-php which is one of the libraries recommended by googles guide. After having trouble with that i discovered web-php-push doesn't actually support firebase.
Looking on here i find examples that look really simple and don't event encrypt the message payload. It is simply sent in plain json. Doing this has no affect and the receiving end still thinks it's an empty message. See my code below.
I am at a complete loss with this and i'm confused why googles guide says the message data must be encrypted but there are countless examples on SO where it is just send in plain json text.
This is what i am posting from my server to the end point.
POST https://fcm.googleapis.com/fcm/send Authorization: key=[my server
key] Content-Type: application/json {"priority":10,"to":"[subscriber
id]","notification":{"body":"test body","title":"test title"}}
Here is my event listener in my service-worker.js
self.addEventListener('push', function(e) {
var body;
if (e.data) {
body = e.data.text();
} else {
body = "No message "+JSON.stringify(e);
}
var options = {
body: body
};
e.waitUntil(
self.registration.showNotification('Launtel Residential', options)
);
});
When i run the post request above the push notification occurs and triggers the service worker 'push' event as expected but no message data is present. e.data returns null. The 'e' object always just contains a flag set to true. e.isTrusted==true

Telegram `setTyping` API call

I'm trying to set my bot's typing status by sending the following POST request (based on the API docs):
https://api.telegram.org/bot{{botToken}}/setTyping
{
peer: {{chat_id}},
typing: true,
action: 'sendMessageTypingAction'
}
I've tried a few variations of it, such as changing the url to be /messages.setTyping and sending the action as {"_":"sendMessageTypingAction"} as seen here, but all I get is:
{
"ok": false,
"error_code": 404,
"description": "Not Found: method not found"
}
Anyone know what I'm doing wrong?
Thanks to #tashakori for pointing me in the right direction towards the Bot API. For posterity, what I needed to do was:
https://api.telegram.org/bot{{botToken}}/sendChatAction
{
chat_id: {{chatId}},
action: 'typing'
}
The link you have mentioned above belongs to Telegram Core APIs which is used for handling ordinary accounts of Telegram. These so-called Core APIs are not related to Telegram Bot APIs.
The only API that is somehow similar to SetTyping for bots is AnswerCallbackQuery, which can be used only when responding to the user's interaction with inline keyboards. (you can send a text to the user, saying that there is a process running in the background and whenever the user's answer is ready, you can send it using APIs like sendMessage)

Telegram Inline Bot not call webhook

I've created new bot for Telegram. I've set /setinline in BotFather for my bot. I've added a webhook that is called when I send a message to bot but this webhook is not called if I write something in the bot chat without send any message.
Any idea how to solve?
Yes, it does, probably you're inspecting the wrong param, it will call the same webhook, first remember you set the webhook by doing:
https://api.telegram.org/bot<BOT_TOKEN>/setWebhook?url=<YOUR_URL>
and like you mentioned, you need to enable /setinline through BotFather, then it will call your endpoint with a message with the following body:
{
"query":"tex",
"from": {
"username":"user",
"first_name":"firstname",
"last_name":"lastname",
"id": 8888888,
"language_code":"en-US"},
"id":"7777777",
"offset":""
}
Remember it will call your endpoint on key-up you may receive a ton of request.

Can I add elements to the aps payload sent by the Bluemix IBM Push Notifications service?

I'm successfully using Bluemix Push to send notifications via the REST interface to an iOS app with a simple string alert message. That works fine.
Now I would like to send a more complex message where alert is a dictionary and has a sibling "category" element per The Remote Notification Payload.
Is this possible with Bluemix Push? Whenever I try to deviate from the basic structure, I get "Bad Request - Invalid JSON".
After much head-scratching, I finally picked up a hint from https://www.ng.bluemix.net/docs/services/mobilepush/t_advanced_notifications.html#t_push_badge_sound_payload and figured out that since the category field is unique to APNS, what I needed to send is
"settings" : {
"apns" : {
"category" : "myCategory"
}
#DSchultz_mo I was having issues to find the documentation but I finally found it, so if you go to https://mobile.ng.bluemix.net/imfpushrestapidocs/#/ you can use swagger to register your device and send notification and the magic button is in model there is more details for sendMessageBody

How to receive & process data when I subscribe to youtube api v3 push notification?

According to this https://developers.google.com/youtube/v3/guides/push_notifications
I can subscribe to a youtube channel & receive push notification for any new video.
My callback server is a php script which interprets POST/GET data:
<?php
if (isset($_GET['hub_challenge'])) {
print $_GET['hub_challenge'];
}
else {
$xml=file_get_contents("php://input");
file_put_contents('endpoint.txt',$xml);
}
?>
But $xml is empty. In the docs it says:
The YouTube Data API (v3) supports push notifications via
PubSubHubbub, a server-to-server publish/subscribe protocol for
Web-accessible resources. Notifications are pushed out to subscribers
via HTTP webhooks, which is much more efficient than polling-based
solutions.
But it does not specify how does it send the data....whether in POST body or in somewhere else.
So How do I get the atom feed in my script?
EDIT: I should probably ask a new question for this...but anyway....I tried this channel (https://www.youtube.com/channel/UCATp8LNTjzjNlLxdArp0Myg); but when I try to subscribe it says "restricted topic" (I did not provide token as it is a public channel). Same for any other channel ID. Is something wrong with my callback server? I also tried runscope url as a callback server for testing. But it did not help.
Others are having similar problems. Here is the issue log:
https://code.google.com/p/gdata-issues/issues/detail?id=7138
and related StackOverflow question:
Youtube API - Subscribing to Push Notifications
Unfortunately, no one seem to provide a solution although you can follow the issue and track any progress.
Yes it send data on the POST body . If you are using Express Nodejs add app.use(bodyParser.xml()) middleware to parse xml data

Resources