Hi,
I use http request activity to send message to ms teams. In my body I have e.g.
“{‘Text’:‘I start my process’}”
It is possible to use in my text string variable (strText=“I start my process”)? How to write it?
Hi,
I use http request activity to send message to ms teams. In my body I have e.g.
“{‘Text’:‘I start my process’}”
It is possible to use in my text string variable (strText=“I start my process”)? How to write it?
Hi @Krzysztof,
You can use a string templating technique.
Assign
Assign
3. Message (str) = Message.Replace(“PAYLOAD”, Payload)
Your Message variable will then be “{‘Text’:‘I start my process’}”
Try this.
For complex messages to be sent to teams you will need to ensure that you follow a fixed Json format: Sending messages to Connectors and Webhooks - Teams | Microsoft Docs
Challenge
However, you may have two totally new problems when you try sending the Message string to MS Teams
Ok, but then to my body I have to write a variable. Could you prepare send test bot?
I got my output message, but I do not know what to write to my body (http request activity).
Probably the problem is that in my output I get
{‘Text’:‘I start my process’}
against
“{‘Text’:‘I start my process’}”
To body I have to write “{‘Text’:‘I start my process’}”
Hi again @Krzysztof,
I advise you first check the attached xaml file and the Payload.txt file to understand this slightly different approach, which I normally use with MS Teams integration.
Read Json string from a text file, makes it easy to handle Json formatting with double quotes especially if you want to use adaptive cards features in MS Teams.
Use .Replace method any number of times to suit your requirement. For example, if you want to send an adaptive card to teams you can use multiple template string and use .Replace method to allocate any string (variable in UiPath) you wish.
Most important is to replace quotes “'” with double quotes for each instance “”“”
FinalPayload = YourModifiedPayload.Replace("'","""")
Use the HTTP request activity and provide the incoming webhook link and the body will be FinalPayload. It is advisable to use the StatusCode output from HTTP activity to check if the request was a success.
You can reuse the same concept to send messages to any webhook endpoint not only teams.
Result of the run- a message in teams channel.
I have made additional annotations in the xaml file. It has one argument which needs to be provided by you i.e., your teams incoming webhook url.
ProjectFiles : SendTeamsMessage.zip (36.3 KB)
Hope this helps!
The simply solution:
“{‘Text’:'” + strMessage + “'}”
It works.
The problem was that I copy-paste from Forum the ’ is different on the forum please WRITE Step by step the characters from KEYBOARD.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.