SendGrid spec differences between versions of Event Notification Webhook - ruby-on-rails

I have an existing rails3 application with SendGrid Service integration based on SMTP relay, and subscribed to Event Notification Webhooks.
I've got reminder email from Service, informing about impending change to SendGrid's service, and I need make some changes to match new version of Event Notification Webhooks v3.
Email I got contains instructions about How To Upgrade:
Review the documentation to understand how to consume this new version's events.
Implement changes on your side to handle the new in-formatting of event data.
Make changes on SendGrid's configuration page
I wounder, what changes now need I implement on my site? I read manual for v3, but there no information about specifications differences between old and new versions.

Previously, the SendGrid event webhook sent improper batched JSON, with documents seperated by line breaks:
{ "email": "john.doe#sendgrid.com", "timestamp": 1337197600, "smtp-id": "<4FB4041F.6080505#sendgrid.com>", "event": "processed" }
{ "email": "john.doe#sendgrid.com", "timestamp": 1337966815, "category": "newuser", "event": "click", "url": "http://sendgrid.com" }
{ "email": "john.doe#sendgrid.com", "timestamp": 1337969592, "smtp-id": "<20120525181309.C1A9B40405B3#Example-Mac.local>", "event": "processed" }
Today, with v3 it sends proper JSON as such:
[
{
"email": "john.doe#sendgrid.com",
"timestamp": 1337197600,
"smtp-id": "<4FB4041F.6080505#sendgrid.com>",
"event": "processed"
},
{
"email": "john.doe#sendgrid.com",
"timestamp": 1337966815,
"category": "newuser",
"event": "click",
"url": "http://sendgrid.com"
},
{
"email": "john.doe#sendgrid.com",
"timestamp": 1337969592,
"smtp-id": "<20120525181309.C1A9B40405B3#Example-Mac.local>",
"event": "processed"
}
]
If you'd previously been dealing with non-batched events you'll need to adjust your code so that it interprets an array, rather than just a single document, and then loops through said array. Put into code:
# This
consume_data(params)
# Becomes this
params.each { |doc|
consume_data(doc)
}

Related

How to allow Microsoft Team attendees to bypass lobby programatically (Microsoft Graph)

I've created an event on a calendar using Calendar API which in turn in the response, it will give me the link to a Microsoft Team meeting link. This is an example data that I've send when creating the event. Also, I'm calling this API as an App not as a user, so basically all 3 attendees are not part of the AD users.
{
"attendees": [
{
"type": "required",
"emailAddress": {
"address": "attendee1#domain.com",
"name": "Attendee 1"
}
},
{
"type": "required",
"emailAddress": {
"address": "attendee2#domain.com",
"name": "Attendee 2"
}
},
{
"type": "required",
"emailAddress": {
"address": "attendee3#domain.com",
"name": "Attendee 3"
}
}
],
"end": {
"dateTime": "2020-11-13T17:32:39.636Z",
"timeZone": "UTC"
},
"start": {
"dateTime": "2020-11-11T16:32:39.636Z",
"timeZone": "UTC"
},
"subject": "My online meeting",
"isOnlineMeeting": true,
"body": {
"content": "Does this time work for you?",
"contentType": "HTML"
},
"onlineMeetingProvider": "teamsForBusiness",
"allowNewTimeProposals": false
}
In the response, I receive something like this:
...
"onlineMeeting": {
"joinUrl": "https://teams.microsoft.com/l/meetup-join/19%3ameeting_NzRmMDIwMWEtNGYyZS00MmNkLTk3NTAtOGxxxxkOGQ4ZDUx%40thread.v2/0?context=%7b%22Tid%22%3a%22b82fec80-bee7-401e-xxxx-8a312e0a62d1%22%2c%22Oid%22%3a%22112d58ba-xxxx-47ce-a1a8-3d0abebead18%22%7d"
}
...
My problem right now is none of the attendees can start the meeting. I wonder if there's a way programatically either when I'm creating the event or updating the online meeting, to enable the attendees to bypass the lobby and start the meeting.
According to your parameter, I think you use Calendar event api to create an online meeting.
I also tried this and found that the attendees needs permission to enter the meeting room while the creater can enter directly. I googled and found no graph api could modify this configuration. The only way to make every attendee join the meeting without permission is changing the meeting option as 'everyone can bypass the lobby'
By the way, admin role account can login the Microsoft teams admin center and automatically allow people in your organization bypass the lobby. This document tells the detail.
Actually, I used Fiddler to catch the changing option request and got a url like https://teams.microsoft.com/api/mt/amer/beta/meetings/v1/options/.... and an access token. I can use them to change the option successfully by sending a http post request. All seems the answer will appear but unfortunately after analizing the access token I found the api needs a permission https://api.spaces.skype.com which is not supported by Azure ad.

Slack API chat.postMessage URL Unfurling

I have a bot app that sends a message to the slack channel. I am using https://api.slack.com/methods/chat.postMessage/ to send messages to the slack channel.
My message sometimes has few links (GIF) which are being rendered in the channel as a plain link.
I want them to be unfurled so that it can display animated GIF on the channel itself.
I tried passing unfurl_links: true to the API parameter however it doesn't work.
Here is my JSON payload
{
"text": "Anniversary Alert :confetti_ball:",
"channel": "C01AGGP63ST",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Anniversary Alert :confetti_ball:\n\nLet's all take a moment to congratulate <#U024FCGPW> on their 10 year anniversary!\n\nWe wish you a very happy anniversary and many more great years ahead with us.\n\nhttps://media0.giphy.com/media/1yjpDZgvGkb6nTynq3/giphy.gif?cid=cbd9d2f95475c686b1a293a6cf43de5f3f640e4eb012f714&rid=giphy.gif"
}
}
],
unfurl_links: true
}
Can someone please help?
Used "attachments" property of the API payload and it unfurls the link
{
"text": "Anniversary Alert :confetti_ball:",
"channel": "C01AGGP63ST",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Anniversary Alert :confetti_ball:\n\nLet's all take a moment to congratulate <#U024FCGPW> on their 10 year anniversary!\n\nWe wish you a very happy anniversary and many more great years ahead with us.\n\nhttps://media0.giphy.com/media/1yjpDZgvGkb6nTynq3/giphy.gif?cid=cbd9d2f95475c686b1a293a6cf43de5f3f640e4eb012f714&rid=giphy.gif"
}
}
],
"attachments": [
{
"text": "",
"image_url": "https://media0.giphy.com/media/1yjpDZgvGkb6nTynq3/giphy.gif?cid=cbd9d2f95475c686b1a293a6cf43de5f3f640e4eb012f714&rid=giphy.gif"
}
]
}
The big gotcha here is that slack unfurl is only triggered when it's a user (bots do not trigger unfurls). Too bad - I'm running into the same issue - unfurl was going to be the way to go but I missed the fine print. I think I'm going to just go with a chat threaded reply (which is way less pretty).

Issue passing in custom parameters to Twilio API

I am attempting to build out a process that will do the following:
New contact lands in my CRM (Podio)
The CRM is triggered to send a POST containing a custom parameter to Twilio which will then initiate a flow
The Twilio flow will call my cell and prompt me to connect to the new contact
Once I press 1, it will take the custom parameter (new contact's phone number) and connect
me to them.
So far, I have been able to get 1-3 with no problem.
However, according to the the API documentation from Twilio I should be able to pass a 3rd parameter in the JSON body of my HTTP request containing custom "Parameters". When I attempt this the parameters aren't showing in the Twilio studio logs and thus I am unable to connect the call to the new lead.
This is the JSON body I am sending over to my Twilio Flow's API
{
"To": "+1xxxxxxxxx1",
"From": "+1xxxxxxxxx2",
"Parameters": {
"name": "example name",
"prospectphone": "+1xxxxxxxxx3"
}
}
When I view the logs in Twilio this is what I received.
{
"contact": {
"channel": {
"address": "+1xxxxxxxxx2"
}
},
"trigger": {
"request": {
"from": "+1xxxxxxxxx2",
"to": "+1xxxxxxxxx1",
"parameters": {}
}
},
"widgets": {},
"flow": {
"flow_sid": "FW936f72c0eb8d3945d0d55c62465e37a8",
"data": {},
"channel": {
"address": "+1xxxxxxxxx2"
},
"sid": "FN955cdb12827f84c8af8fc9b5264e5a28"
}
}
I really can't figure out what I'm missing here? Has anyone run into this before? Is this something you can only do if you're using the SDK or does the additional parameter need to be passed in some other way?
It should be sent x-www-form-urlencoded.
From the documentation:
"Note: the JSON value must explicitly be passed as a string, not as a hash object. Depending on your particular HTTP library, you may need to add quotes or URL encode the JSON string."
Trigger a Twilio Studio Flow Execution via the REST API

"Exception has been thrown by target of an invocation" for /findMeetingTimes request

I am developing a multi-tenant application with the Microsoft Graph API that makes use of the /findMeetingTimes endpoint. After many months of successful requests, on January 15th I started to see some errors coming through for a specific kind of request for some users.
The failing request is a POST to /findMeetingTimes for a single attendee who is the user on who's behalf I'm making the request. The same requests for more than a single attendee are still completing just fine, even if the user who authorized the request is included.
Nothing has changed in my request so this seems like it's either a change on the API side or a change in the user's configuration that's broken their ability to make requests of this type. Any insight on this error in this context would be helpful!
POST https://graph.microsoft.com/v1.0/me/findMeetingTimes
Request body:
{
"attendees": [
{
"emailAddress": {
"address": "[email of user who authorized the request]"
},
"type": "Required"
}
],
"meetingDuration": "PT30M",
"minimumAttendeePercentage": 100,
"maxCandidates": 400,
"timeConstraint": {
"timeslots": [
{
"start": {
"dateTime": [DateTime],
"timeZone": "UTC"
},
"end": {
"dateTime": [DateTime],
"timeZone": "UTC"
}
}
],
"activityDomain": "Unrestricted"
}
}
Returns (one specific example):
500: "Exception has been thrown by the target of an
invocation.", "innerError":{"request-id":"a039234e-f64e-489a-96cf
ff4f686a4389","date":"2018-01-18T01:51:49"}

Google Cloud Endpoints REST Discovery Document missing format

I've upgraded to Cloud Endpoints 2.0 which no longer supports RPC. Therefore, I generated a new discovery document and used the service generator with the REST discovery doc as input in order to generate the client library for my iOS app.
Using the new REST discovery doc I am getting the following error when trying to generate the library:
~/workspace/google-api-objectivec-client-for-rest/Source/Tools/ServiceGenerator/build/Release/ServiceGenerator discovery/servUsApi-v1-rest.discovery --outputDir GTLAPI --gtlrFrameworkName GoogleAPIClientForREST
ERROR: Failure, exception: Looking at parameter 'creditKickbackKash:creditAmount', found a type/format pair of 'number/(null)', and don't how to map that to Objective-C
I was able to manually fix this by adding (in numerous places) in the discovery doc, the "format": "double" key and value for all double parameters. Notice creditAmount below is missing a format, like all other doubles.
The generated discovery doc looks like this:
"creditKickbackKash": {
"httpMethod": "PUT",
"id": "servUsApi.admin.creditKickbackKash",
"parameterOrder": [
"userId",
"creditAmount"
],
"parameters": {
"userId": {
"format": "int64",
"location": "path",
"required": true,
"type": "string"
},
"creditAmount": {
"location": "path",
"required": true,
"type": "number"
}
},
"path": "creditKickbackKash/{userId}/{creditAmount}",
"response": {
"$ref": "ResultDTO"
},
"scopes": [
"https://www.googleapis.com/auth/userinfo.email"
]
}
Is anyone else having this issue? How can I get the discovery document generation to properly format the document including double number types?
I had the same problem. I rolled back from 1.9.50 to 1.9.48 and the problem is gone.

Resources