Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
MarkGeurtsen
Support
Support

How to use the "Send structured message with base64 images" block of Teams

This block is meant to provide users with a lot of flexibility in how they want to craft messages posted to teams.
However, this amount of flexibility comes at a cost with regards to user experience.

The following page on the Microsoft Graph API documentation explains how inline images work on the REST API: https://docs.microsoft.com/en-us/graph/api/chatmessage-post?view=graph-rest-1.0&tabs=http#example-5-...

In this block, we have the following input parameters that can be used:

  • team id: The identifier for the team, this can be provided by using the "do lookup" functionality
  • channel id: can also be provided by using the "do lookup" functionality.
  • title: optional input, this can be used to add a title to the message. This will become a <h1> html element and take the full width of the message.
  • item ordering: A comma separated list of elements to be included in the message. The names of the elements have to be used and it defines the order of the elements.
    Elements that are not listed are not included in the resulting message. Elements that are listed need to be provided by the user as inputs.
  • paragraph_1: a textfield that contains a paragraph of text.
  • image_1_width: The width of the first image in pixels. Default value is 300.

  • image_1_heigth: The height of the first image in pixels. Default value is 300.

  • image_1_content_type: The content type of the image. For example: image/png. This parameter must be provided if the image_1 parameter is part of the item_ordering string.

  • image_1_base64: an image as a base64 encoded string. It is not recommended to put large strings in here because the frontend will be loading for a very long time.

  • button_1_label: A label to put on a button if a button is provided in the item_ordering list.
  • button_1_url: A URL that must be triggered when the button is pressed
  • paragraph_2, image_2_width, image_2_height, image_2_content_type, image_2_base64, button_2_label, button_2_url: identical to the elements mentioned before.

How to encode your image as base64

There are various webtools available that will allow you to upload an image and obtain a base64 string of the file contents.
Alternatively this can be done on a linux using base64 -w 0 <filename>. Or it would be possible to do it in any other programming language.
It's definitely easiest doing this in a browser on any webtool though.

Soon we will have blocks that allow you to open a file and get the file back as Base64 encoded. This article will be updated when this becomes possible.

How to provide item ordering

The item_ordering parameter provides the order in which the elements appear in the constructed message. Items that are not listed will not be part of the message. 
The order title, paragraph_1, image_1, paragraph_2, image_2, button_1, button_2 is used when no value is provided.

When providing image_1 and/or image_2, it becomes mandatory to provide the image_content_types as well. Not providing these will cause the block to fail.

An example message

For this message a simple 20x20 image containing a red box was encoded into Base64 format with the following result: 

iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAAeSURBVDhPY3gro0I2GtVMIhrVTCIa1UwiGnmaZVQAKzLWYLcYEB8AAAAASUVORK5CYII=

The following configuration was used for sending a message:

 

input_1.pnginput_2.pnginput_3.png

This results in the following message being posted to a Teams channel:

result_1.png

If we were to change the item_ordering to button_1, title, paragraph_1, image_1 the following would be the result:

result_2.png

 

 

 

 

 

Conclusion

The "send structured message with base 64 images" block enables end users to create rich messages that can be send to Teams channels. Limitations are that it is limited to two images in a single message. Also images have an upper limit in size that can be uploaded through Base64 in Qlik Application Automation. Items ordering can be used to determine in what order elements should appear in the message.

1 Reply
J_Lindberg
Support
Support

Good stuff Mark!