It appears that through the alert() function you can code a message to be sent, but what about the webhook?
I would like to use capitalise.ai, and they require to set in the alert both a webhook (https://tvwebhook.capitalise.ai) and a message, for example {"alertId": "b2f0d9f2-a848-48e4-8218-70350b24xxxx"} which will trigger a specific action, for example to buy or to sell.
Fact is, if I set in the UI an alert for a strategy I have created in Tradingview, there will be only one alert for all the possible events, and therefore only one message, but then how can I tell Capitalise.ai if the alert is for selling or buying?
I could do something like
if enterLong
alert("message 1))
else if enterShort
alert("message2"))
But then where do I put the webhook?
Thank you
You need different messages for different orders.
Check out this tutorial.
Your code must include something like this :
alert(jsondata, alert.freq_once_per_bar)
with jsondata a string in the json format.
Then your jsondata (your message) will be sent to your webhook.
To create the weebhook, look in the Alert Menu from your Tradingview Chart :
Choose the nae of your strategy in the Condition (Bybit Bot in the screenshot),
and create a 'Open-ended alert' alert :
Then go on the notification menu to give the url for the webhook :
I do something like this with a discord alert. Create your message in the script and not in the message box on the alert fly out.
I use this in a library
export GetDiscordJson(string userName, string avatar_url, string content, string title, string url, string description, string _fields, string _footer, string _authObject, string clr) =>
//parameters with _ lead are already formatted for the json end object
_username = jsonKeyValuePair("username", userName)
_avatarUrl = jsonKeyValuePair("avatar_url", avatar_url)
_content = jsonKeyValuePair("content", content)
_title = jsonKeyValuePair("title", title) // title = ticker
_url = jsonKeyValuePair("url", url)
_description = jsonKeyValuePair("description", description)
_color = jsonKeyValuePair("color", clr)
_embeds = str.format("\"embeds\":[{0}\n{1},\n{2},\n{3},\n{4},\n{5},\n{6},\n{7}\n{8}]", "{", _authObject, _title, _url, _description, _color, _fields, _footer, "}")
str.format("{0}\n{1},\n{2},\n{3},\n{4}\n{5}", "{",_username, _avatarUrl, _content, _embeds, "}")
Then in the indicator call it on each kind of alert
if enterLong
content = w.GetDiscordJson(_botName, _avatarURL, contMessage, syminfo.ticker, _titleURL, chartTimeframe, _fields, _footerObject, _authObject, _color )
alert(content, alert.freq_once_per_bar)
Simply put the webhook json string you get from capitalise into the alert(Capitalise-string,alert-frequency) command in your script. and then you can based on condition in your script decide which capitalise string to send. The alarm setup can only be done once with just the capitalise webhook URL, and leaving the message box empty.
Hope that’s understandable 😀
OK - be gentle with me as I'm not techie
I'm wanting to create a set of data driven tests for a service where both the request and response wrap all the elements into CDATA
So to map the input fields to my data source I've created a request without the CDATA so that I can map every request field to my data source.
But of course, the service is expecting to see these fields in CDATA so the requests fail. I know I need to find a way to convert the mapped fields back to CDATA
Have tried adding a Event, Requestfilter.filterRequest with the following:
//This event handler will affect all requests
if( request.requestContent == null )
return log.info "Old request without CDATA : " + request.requestContent
def requestContent = request.requestContent
//requestContent = requestContent.replaceAll( "<!\\[CDATA\\[", "" )
//requestContent = requestContent.replaceAll( "]]>", "" )
requestContent = requestContent.replace ( "<Input>" , "<![CDATA[<Input>" )
requestContent = requestContent.replace ( "</Input>" , "</Input>]]>" )
log.info "New request with CDATA : " + request.requestContent
request.requestContent = requestContent
Tried testing this event in a manual test step and the first call fails with Unmarshalling Error: unexpected element (uri:"", local:"Input"). Expected elements are (none)
A second call concatenates the event but actually works ok
A third call concatenates the event and fails with Unmarshalling Error: String ']]>' not allowed in textual content, except as the end marker of CDATA section
at [row,col {unknown-source}]: [68,20]
I know I'm close to getting this working so would appreciate some help !
I am using AIM Aegis Implicit Mail to send Implicit ssl mails.
When using subject and body in a mail message all is fine, however when I use alternate views my mai lhas an empty body. This alternate view setup works with mailmessage and has html and text body depending on the reciving client but I must use MimeMailMessage which looks ok in the debug code but is empty when recivied in the mailbox.
Here's the code:
string plainTextBody = "Welkom.";
AlternateView plainTextView =
AlternateView.CreateAlternateViewFromString(
plainTextBody, null, MediaTypeNames.Text.Plain);
plainTextView.ContentType = new System.Net.Mime.ContentType("text/plain");
mail.AlternateViews.Add(plainTextView);
string htmlBody = #"<html><body><img src=""cid:logo""><br /> Welkom </body></html>";
AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlBody, null, MediaTypeNames.Text.Html);
htmlView.ContentType = new System.Net.Mime.ContentType("text/html");
string imageSource = Path.Combine(HttpRuntime.AppDomainAppPath, #"Content\Images\Logob.png");
LinkedResource PictureRes = new LinkedResource(imageSource, MediaTypeNames.Image.Jpeg);
PictureRes.ContentId = "logo";
htmlView.LinkedResources.Add(PictureRes);
mail.AlternateViews.Add(htmlView);
Aim is not providing AlternativeView, however you can use inline attachments to put your images and directly set HTML code in your message body. try to download the sample code and have a look on how inline attachments are working
The specific scenario that we are attempting to solve for our API solution is to create an envelope using a template and to replace the template document with a user specified document. DocuSign's documentation on creating a composite template show the steps for the serverside template and inline templates clearly, and this functionality is working correctly for us. However, the portion of the XML string containing the alternate document does not affect the template. Here is the link to DocuSign's example followed by the code snippet regarding document portion of the composite template.
https://www.docusign.com/p/APIGuide/Content/Sending%20Group/Rules%20for%20CompositeTemplate%20Usage.htm
<Document>
<ID>1</ID>
<Name>Form Document</Name>
<PDFBytes>PDF_BYTES_GO_HERE</PDFBytes>
<TransformPdfFields>true</TransformPdfFields>
<FileExtension>pdf</FileExtension>
</Document>
We have tried multiple variations of breaking down the pdf into bytes to insert into the "PDF_BYTES_GO_HERE" portion.
Here is the code we used to get the pdf bytes, convert them to a string and insert into the tag.
Dim fs As FileStream
fs = File.Open(filePath, FileMode.Open)
Dim bytes As Byte() = New Byte(fs.Length - 1) {}
fs.Read(bytes, 0, System.Convert.ToInt32(fs.Length))
fs.Close()
Dim byteString As String = System.Convert.ToBase64String(bytes, 0, bytes.Length)
byteString is the string that we then use in the XML string.
"<Document>" & _
"<documentId>1</documentId>" & _
"<name>DOCUSIGN API TEST</name>" & _
"<PDFBytes>" & byteString & "</PDFBytes>" & _
"<TransformPdfFields>false</TransformPdfFields>" & _
"<FileExtension>pdf</FileExtension>" & _
"</Document>" & _
What type of data is expected within the tag and what is the best way to convert a pdf into that data?
Based on the documentation you've linked to, and the code sample you included, it seems as though you're using the DocuSign SOAP API. If that's the case, then the DocuSign SOAP API guide will be a useful reference for you. As the guide specifies, the PDFBytes property expects a base64-encoded byte stream that represents the document contents:
Are you manually constructing the XML payload? If so, you might instead want to consider adding a Service Reference to your project for the DocuSign WSDL, and then using the proxy classes (i.e., DocuSign object model) that come from that to construct the payload and subsequently send the envelope. If you go this route, the API guide contains code examples in a couple different languages that illustrate the setting of the PDFBytes property during Envelope creation -- starting on page 62. For example:
C#
// Attach the document(s)
envelope.Documents = new DocuSignWeb.Document[1];
DocuSignWeb.Document doc = new DocuSignWeb.Document();
doc.ID = "1";
doc.Name = "Document Name";
doc.PDFBytes = [Location of Document];
envelope.Documents[0] = doc;
PHP
// Attach the document
$doc = new Document();
$doc->ID = "1";
$doc->Name = "Picture PDF";
$doc->PDFBytes = file_get_contents("docs/picturePdf.pdf");
$env->Documents = array($doc);
Perhaps try modeling your approach after one of these examples (in VB, rather than C# or PHP)?
I have a mail-in database application and I am finding that occasionally an email is received with an attachment that is not part of the Body field and therefor not able to be "seen" by rtItem.EmbeddedObjects.
How do I identify that there is an attachment if it is not in the Body and once I do that how do I get a handle on it?
I need to determine the type of attachment (PDF, JPG, DOC, XLS, etc.), detach it and then process it based on the extension.
Here is the various If statements that do all the checking of the Body (RTF) field and the associated EmbeddedObjects. This does not catch an attachment that is "outside" of the Body.
Set rtItem = mailDoc.Getfirstitem("Body")
If ( rtItem.Type = RICHTEXT ) Then
If Not (IsEmpty(rtItem.EmbeddedObjects)) Then
ForAll o In rtItem.EmbeddedObjects
If (o.Type = EMBED_ATTACHMENT) Then
noAttachment = True
Else
noAttachment = True
End If
End ForAll
Else
noAttachment = True
End if
Else
noRTF = True
End If
I also have a document with nothing in the Body but $File contains the attachment name. How do you find that?
Youll need to get at those attachments using the EmbeddedObjects property of the NotesDocument. The union of that property plus all the EmbeddedObjects properties of all rich text items gives you access to all the attachments. Note that usually you only need to worry about the Body rich text item.
FYI we've hit a similar problem when the mail server was running out of disk space, or if a virus scanner blocked access to the attachment