-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShmoopySoftBluePrismTelegramMessageExample.bprelease
100 lines (84 loc) · 21.7 KB
/
ShmoopySoftBluePrismTelegramMessageExample.bprelease
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?xml version="1.0" encoding="utf-8"?>
<bpr:release xmlns:bpr="http://www.blueprism.co.uk/product/release">
<bpr:name>ShmoopySoftBluePrismTelegramMessageExample</bpr:name>
<bpr:release-notes />
<bpr:created>2020-02-23 15:41:49Z</bpr:created>
<bpr:package-id>12</bpr:package-id>
<bpr:package-name>ShmoopySoft Telegram Example</bpr:package-name>
<bpr:user-created-by>admin</bpr:user-created-by>
<bpr:contents count="4">
<process id="27b7d0ff-921c-4d17-b740-43bd22f44da6" name="Telegram Process" xmlns="http://www.blueprism.co.uk/product/process"><process name="Telegram Process" version="1.0" bpversion="6.4.2.10610" narrative="Sends messages to a Telegram Channel using the Telegram BOT Api." byrefcollection="true"><view><camerax>-44</camerax><cameray>-44</cameray><zoom version="2">0.9375</zoom></view><preconditions /><endpoint narrative="" /><stage stageid="87753ee8-446d-442d-9d4f-4368ab2e85d8" name="Start" type="Start"><loginhibit onsuccess="true" /><narrative></narrative><displayx>45</displayx><displayy>-120</displayy><displaywidth>60</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><onsuccess>99b3a746-6f1f-4d3d-95a0-75a3ab1bf163</onsuccess></stage><stage stageid="65a65826-918d-46f8-930d-549162759156" name="End" type="End"><loginhibit onsuccess="true" /><narrative></narrative><displayx>45</displayx><displayy>120</displayy><displaywidth>60</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /></stage><stage stageid="570e6c91-c6ef-4e2d-8c03-f4544940ff62" name="Stage1" type="ProcessInfo"><loginhibit onsuccess="true" /><narrative></narrative><displayx>-240</displayx><displayy>-90</displayy><displaywidth>330</displaywidth><displayheight>90</displayheight><font family="Arial" size="12" style="Regular" color="000000" /></stage><stage stageid="99b3a746-6f1f-4d3d-95a0-75a3ab1bf163" name="Send Telegram Message" type="Action"><loginhibit onsuccess="true" /><narrative></narrative><displayx>45</displayx><displayy>-45</displayy><displaywidth>120</displaywidth><displayheight>60</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><inputs><input type="text" name="BotAPIKey" narrative="API Key generated by BotFather when you created your bot." expr="[vBotAPIKey]" /><input type="text" name="ChannelChatId" narrative="The Chat Id of your Telegram channel." expr="[vChannelChatId]" /><input type="text" name="MessageText" narrative="The message to send to your Telegram Channel." expr="[vMessageText]" /></inputs><outputs><output type="flag" name="Success" narrative="True if the message was sent." stage="vSuccess" /><output type="text" name="ServerMessage" narrative="The server message returned by the Telegram Api." stage="vServerMessage" /></outputs><onsuccess>388b6822-8388-41ab-9f74-14e959e945ff</onsuccess><resource object="Telegram" action="Send Message" /></stage><stage stageid="5773936d-5fe1-47aa-8bcc-c3a9ab68df47" name="Protected (Private) Data Items" type="Block"><loginhibit onsuccess="true" /><narrative></narrative><displayx>-405</displayx><displayy>90</displayy><displaywidth>330</displaywidth><displayheight>75</displayheight><font family="Arial" size="12" style="Regular" color="99CCFF" /></stage><stage stageid="6d264346-7ef6-4384-8b0e-b6369ca8fb12" name="vMessageText" type="Data"><loginhibit onsuccess="true" /><narrative>The message you want to send (URL-encoded).</narrative><displayx>-240</displayx><displayy>135</displayy><displaywidth>300</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><datatype>text</datatype><initialvalue xml:space="preserve">This message was sent from Blue Prism :-)</initialvalue><private /><alwaysinit /></stage><stage stageid="388b6822-8388-41ab-9f74-14e959e945ff" name="Message Sent?" type="Decision"><loginhibit onsuccess="true" /><narrative></narrative><displayx>45</displayx><displayy>45</displayy><displaywidth>90</displaywidth><displayheight>60</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><decision expression="[vSuccess]" /><ontrue>65a65826-918d-46f8-930d-549162759156</ontrue><onfalse>207fa4ee-cea3-4132-b56a-5bedeb5d2bba</onfalse></stage><stage stageid="207fa4ee-cea3-4132-b56a-5bedeb5d2bba" name="Send Telegram Message Exception" type="Exception"><loginhibit onsuccess="true" /><narrative></narrative><displayx>165</displayx><displayy>45</displayy><displaywidth>90</displaywidth><displayheight>60</displayheight><font family="Arial" size="12" style="Bold" color="FF0000" /><exception type="System Exception" detail="[vServerMessage]" /></stage><stage stageid="e8c8798a-9e4a-4123-b764-f30a8ab4a992" name="vBotAPIKey" type="Data"><loginhibit onsuccess="true" /><narrative>API Key generated by BotFather when you created your bot.</narrative><displayx>-315</displayx><displayy>30</displayy><displaywidth>150</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><datatype>text</datatype><initialvalue xml:space="preserve">!!! INSERT BOT API KEY !!!</initialvalue><private /><alwaysinit /></stage><stage stageid="04658b20-357d-4139-aef3-1f67df947421" name="vChannelChatId" type="Data"><loginhibit onsuccess="true" /><narrative>Chat Id of your channel.</narrative><displayx>-165</displayx><displayy>30</displayy><displaywidth>150</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><datatype>text</datatype><initialvalue xml:space="preserve">!!! INSERT CHANNEL CHAT ID !!!</initialvalue><private /><alwaysinit /></stage><stage stageid="82d6ebb1-1746-47ba-bbbd-b40c8e7204b5" name="Telegram Settings" type="Block"><loginhibit onsuccess="true" /><narrative></narrative><displayx>-405</displayx><displayy>-15</displayy><displaywidth>330</displaywidth><displayheight>75</displayheight><font family="Arial" size="12" style="Regular" color="FF9900" /></stage><stage stageid="9a1f1e1f-4aac-43d3-b656-2b03a55abcc3" name="Note1" type="Note"><loginhibit onsuccess="true" /><narrative>[vBotAPIKey] is the API Key generated by BotFather when you created your bot
[vChannelChatId] is the Chat Id of your channel
[vMessageText] is the message you want to send (URL-encoded)</narrative><displayx>-90</displayx><displayy>-210</displayy><displaywidth>660</displaywidth><displayheight>90</displayheight><font family="Arial" size="15" style="Regular" color="0000FF" /></stage><stage stageid="3e6a0e26-66aa-44b8-86d4-01d39252c338" name="Action Return Values" type="Block"><loginhibit onsuccess="true" /><narrative></narrative><displayx>-405</displayx><displayy>195</displayy><displaywidth>330</displaywidth><displayheight>75</displayheight><font family="Arial" size="12" style="Regular" color="339966" /></stage><stage stageid="f525d178-9395-49be-9973-747a75fb1310" name="vSuccess" type="Data"><loginhibit onsuccess="true" /><narrative>True if sending the message was successful.</narrative><displayx>-165</displayx><displayy>240</displayy><displaywidth>150</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><datatype>flag</datatype><initialvalue /><private /><alwaysinit /></stage><stage stageid="8951ec33-3b27-43f4-b88d-455d25bd78ca" name="vServerMessage" type="Data"><loginhibit onsuccess="true" /><narrative>The message returned by the Telegram server.</narrative><displayx>-315</displayx><displayy>240</displayy><displaywidth>150</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><datatype>text</datatype><initialvalue /><private /><alwaysinit /></stage><stage stageid="3e884798-c89f-431f-a945-701a6f70dcc3" name="Note1" type="Note"><loginhibit onsuccess="true" /><narrative>ShmoopySoft Blue Prism Telegram Message Example</narrative><displayx>-90</displayx><displayy>-285</displayy><displaywidth>660</displaywidth><displayheight>30</displayheight><font family="Arial" size="20" style="Bold" color="000000" /></stage></process></process>
<object id="38fc2df8-79c5-46fa-963d-d1306149973b" name="Telegram" xmlns="http://www.blueprism.co.uk/product/process"><process name="Telegram" version="1.0" bpversion="6.4.2.10610" narrative="A business object that sends a message to a Telegram Channel using the Telegram BOT Api.

This object is set to run in BACKGROUND MODE." byrefcollection="true" type="object" runmode="Background"><appdef><element name="Application Root"><id>4902bd4e-f20a-4df5-a470-e1c3134c6733</id><type>Application</type><basetype>Application</basetype><datatype>unknown</datatype><diagnose>False</diagnose></element></appdef><view><camerax>-164</camerax><cameray>-38</cameray><zoom version="2">0.9375</zoom></view><preconditions /><endpoint narrative="" /><subsheet subsheetid="47886f97-bf3e-48fe-b04c-5cb0392e3bdf" type="CleanUp" published="True"><name>Clean Up</name><view><camerax>0</camerax><cameray>0</cameray><zoom version="2">0.9375</zoom></view></subsheet><subsheet subsheetid="e86f3008-8880-4436-be78-ca5d55fa4691" type="Normal" published="True"><name>Send Message</name><view><camerax>-144</camerax><cameray>-54</cameray><zoom version="2">0.9375</zoom></view></subsheet><stage stageid="e28d5bd9-9141-4524-92b4-a353c7e02d97" name="Start" type="Start"><loginhibit /><narrative></narrative><displayx>15</displayx><displayy>-195</displayy><displaywidth>60</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><onsuccess>403b8c17-61ed-4854-a775-3b3757592779</onsuccess></stage><stage stageid="403b8c17-61ed-4854-a775-3b3757592779" name="End" type="End"><loginhibit /><narrative></narrative><displayx>15</displayx><displayy>0</displayy><displaywidth>60</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /></stage><stage stageid="df5b1324-9ce9-48b8-b2c7-f9974f15c229" name="Stage1" type="ProcessInfo"><loginhibit /><narrative></narrative><displayx>-240</displayx><displayy>-165</displayy><displaywidth>330</displaywidth><displayheight>90</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><references><reference>System.dll</reference></references><imports><import>System</import><import>System.Net</import><import>System.IO</import></imports><language>csharp</language><globalcode><![CDATA[]]></globalcode><code><![CDATA[/*
MIT License
Copyright (c) 2020 ShmoopySoft (Pty) Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/]]></code></stage><stage stageid="4bf5e4ca-d0bb-431d-965b-9964ab45bb26" name="Clean Up" type="SubSheetInfo"><subsheetid>47886f97-bf3e-48fe-b04c-5cb0392e3bdf</subsheetid><loginhibit /><narrative></narrative><displayx>-135</displayx><displayy>-75</displayy><displaywidth>150</displaywidth><displayheight>90</displayheight><font family="Arial" size="12" style="Regular" color="000000" /></stage><stage stageid="ef7675ea-3a56-496f-8f93-532cf8779633" name="Start" type="Start"><subsheetid>47886f97-bf3e-48fe-b04c-5cb0392e3bdf</subsheetid><loginhibit /><narrative></narrative><displayx>15</displayx><displayy>-105</displayy><displaywidth>60</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><onsuccess>6ada2aef-4d2c-4e1a-a27a-3d7af0ba73ea</onsuccess></stage><stage stageid="6ada2aef-4d2c-4e1a-a27a-3d7af0ba73ea" name="End" type="End"><subsheetid>47886f97-bf3e-48fe-b04c-5cb0392e3bdf</subsheetid><loginhibit /><narrative></narrative><displayx>15</displayx><displayy>90</displayy><displaywidth>60</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /></stage><stage stageid="1497d7c3-2117-4bf4-8a7e-7d2810ea5e54" name="Send Message" type="SubSheetInfo"><subsheetid>e86f3008-8880-4436-be78-ca5d55fa4691</subsheetid><loginhibit /><narrative>Send a message to a Telegram Channel.</narrative><displayx>-285</displayx><displayy>-165</displayy><displaywidth>330</displaywidth><displayheight>90</displayheight><font family="Arial" size="12" style="Regular" color="000000" /></stage><stage stageid="dd4ba2ea-f8bb-4fe1-b8fd-a657b3e4fc29" name="Start" type="Start"><subsheetid>e86f3008-8880-4436-be78-ca5d55fa4691</subsheetid><loginhibit /><narrative></narrative><displayx>-15</displayx><displayy>-195</displayy><displaywidth>60</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><inputs><input type="text" name="BotAPIKey" narrative="API Key generated by BotFather when you created your bot." stage="inBotAPIKey" /><input type="text" name="ChannelChatId" narrative="The Chat Id of your Telegram channel." stage="inChannelChatId" /><input type="text" name="MessageText" narrative="The message to send to your Telegram Channel." stage="inMessageText" /></inputs><onsuccess>156e73e9-3ae3-4546-9746-d3beac7dc185</onsuccess></stage><stage stageid="584ca43f-4d95-4180-bc65-be23631ba206" name="End" type="End"><subsheetid>e86f3008-8880-4436-be78-ca5d55fa4691</subsheetid><loginhibit /><narrative></narrative><displayx>-15</displayx><displayy>-45</displayy><displaywidth>60</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><outputs><output type="flag" name="Success" narrative="True if the message was sent." stage="outSuccess" /><output type="text" name="ServerMessage" narrative="The server message returned by the Telegram Api." stage="outServerMessage" /></outputs></stage><stage stageid="156e73e9-3ae3-4546-9746-d3beac7dc185" name="Send Telegram Message" type="Code"><subsheetid>e86f3008-8880-4436-be78-ca5d55fa4691</subsheetid><loginhibit /><narrative></narrative><displayx>-15</displayx><displayy>-120</displayy><displaywidth>120</displaywidth><displayheight>60</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><inputs><input type="text" name="BotAPIKey" expr="[inBotAPIKey]" /><input type="text" name="ChannelChatId" expr="[inChannelChatId]" /><input type="text" name="TelegramURLString" expr="[gvTelegramURLString]" /><input type="text" name="MessageText" expr="[inMessageText]" /></inputs><outputs><output type="flag" name="Success" stage="outSuccess" /><output type="text" name="ServerMessage" stage="outServerMessage" /></outputs><onsuccess>584ca43f-4d95-4180-bc65-be23631ba206</onsuccess><code><![CDATA[/*
MIT License
Copyright (c) 2020 ShmoopySoft (Pty) Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
Success = false;
ServerMessage = "";
TelegramURLString = String.Format(TelegramURLString, BotAPIKey, ChannelChatId, MessageText);
try
{
// Create a request using a URL.
WebRequest request = WebRequest.Create(TelegramURLString);
// Get the response.
WebResponse response = request.GetResponse();
// Display the status.
ServerMessage = (((HttpWebResponse)response).StatusDescription) + ": ";
// Get the stream containing content returned by the server.
// The using block ensures the stream is automatically closed.
using (Stream dataStream = response.GetResponseStream())
{
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);
// Read the content.
ServerMessage += reader.ReadToEnd();
Success = true;
}
// Close the response.
response.Close();
}
catch (Exception ex)
{
// Return an error message.
ServerMessage = ex.ToString();
}]]></code></stage><stage stageid="3e556087-c603-4a77-a79c-7ea6e8966a35" name="outSuccess" type="Data"><subsheetid>e86f3008-8880-4436-be78-ca5d55fa4691</subsheetid><loginhibit /><narrative>True if sending the message was successful.</narrative><displayx>-210</displayx><displayy>105</displayy><displaywidth>150</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><datatype>flag</datatype><initialvalue /><private /><alwaysinit /></stage><stage stageid="5dba8796-7c2b-4827-9066-b9a49094efa5" name="outServerMessage" type="Data"><subsheetid>e86f3008-8880-4436-be78-ca5d55fa4691</subsheetid><loginhibit /><narrative>The message returned by the Telegram server.</narrative><displayx>-360</displayx><displayy>105</displayy><displaywidth>150</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><datatype>text</datatype><initialvalue /><private /><alwaysinit /></stage><stage stageid="3a386c59-1b3c-421c-88a2-79a336476e91" name="gvTelegramURLString" type="Data"><loginhibit /><narrative></narrative><displayx>-240</displayx><displayy>-45</displayy><displaywidth>300</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><datatype>text</datatype><initialvalue xml:space="preserve">https://api.telegram.org/bot{0}/sendMessage?chat_id={1}&text={2}</initialvalue><alwaysinit /></stage><stage stageid="d4a856a3-21bd-4aa3-be01-43bb4dd4b921" name="inBotAPIKey" type="Data"><subsheetid>e86f3008-8880-4436-be78-ca5d55fa4691</subsheetid><loginhibit /><narrative>API Key generated by BotFather when you created your bot.</narrative><displayx>-360</displayx><displayy>-45</displayy><displaywidth>150</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><datatype>text</datatype><initialvalue /><private /><alwaysinit /></stage><stage stageid="a61639ec-a72a-4d44-a5ad-ef6d4fca2beb" name="inChannelChatId" type="Data"><subsheetid>e86f3008-8880-4436-be78-ca5d55fa4691</subsheetid><loginhibit /><narrative>The Chat Id of your Telegram channel.</narrative><displayx>-210</displayx><displayy>-45</displayy><displaywidth>150</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><datatype>text</datatype><initialvalue /><private /><alwaysinit /></stage><stage stageid="11b13f7f-89dc-4d91-9c21-bc3a49856f50" name="inMessageText" type="Data"><subsheetid>e86f3008-8880-4436-be78-ca5d55fa4691</subsheetid><loginhibit /><narrative>The message to send to your Telegram Channel.</narrative><displayx>-300</displayx><displayy>0</displayy><displaywidth>150</displaywidth><displayheight>30</displayheight><font family="Arial" size="12" style="Regular" color="000000" /><datatype>text</datatype><initialvalue /><private /><alwaysinit /></stage><stage stageid="6d046503-b88f-4356-9036-48f717d8b050" name="Input Data Items" type="Block"><subsheetid>e86f3008-8880-4436-be78-ca5d55fa4691</subsheetid><loginhibit /><narrative></narrative><displayx>-450</displayx><displayy>-90</displayy><displaywidth>330</displaywidth><displayheight>120</displayheight><font family="Arial" size="12" style="Regular" color="99CCFF" /></stage><stage stageid="b501ec6c-24f3-41c7-a6b3-2f354b22ab41" name="Output Data Items" type="Block"><subsheetid>e86f3008-8880-4436-be78-ca5d55fa4691</subsheetid><loginhibit /><narrative></narrative><displayx>-450</displayx><displayy>60</displayy><displaywidth>330</displaywidth><displayheight>75</displayheight><font family="Arial" size="12" style="Regular" color="339966" /></stage><stage stageid="ce641448-0e6c-454d-9259-ff602f48abd3" name="Public (Global) Data Items" type="Block"><loginhibit /><narrative></narrative><displayx>-405</displayx><displayy>-90</displayy><displaywidth>330</displaywidth><displayheight>75</displayheight><font family="Arial" size="12" style="Regular" color="99CCFF" /></stage></process></object>
<process-group id="c5dc8723-57b5-4229-96c3-ed72bd5bb8ce" name="Default" isDefaultGroup="True" xmlns="http://www.blueprism.co.uk/product/process-group">
<members>
<process id="27b7d0ff-921c-4d17-b740-43bd22f44da6" />
</members>
</process-group>
<object-group id="5db24851-50a8-41e5-af84-aee00a3a8c08" name="Default" isDefaultGroup="True" xmlns="http://www.blueprism.co.uk/product/object-group">
<members>
<object id="38fc2df8-79c5-46fa-963d-d1306149973b" />
</members>
</object-group>
</bpr:contents>
</bpr:release>