[R-pkgs] Introducing teamr Package

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[R-pkgs] Introducing teamr Package

Tanbing Yan
Today I am so pleased to introduce my first CRAN package for sending
formatted messages to Microsoft Teams, teamr

Motivation is simple here. For years I have been using Slack and built many
slash commands and apps using incoming webhooks with R, but ever since I
started to use Teams, I found that we will have the same needs for
communicating with R as well. So with some inspiration from the Python
package pymsteams <https://pypi.org/project/pymsteams/>. I created
teamr package
with the hope that this package will provide a simple and clean way to talk
to Teams from R.

You can install the released version of teamr from CRAN
<https://cran.r-project.org/> with:


And the development version from GitHub <https://github.com/> with:

# install.packages("devtools")


This is a basic example of send a simple titled message to MS Teams:

# initiate new connector card object
cc <- connector_card$new(hookurl =
"https://outlook.office.com/webhook/...")# add text
cc$text("This is text of main body.")# add title
cc$title("This is message title")# add hyperlink button
cc$add_link_button("Read more", "https://www.google.com")# change theme color

We can print out the payload that will be sending to given webhook using

# print out the payload for checking

  hookurl: https://outlook.office.com/webhook/...
  payload:  {"text":"This is text of main body.","title":"This is
message title","potentialAction":[{"@context":"http://schema.org","@type":"ViewAction","name":"Read

Our JSON payload looks good, time to send it out :)

# send to Teams

[1] TRUE

send menthod will return TRUE if send was successful (status code 200). If
it failed, it will return the reponse object for further investigation. Our
message with a link button will looks like this:

        [[alternative HTML version deleted]]

R-packages mailing list
[hidden email]

[hidden email] mailing list -- To UNSUBSCRIBE and more, see
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.