SurveyMonkey Webhook Event Data - webhooks

I am having difficulty interpreting the results of the webhook event data being returned. If this is the data being returned:
{
"name":"Test Webhook",
"event_id":"EVENT ID HERE",
"object_type":"response",
"object_id":"OBJECT ID HERE",
"event_datetime":"2017-01-12T15:10:18.667701+00:00",
"event_type":"response_completed"
}
I understand that the object_id corresponds to the responseId but I am trying to figure out where the surveyId is?
When we get the event data back, we need to make an API call to:
'surveys/'.$surveyId.'/responses/'.$responseId.'/details' so that we can get the details for processing.
Any help is greatly appreciated.

The webhook data sent to your subscription URL has recently been updated. See the details in the docs.
The payload has some new values, it looks something like this now (depending on your event type):
{
"name": "My Webhook",
"filter_type": "collector", (or survey, it's based on how they configure the webhook)
"filter_id": "123456789",
"event_type": "response_completed",
"event_id": "123456789",
"object_type": "response",
"object_id": "123456",
"event_datetime": "2016-01-01T21:56:31.182613+00:00",
"resources": {
"respondent_id": "123456789",
"recipient_id": "123456789",
"collector_id": "123456789",
"survey_id": "123456789",
"user_id": "123456789"
}
}
So if your event was "response_completed" then object_id is the response ID. If you filtered to a specific type of survey then the filter_id is the survey ID.
As well there is a resources key with a bunch of relevant IDs.

Related

Insert User through Sharepoint batch send HTTP Request Connector

I need to insert items into sharepoint by using SP connector - Send HTTP Request
I send body : "User": { "Key": "i:0#.f|membership|#{first(body('Get_by_mail')?['value'])['Email']}" },
Despite it having successfully created, the sharepoint shows the field without value. Do you have any idea what could be going on?
After reproducing from my end, I could able to make this work using the below JSON in the body while sending the HTTP request.
{
"__metadata": { "type": "SP.Data.<YOUR_LIST_NAME>ListItem" },
"Title": "ccc",
"UserId": 6
}
UserId is the key which represents the column in my Sharepoint which is named as User. Consider if Person is the column in your Sharepoint then make sure you set the key value as PersonId.
Results:
If you look at your JSON:
"User":
{
"Key": "i:0#.f|membership|#{first(body('Get_by_mail')?['value'])['Email']}"
}
you'll notice that you're sending just a key to a key/value pair target. The item inserts because a Key is provided, but it doesn't display anything because you did not provide a Value that would be displayed. Try the following JSON instead:
"User":
{
"Key": "i:0#.f|membership|#{first(body('Get_by_mail')?['value'])['Email']}",
"Value": "i:0#.f|membership|#{first(body('Get_by_mail')?['value'])['Email']}"
}

Adding a mailbox filter to Gmail

I am trying to add a simple mailbox filter to Gmail, and getting error 400. The response text says that "Filter doesn't have any criteria" but of course I believe I do. Here is the payload data:
{
"filter": [{
"id": "ABC12345-2",
"criteria": {
"from": "donald trump"
},
"action": {
"addLabelIds": ["TRASH"]
}
}]
}
This is the URL that I am posting to:
https://gmail.googleapis.com/gmail/v1/users/{userId}/settings/filters
There is no problem with authentication. I have tried it with and without the "id" field. Any ideas about what I am doing wrong?
I'm not sure about your actual script. So I'm not sure about the requirement of {"filter": []}. But when I saw the official document, it seems that the sample request body for the endpoint of POST https://gmail.googleapis.com/gmail/v1/users/{userId}/settings/filters is as follows, when your request body is used.
Sample request body:
{
"id": "###",
"criteria": {"from": "###"},
"action": {"addLabelIds": ["TRASH"]}
}
id: string, The server assigned ID of the filter.
criteria: object (Criteria), Matching criteria for the filter.
action: object (Action), Action that the filter performs.
In this case, even when id is not used, no error occurs.
You can also test above at "Try this API".
References:
Method: users.settings.filters.create
Resource: Filter

BigCommerce API Webhook event payload with address created/updated is missing customer_id

From the WebHook documentation for a store/customer/address/updated/store/customer/address/created events should have following payload:
{
"scope": "store/customer/address/created",
"store_id": "1025646",
"data": {
"type": "customer",
"id": 60,
"address": {
"customer_id": 32
}
},
"hash": "416ca9c01779515de91824aa1cac9012ee691e7a",
"created_at": 1561481620,
"producer": "stores/{store_hash}"
}
However, in the logs we don't see the "address" part. The payload is always coming as:
{
created_at: 1573847377
data: {
id: 2246136
type: "customer"
}
hash: "%hash%"
producer: "%producer%"
scope: "store/customer/address/updated"
store_id: "%storeid%"
}
And the payload.data.id is not the customer id, as fetching customer by given ID always results in 404.
Fetching address with given id is also impossible, as the resource url should include customer_id which is absent in the response.
Contacted BigCommerce support already, but maybe someone had solved this issue already?
Saw relevant question in the BigCommerce's community, but it was also unanswered.
I have encountered a similar problem, and believe I have isolated the conditions under which it occurs.
I am building an app with MEAN stack that uses bigcommerce API/webhooks.
When I tried to create a customer address in-app, it makes an API request to BigCommerce and creates customer addresses in BigCommerce. Via the webhooks, I have implemented the store_customer_address_created hook event.
So there are two cases when the address webhook event is being triggered:
When the customer address is created in-app and it sends an address creation request via the API to BigCommerce.
When the customer address is directly created in the BigCommerce admin.
Here are the responses from those:
"scope": "store/customer/address/created",
"store_id": "1025646",
"data": {
"type": "customer",
"id": 60,
},
"hash": "416ca9c01779515de91824aa1cac9012ee691e7a",
"created_at": 1561481620,
"producer": "stores/{store_hash}"
}
{
"scope": "store/customer/address/created",
"store_id": "1025646",
"data": {
"type": "customer",
"id": 60,
"address": {
"customer_id": 32
}
},
"hash": "416ca9c01779515de91824aa1cac9012ee691e7a",
"created_at": 1561481620,
"producer": "stores/{store_hash}"
}
As you can see, the address field is not included when the customer address is being created by the API. I’m not sure if it is designed by the BigCommerce team, or a special case. But I think we can identify if the customer address is being created by the BigCommerce admin directly or via the API myself based on this distinction.
I believe you are encountering the first case on your end.
I hope this helps and please update me if you have any other opinions.
It is fairly strange to see this webhook response without the address field, and I haven't had any luck replicating this with scope for store/customer/address/updated. Are you working with any other code beyond this webhook or testing the webhook event specifically?

Create room reservations using Domino data services REST API

I've been attempting to create room bookings using the Domino data services REST API but I seem to be missing a trick.
Sending a POST request to the document endpoint I am able to submit and create a reservation document which appears in the Rooms and resource view but the underlying room still shows as available in the notes client.
Here is a sample of the request body:
{
"#authors": [
"CN=Andrew Jones/O=MyCorp",
""
],
"#form": "Reservation",
"From": "CN=Andrew Jones/O=MyCorp",
"Chair": "CN=Andrew Jones/O=MyCorp",
"AltChair": "CN=Andrew Jones/O=MyCorp",
"Principal": "CN=Andrew Jones/O=MyCorp",
"SequenceNum": 1,
"OrgState": "5",
"ResourceType": "1",
"ResourceName": "Room/Office",
"ROOM": "Room/Office#MyCorp",
"Capacity": 1,
"AppointmentType": "3",
"StartTimeZone": "Z=0$DO=1$DL=3 -1 1 10 -1 1$ZX=47$ZN=GMT",
"EndTimeZone": "Z=0$DO=1$DL=3 -1 1 10 -1 1$ZX=47$ZN=GMT",
"TOPIC": "Test",
"SendTo": "CN=Room/O=Office",
"SelectedRR": "CN=Room/O=Office",
"$BusyName":"CN=Room/O=Office",
"Encrypt": "0",
"Categories": "",
"RouteServers": "CN=dominonode/O=MyCorp",
"DeliveredDate": { "data":"2017-03-09T12:38:34Z","type":"datetime"},
"StartDate": {"data":"2017-03-09T20:00:00Z","type":"datetime"},
"StartTime": {"data":"2017-03-09T20:00:00Z","type":"datetime"},
"StartDateTime": {"data":"2017-03-09T20:00:00Z","type":"datetime"},
"EndDate": {"data":"2017-03-09T21:00:00Z","type":"datetime"},
"EndTime": {"data":"2017-09-03T21:00:00Z","type":"datetime"},
"EndDateTime": {"data":"2017-03-09T21:00:00Z","type":"datetime"},
"CalendarDateTime": {"data":"2017-03-09T20:00:00Z","type":"datetime"},
"UpdateSeq": 1,
"Author": "CN=Andrew Jones/O=MyCorp",
"ResourceOwner": "",
"ReservedFor": "CN=Andrew Jones/O=MyCorp",
"ReservedBy": "CN=Andrew Jones/O=MyCorp",
"RQStatus": "A",
"Purpose": "API Test",
"NoticeType": "A",
"Step": 3,
"Site": "Office",
"ReserveDate": {"data":"2017-03-09T20:00:00Z","type":"datetime"}
}
This question suggests I should instead be trying to create a Calendar event but everything I send seems to get rejected with bad request, including the sample
I've also looked at another question which suggests I need to create an appointment and then a notice document for the room, but whilst I can create these documents, it doesn't seem to create a reservation.
Has anyone tried this and got it to work or am I just joining the elephant's graveyard?
I recommend registering a special "user" to act as the booking agent. Then you can use the calendar API to book any room. I think this approach will work better than the data API.
Details:
Register a new "user" to act as the booking agent. Let's call the user "Room Agent/MyCorp". The user's mail file is "mail/ragent.nsf".
Make sure the calendar API is enabled on a mail server with a replica of "mail/ragent.nsf".
When someone uses your tablet app to book a room, the app sends a request to create an event on the room agent's calendar (POST /mail/ragent.nsf/api/calendar/events). The new event should include the room in the list of attendees.
The calendar API sends an invitation to the room (actually the resource database). As long as the room is not already booked, the resource database accepts the invitation and the room becomes busy for that time slot.
This saves you from having to deal with the data API and the intricacies of the resource database. Your tablet app just needs to know the mail server host name, the name of the mail file, and the room agent's credentials. I also like the idea of being able to "audit" all bookings originating from your tablet app. You'll be able to find all the events and notices (accept or decline) in the room agent's mail file.
One disadvantage is booking will not be instantaneous, but the resource database should be able to accept an invitation in a matter of seconds.
By the way, here is some sample JSON input for your POST request:
{
"events":[
{
"summary":"Calendar API test",
"location":"test",
"description":"test",
"start":{"date":"2018-01-01","time":"13:00:00","utc":true},
"end":{"date":"2018-01-01","time":"14:00:00","utc":true},
"organizer":{"email":"ragent#mycorp.com"},
"attendees":[
{
"role":"req-participant",
"userType":"room",
"status":"needs-action",
"rsvp":true,
"email":"room#mycorp.com"
}
]
}
]
}
It's important to specify "userType":"room" for the attendee. Otherwise, the resource database won't accept the invitation.

Insert a card that can be directly responded to

update !important: The API has changed a lot, this question shouldn't be taken into consideration anymore
I am trying to use the REST api (via Node.js API) to create cards that the user can respond to and create an interaction in this way.
Reading the docs the creator attribute is not really specified anywhere, so I have no idea how to insert that.
Also this video doesn't help. Nor this guide =)
I believe there is an URL I should set as callback somehow? I'd like to know how to get these responses, please.
update
This is the card I am sending.
{
bundleId: 'veryuniqueBundle',
id: 'veryuniqueBundle:reply',
text: "want to hear moar?",
menuItems: [
{action: "REPLY"}
]
}
that's the response I get:
{
"collection": "timeline",
"itemId": "119c4dc8-c0ce-4a83-aa76-41aab4e8dbe1",
"operation": "INSERT",
"verifyToken": "42",
"userToken": "id:520ef63cde31145deb000001",
"userActions": [
{
"type": "REPLY"
}
]
}
The problem is, I can't see what the user responded (an text) and the reference to the original card id (or bundle) that was responded to. How can I get those
Cards do not provide a direct callback. Instead, when a user selects a menu item it causes the card to be updated with their menu selection. This change subsequently triggers a notification ping to your timeline subscription.
Follow these steps to detect a menu item selection:
Subscribe to notifications for changes in the timeline collection
{
"collection": "timeline",
"userToken": "awesome_kitty",
"verifyToken": "random_hash_to_verify_referer",
}
Insert a timeline card with a custom menu item
{
"text": "Hello world",
"menuItems": [
{
"action": "CUSTOM",
"id": "complete"
"values": [{
"displayName": "Complete",
"iconUrl": "http://example.com/icons/complete.png"
}]
}
]
}
Select the item on Glass
Receive the notification on your subscription URL
{
"collection": "timeline",
"itemId": "3hidvm0xez6r8_dacdb3103b8b604_h8rpllg",
"operation": "UPDATE",
"userToken": "harold_penguin",
"userActions": [
{
"type": "CUSTOM",
"payload": "PING"
}
]
}
Do cool stuff in your code
???
Profit

Resources