I recently inherited an app that uses the Webhooks from the Connect API. I'm looking through this:
https://docs.connect.squareup.com/api/connect/v1/#webhooks-overview
I have the webhook setup with what it says in the docs:
curl -X PUT -H "Authorization: Bearer PERSONAL_ACCESS_TOKEN" -H "Content-Type:
application/json" -d "[\"PAYMENT_UPDATED\"]"
https://connect.squareup.com/v1/LOCATION_ID/webhooks
I recently had an issue where I was receiving 2 requests for each PAYMENT_UPDATED event. I eventually found out that this was because 2 separate accounts had the webhook enabled. The two accounts were
1) a developer's account
2) the client's account
However, what I don't understand is how the developer's account was receiving notifications for the orders coming from the client's account?
Is it because it hooks up any orders placed in the location (which comes from the LOCATION_ID) and the webhook URL specified for the merchant (which is identified by the PERSONAL_ACCESS_TOKEN)? This works even if the merchant is not the owner of that location?
You probably have multiple applications connected to your account with the same notification URL, so you are getting notified twice. If you go to https://squareup.com/dashboard/apps/my-apps you can see the apps that are authoirzed for a given account and remove ones that you aren't using anymore.
Related
My username is "Charlie", and I'm the admin of a Slack environtment.
I create my incoming webhook following the steps:
https://api.slack.com/messaging/webhooks
And I create a bot called "Bot" with all the "write" scopes.
Then, I add a Webhook URL to be able to send direct messages to username "Peter".
When I use the typical curl method to send a test:
curl -X POST -H 'Content-type: application/json' --data '{"text":"Hello, World!"}' https://hooks.slack.com/services/xxxxxxxxxxx/xxxxxxxxxxx/xxxxxxxxxxxxxxx
Peter receives a message from Bot ... that's ok !!
But I see in my private messages with Peter that notification also.
That's to say, it's like Bot has written to Peter as me ... in my private channel with Peter.
What I want is Bot to write DIRECTLY to Peter, not in my private channel with that person.
Thank you!
Unfortunately, incoming webhooks won't be able to post a DM to a user on behalf of the bot. This type of functionality requires additional permissions and therefore can only be accomplished using a Slack WebAPI methods via a bot token.
To post a DM to a user with a Slack API app you will have to:
Add a bot user to your app. The bot token will appear in your OAuth and Permissions page after you install the app.
Make a call to the chat.postMessage api method and pass the id for the channel/conversation your want to post to. https://api.slack.com/methods/chat.postMessage
To get a list of all channel and conversations in your workspace including DMs make a call to conversations.list https://api.slack.com/methods/conversations.list
To open a DM with a user you can call conversations.open https://api.slack.com/methods/conversations.open
I want to utilise Google Meet api, which is used in Hangouts integration for Slack, description follows
TL;DR:
Links such as https://meet.google.com/new?gid=123&gd=qwe987 can be generated, so a modal is shown which can ask user's confirmation and then some request is sent from user's browser (where the Google Meet page is opened) to some endpoint (probably it is determined from gid which seems to be google application id). Is there a way to configure my application to have a webhook, so I can generate these custom links?
There's Google+ Hangouts app for Slack. Here's how it works (after you add the app in your workspace):
you send /hangout command in any Slack channel
slackbot sends an "Only visible to you" message in this channel with a link to start a new hangout. it looks smth like this (I changed data in the link): https://meet.google.com/new?gid=691521906844&gd=THTJ30X6W%7CU01113BD13M%7CD01113BDB5Z%7Csuren%7C%7C1846381238693%7C1%7CB01QFGG5GJF%7CE1MDm4DWcuVa0RbN5ZT9o5KF
when you visit the link, a new meeting is started instantly, and the page shows modal with text "To bring others into this video call, post a link it to your Slack channel" with buttons 'Cancel' and 'Post'.
when you click 'Post', a new message is sent to the Slack channel, where the command was sent. Text is "#Suren Khorenyan has started a Google+ Hangout and would like you to join. Join Hangout." and contains a link to the meet, which was created previously
How can I utilise this integration for another app, like Mattermost (or anything else like Telegram chats via bots)?
As I see, data in the url slightly changes. Probably it's payload for Google Meet to trigger Slack to send a message with link to the channel.
gid seems to be something like google app id
gd seems to be something like google data. If I url-decode it, it becomes THTJ30X6W|U01113BD13M|D01113BDB5Z|suren||1846381238693|1|B01QFGG5GJF|E1MDm4DWcuVa0RbN5ZT9o5KF. This is some kind of payload, separated by pipes (obviously), but I don't know what any part of this means (suren is my username in the Slack workspace, probably this is used for creating an invitation message).
When I click Post, this happens:
a new POST request to https://hooks.slack.com/services/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 is sent with form-data
hangout_id: 1812381238693
hangout_url: https://meet.google.com//abc-iuqx-def
a new message is posted to the Slack channel
Google meet somehow knows where to post back! Is this configured at the Google application (application id is provided via gid)? How can I configure my application for such behaviour? Where can I setup webhook url?
If we breakdown the request, we can see that url contains some parts of the gd payload:
THTJ27X6W - this is the first part of the gd payload
B01ABCD5GJF - last but one
E1MDm4DWcuVa0RbK5ZT9o5KD - the last part of the gd payload
and form-data contains:
hangout_id - this is in the gd payload after my name
hangout_url - obviously, this is the url for the new created meeting
How can I change it for my needs?
I created a new application at Google APIs dashboard (here console.developers.google.com/apis), but can't find any docs for this integration. There's Google+ Hangouts API in API Library, but it says Apps will continue to function until April 25, 2017..
I tried to approach it from another side:
In the API Library there's Google Calendar. I found mattermost-hangout app on GitHub (had to update it a bit, so it works with updated api). Here's how it works:
oauth2 for authorising at google (single account)
it handles POST request, which is meant to be received from Mattermost (triggered by a slash command),
creates a new calendar event using Google Calendar API (with conference),
takes hangouts url from the response and sends a new message in the Mattermost channel with invitation to join the meeting.
But it has some downsides:
you have to use one account to authorise all event creation events (yeah, it can be upgraded to authorise any number of users, but it'll be inconvenient. why to force anyone to provide access to their Google Account, when Google Meet authorisation just happens in browser, we don't need to create events)
account, used for auth, now has events in his calendar. of course, events can be deleted, but it's not the way.
Is there any documentation on utilising gid and gd params?
Generally, I want to find a way to configure a webhook in my app, so when Google Meet finds my application's ID in the gid query param, it looks at the app's config and sends a request to my app (previously configured endpoint (I assume it works this way)).
Of course there's a chance that it's some kind of internal API and it cannot be used by everyone, but I could not find any information on this.
When creating a slack app, it creates a new "channel" in the left hand menu. I want to be able to send a message to specific users and not to all users in a workspace who have integrated with the app.
For example, if I make the following request:
curl -X POST -H 'Content-type: application/json' --data '{"text":"Hello, World!"}' https://hooks.slack.com/services/ABxxx/CDxxx/EFxxxxxx
It will send a message to all users who have integrated with my app with the text "Hello World".
But I only want to send a message to user A without User B being notified.
I don't want to message a user directly and it to appear to come from slack bot. I want the message to appear to come from my bot / app.
How can this be achieved via slack API?
I found this quite hard to explain so please let me know if you'd like me to clarify anything.
The problem of your request that you are using a hook URL which is bound to a particular channel (you pick it during Slack App installation).
To send a direct message to the user on behalf of your bot, you need to consider the following things (this is not the single way to achieve it, but works for me):
Ensure you have a bot registered for your Slack App.
Ask for bot and chat:write:bot permissions during App installation process (example for Slack Install button and here).
Store the bot access token on successful installation (see for details).
Now using the bot access token you can send Slack API requests.
To achieve what you need, use chat.postMessage API method. channel argument can be user ID (e.g. U0G9QF9C6). By setting up as_user argument to true, your message will be always sent on behalf (name and icon) of your bot (seems for bot tokens it's always like this, but it's recommend it to specify it explicitly).
Hope it helps. Feel free to ask for details.
I would like to create a webhook using callfire's api on outbound calls when the "transfer digit" is pressed by the user.
The webhooks method is found here:
https://developers.callfire.com/docs.html#createWebhook
Is shows an example in the post payload like this:
curl -u username:password -H
"Content-Type:application/json" -X POST"
localhost:8080/callfire-api-v2/v2/webhooks"
-d '{"name":"API hook", "resource":"textCampaign", "events":["start", "stop"], "callback":"http://cool.site.xyz/webhook"}'
This example shows the events "start" and "stop" for a "textCampaign" . This is the only list of events I can find in the documentation.
I was hoping to find a list of events for each resource.
I would like to use a webhook to get call results for voice calls without having to poll for them.
It might look like this assuming these events and resources existed:
-d '{"name":"API hook", "resource":"voiceCampaign", "events":["finalCallResult"], "callback":"blah"}'
Is there a way that one infers the resources and specifically, the events that are available for webhooks?
currently API v2 for webhooks is in beta and doesn't have some statuses, events and other things.
I would recommend to use subscriptions in API v1.1 https://www.callfire.com/api-documentation/rest/version/1.1#!/subscription
I am currently trying to develop a script for our backend (PHP) which sends push-notifications to a custom group of users using the REST API https://api.parse.com/1/push.
So far, it is working fine sending single push messages and I could probably loop through the list of users and send the push notifications 1by1.
However, this is obviously not a great idea reporting wise since they will show up as single notifications in Parse and hence it would be more difficult to see the open rate, etc.
My Idea would be to assign a unique Channel to the users which match the filters defined and sends the push to this channel.
I know that I can do this with the object_id using this:
https://parse.com/docs/rest#installations-updating
But the problem is that I only got the installationID or deviceToken (depending on Device) which I can not use to assign a channel.
It would be great if anybody knows a solution for this using the Data I got (installationID and deviceToken)
Thanks a lot
Marco, have a look into the object as, even though their docs don't specify it there is a method to retrieve objectId from the object and pass it to your PHP API.
On Android use:
ParseInstallation.getCurrentInstallation().getObjectId()
Nevertheless, if you cannot figure it out, you can always query the installations endpoint of Parse API
curl -X GET \
-H "X-Parse-Application-Id: <app-key>" \
-H "X-Parse-REST-API-Key: <api-key>" \
-G \
--data-urlencode 'where={"installationId":"sdfddf-344-dfdf-dffd-dffff"}' \
https://api.parse.com/1/installations
To use deviceToken, just edit the where clause.
For more info check their docs query installations and object querying