Microsoft Teams Connector for meetup.com

I’m loving my time with Microsoft Teams, the latest Office 365 alternative to Slack and Skype for Business. I’m also loving the local community meetup groups.

I am passionate about learning and encouraging others to grow. If we don’t continuously learn and change (as an individual, a team and as an organisation) we’ll be quickly left behind those that do. Thankfully there are lots of local meetup groups on agile development and cloud technologies in most major cities around the world. The best thing is that almost all of them are FREE.

If your organization has access to Office 365 and you are not currently using Microsoft Teams you can check out the Microsoft Teams product page for more details.

Let’s add a connector for meetup.com to a Microsoft Team channel so that everyone can see upcoming events and get a reminder on the day.

ReminderToday

We could also add a weekly summary listing upcoming meetup events so everyone in the team can plan their networking / permission from their boss / wife.

SummaryList.PNG

Sadly there is no official meetup.com connector or bot available, but the good news is that Microsoft Teams supports incoming webhook connectors, meetup.com have a documented API, and you can join them together with a few lines of PowerShell and an Azure function (or other orchestration engine).

Don’t worry, I’ll share the code and walk you through the process so you can follow along!

Exploring the meetup.com event API with PowerShell

First up let’s see how to get meetup.com data using the PowerShell Invoke-RestMethod and the meetup.com API.

The API documentation for getting event information can be found here: https://www.meetup.com/meetup_api/docs/:urlname/events/#list

To get the next upcoming event for the Melbourne PowerShell Meetup group (https://www.meetup.com/Melbourne-PowerShell-Meetup/) we can invoke a GET request to https://api.meetup.com/Melbourne-Powershell-Meetup/events?&scroll=next_upcoming&page=1

Here is the PowerShell code and (abridged) response:

$uri = "https://api.meetup.com/Melbourne-Powershell-Meetup/events?scroll=next_upcoming&page=1"
Invoke-RestMethod -Uri $Uri -ContentType 'application/json' -Method Get
created        : 1485825097000
id             : 237328935
name           : PowerShell, Pizza and drinks
status         : past
time           : 1488348000000
updated        : 1488851110000
utc_offset     : 39600000
waitlist_count : 0
yes_rsvp_count : 45
venue          : @{id=24366319; name=Readify; lat=-37.820640563964844; lon=144.95005798339844; repinned=False; address_1=Level 17, 727 Collins Street; city=Melbourne; country=au; localized_country_name=Australia}
group          : @{created=1448442961000; name=Melbourne PowerShell Meetup; id=19153447; join_mode=open; lat=-37.810001373291016; lon=144.9600067138672; urlname=Melbourne-PowerShell-Meetup; who=PowerShellers}
link           : https://www.meetup.com/Melbourne-PowerShell-Meetup/events/237328935/
description    :
Readify has kindly agreed to host us again in their offices in Docklands. Please RSVP as we need your names to get you through security!!! Sapien (http://sapien.com/) are sponsoring our food and drinks again. Greatly appreciated!
visibility : public

Pretty cool.

Note that if there is no next upcoming meeting (it has not been scheduled) the response will be empty. You can change the scroll =next_upcoming to scroll=recent_past to get the most recent past event.

$uri = "https://api.meetup.com/Melbourne-Powershell-Meetup/events?scroll=recent_past&page=1"
Invoke-RestMethod -Uri $Uri -ContentType 'application/json' -Method Get

The API responses contain the essential event data. The event time property returned in the response is in Unix epoch time to the milliseconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC)  1 January 1970.

We can assign the response to an $event variable and convert this into local time.

$MeetupGroup = 'Melbourne-Powershell-Meetup'
$uri = "https://api.meetup.com/$MeetupGroup/events?scroll=next_upcoming&page=1"
try {
$event = Invoke-RestMethod -Uri $Uri -ContentType 'application/json' -Method Get
}
catch [System.Exception] {
throw $_
}
$eventTime = (Get-Date 1/1/1970).AddSeconds($event.time/1000).ToLocalTime()
PS C:\WINDOWS\system32> $eventTime
Wednesday, 1 March 2017 5:00:00 PM

PS C:\WINDOWS\system32> $event.venue
id : 24366319
name : Readify
lat : -37.820640563964844
lon : 144.95005798339844
repinned : False
address_1 : Level 17, 727 Collins Street
city : Melbourne
country : au
localized_country_name : Australia

Cool.

We have got the essential meetup info, however additional details such as the group photo  require optional parameters to our invoke request e.g.&fields=group_photo

$uri = "https://api.meetup.com/$MeetupGroup/events?scroll=next_upcoming&page=1&fields=group_photo"
PS C:\WINDOWS\system32> $event.group.photo
id : 444592442
highres_link : http://photos1.meetupstatic.com/photos/event/c/c/d/a/highres_444592442.jpeg
photo_link : http://photos1.meetupstatic.com/photos/event/c/c/d/a/600_444592442.jpeg
thumb_link : http://photos1.meetupstatic.com/photos/event/c/c/d/a/thumb_444592442.jpeg
type : event
base_url : http://photos1.meetupstatic.com

Very cool.

Having figured out how to get all the information we need, the next step is to push the data to Microsoft Teams using an Incoming Webhook connector. I will show you the full powershell script and how to do that in my next post.

ReminderToday

Advertisements