top of page
Search
  • benhaguenz

Automatically posting XKCD in Teams

A friend recently mentioned that they used to have a regular post of an XKCD, https://xkcd.com/, cartoon in Zoom, but that they'd lost that when moving to Teams. I wondered if it was possible to recreate that with Microsoft's Power Automate, and after some experimentation it appears that it is.


First, create a blank Custom Connector in Power Automate. Give it a sensible name, I choose XKCD, and then enable the Swagger editor.

Replace the default contents with the below code and save the connector.

swagger: '2.0'
info: {title: XKCD, description: XKCD, version: '1.0'}
host: xkcd.com
basePath: /
schemes: [https]
consumes: []
produces: []
paths:
  /info.0.json:
    get:
      responses:
        '200':
          description: OK
          schema:
            type: object
            properties:
              month: {type: string, description: month}
              num: {type: integer, format: int32, description: num}
              link: {type: string, description: link}
              year: {type: string, description: year}
              news: {type: string, description: news}
              safe_title: {type: string, description: safe_title}
              transcript: {type: string, description: transcript}
              alt: {type: string, description: alt}
              img: {type: string, description: img}
              title: {type: string, description: title}
              day: {type: string, description: day}
      summary: Get latest image
      operationId: GetLatest
      parameters: []
      description: Gets the latest XKCD comic
definitions: {}
parameters: {}
responses: {}
securityDefinitions: {}
security: []
tags: []

Next, you need to create a new Scheduled Flow. The recurrence settings should look like:


Adjust depending on timezone and then add a Custom action. You should see one with the same name as the Custom Connector you created earlier.

After that add a new Teams Post adaptive card in chat or channel action. The settings should look like:

I created a separate channel, but you can post to any channel.

The card contents are JSON,

{
    "type": "AdaptiveCard",
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.2",
    "body": [
        {
            "type": "TextBlock",
            "text": "XKCD @{outputs('Get_latest_image')?['body/num']}",
            "wrap": true
        },
        {
            "type": "Image",
            "url": "@{outputs('Get_latest_image')?['body/img']}"
        },
        {
            "type": "TextBlock",
            "text": "@{outputs('Get_latest_image')?['body/alt']}",
            "wrap": true
        }
    ]
}

This site, https://adaptivecards.io/designer/ is quite useful for designing card layouts.

The final results should look like:

If you test the flow you should get an output that looks something like:


6 views0 comments

Recent Posts

See All

Downloading PGN files from LiveChess Cloud

Quite a few places are using LiveChess Cloud from DGT to broadcast chess games over the internet, e.g. http://view.livechesscloud.com/ba9ad40e-88e7-491b-b48f-4efd5a761ed2 or https://view.livechessclou

bottom of page