Slack slash commands - Variable/Parameters - slack-api

I'm integrating slack with jenkins to use slash commands and want to know if slash commands have variables
What I want to do is something like this;
/this_word_should_be_in_the_url word
and the be able to use word in the URL the slash command will call.
On their page they have something like /weather 94070
Do I have access to the 94070 and somehow set is as a query parameter for the URL.
Is this possible?
Can't find any documentation of this.
Thanks.

Yes. You will have access to the word as per the example that you mentioned.
So for example, if you have the following:
/this_word_should_be_in_the_url word
Then there will be an additional query parameter named text that will contain everything else after the slash command. If you just have one parameter then it should be simple to just trim and use the text query parameter but if you have multiple words and need to split them into something more meaningful, then you might have to use some regex or simple string split function.
It is documented at How do commands work. In this section they have provided the various query parameters that will get passed to your Slash Command External URL. For the weather example, the data posted as per the documentation is:
token=gIkuvaNzQIHg97ATvDxqgjtO
team_id=T0001
team_domain=example
channel_id=C2147483705
channel_name=test
user_id=U2147483697
user_name=Steve
command=/weather
text=94070
response_url=https://hooks.slack.com/commands/1234/5678
Notice the text parameter in the above list.

Related

What language is this Salesforce code that I need to wrap?

I'm working on a Salesforce coding issue. Let me preface this by saying I'm not a developer or Salesforce expert.
What language is this?
Data Type FormulaThis formula references multiple objects
IF (Fulfillment_Submission_Form_URL__c <> "" && CONTAINS(Fulfillment_Submission_Form_URL__c, "qualtrics"),
Fulfillment_Submission_Form_URL__c &
(IF (CONTAINS(Fulfillment_Submission_Form_URL__c,"?SID="), "&", "?")) &
(IF (CONTAINS(TEXT(Type__c), "Site Visit"),
"ContactId="&Statement_of_Work__r.Contractor_Contact__c&
"&CoachType="&SUBSTITUTE(Statement_of_Work__r.Work_Type__r.Name," ","%20")&
"&CoachName="&SUBSTITUTE(Statement_of_Work__r.Contractor_Name__c," ","%20")&
"&InitPartId="&Initiative_Participation__r.Id&
"&InstitutionName="&substitute(substitute(SUBSTITUTE(Institution_Name__c," ","%20"),")",""),"(","")&
"&AccountId="&Initiative_Participation__r.Participating_Institution__r.Id&
"&TodaysDate="&TEXT(TODAY())&
"&SOWLineItemId="&Id&
"&LeaderCollege="&Initiative_Participation__r.ATD_Leader_College_Status__c&
"&SVRCompleted="&TEXT(Count_of_Site_Visit_Fulfillments__c)&
"&SVRRequired="&TEXT(Number_of_Work_Units_Allocated__c),
IF (CONTAINS(TEXT(Type__c), "Feedback"),
"InitPartId="&Initiative_Participation__r.Id&
"&SOWLineItemId="&Id&
"&ReportYear="&Statement_of_Work__r.SOW_Year__c&
"&UserId="&Contractor_User_Id__c&
"&InstitutionName="&substitute(substitute(SUBSTITUTE(Institution_Name__c," ","%20"),")",""),"(",""),
"")
))
,"")
Essentially it's pulling a link from another product we've integrated it with. We then take the basic link and reformat it to add parameters.
The problem is when it pulls in some parameters (ex: CoachName) the Coach entered their name in strange formats like: John (Coach) Doe.
So when the script outputs a URL that includes parameters it breaks at the &CoachName=John%20(Coach)% portion of the URL. Any easy way to work around this by modifying the script? Unfortunately we DO need that (Coach) identifier because the system we push to grabs that as well.
It's formula syntax, I'd compare it to Excel-like formulas. There's self-paced training if you don't want to read documentation. And as it's not exactly code-related you may have more luck on dedicated site, https://salesforce.stackexchange.com/. More admins lurk there.
So you do want that "(Coach)" to go through but it breaks the link? Looks like ( is a special character. It's not technically wrong to have unescaped parentheses, if it breaks that other site you might want to contact them and get their act together. RFC doesn't force us to encode them but looks like you'll have to to solve it at least in the short term: https://webmasters.stackexchange.com/questions/78110/is-it-bad-to-use-parentheses-in-a-url
Instead of poor man's encoding (SUBSTITUTE(Statement_of_Work__r.Contractor_Name__c," ","%20") try using proper URLENCODE(Statement_of_Work__r.Contractor_Name__c).
Or there's bit more "pro" function called URLFOR but the documentation doesn't make it very clear how powerful the 3rd parameter is with the braces [key1 = value1, key2 = value2] syntax. Basically just pass the parameters and let SF worry about encoding special characters etc.
Read my answer https://salesforce.stackexchange.com/a/46445/799 and there are some examples on the net like https://support.docusign.com/s/articles/DFS-URL-buttons-for-Lightning-basic-setup-limitations?language=en_US&rsc_301

Sql Server Full-Text Search with wild card suffix using Entity Framework 6 Interceptor

http://www.entityframework.info/Home/FullTextSearch
This example works fine for full word searches but does not talk about how to implement wild card suffix.
For example, I can do the following in SQL and get results for "bill" or "billy" using '*' in the end. How do I add that to my Interceptor?
select * from dbo.messagethread a
where contains(Text, '"bil*"')
If you look at that example code in that link above, I was thinking if something like this (below) is possible, but obviously that does not work as it is getting added to the parameter name not the value.
string.Format(#"contains([$1].[$2], #{0} *)", parameter.ParameterName));
There are questions like this one which talk about wildcards in full-text in SQL.
Look for this line in the example link provided in the question.
parameter.Value = value;
Then, to do prefix match, just add this line below that.
value = $"\"{value}*\""; // prefix match
We're basically changing the value of the parameter to have the * in it inside double quotes.
Now if you search for "bil", you get results for "bill"/"billy" and so on.

Add # hashtag before parameters in URL

I'm creating a dynamic website which is displaying many products. There are also filters like price (from - to), year (from-to) etc. I need to put # symbol before the filter parameters in URL because of Googlebot indexing. But I have no idea how to do it and found no documentation on the internet.
I think it could be done with AJAX script but I don't know where to start.
The question is:
How do I insert a # hash symbol before parameters in URL?
I've got this:
http://domain.com/pd/?rps=100&a=2001
and I need to make it look like
http://domain.com/pd/#rps=100&a=2001
Why do you want to replace the "?" with "#". For well optimised url to seo, you can leave them unchanged. You can also use Google Webmaster Tool to declare your url parameters. Here is another resource for you to optimize your url :Faceted navigation

Attaching parameters to the URL of a Rails route

This is a silly question but weird enough I Googled it, I am sure i had seen it before in Rails guides but now couldn't find it.
I want to attach parameters to my URL.
My initial url is this: "http://localhost:3000/pharmacy/patients"
Now I attach one URL with string concatination in JavaScript and it will be this:
"http://localhost:3000/pharmacy/patients?provider=234"
And still good.
Now I want to attach a second parameter named thera_class and its values are strings with spaces between them like "Nasal Congestion"
If I want to also concatenate that second parameter to it, How would the URL look like?
The way it would look is:
http://localhost:3000/pharmacy/patients?provider=234&thera_class=Nasal Congestion
To be extra strict, spaces are replaced by %20 in the URL:
http://localhost:3000/pharmacy/patients?provider=234&thera_class=Nasal%20Congestion

RESTful url in android with (')

I am developing an android application and I am using a RESTful service to connect to SQL azure database. I need to use this RESTful url:
http://example.com/wcfDataService1.svc/wn_synset?$filter=word%20eq%20'child's_game'&$select=synset_id,w_num,word,ss_type,wn_gloss/gloss&$expand=wn_gloss
As you can see am looking for this word (child's_game) in the table wn_synset.
The problem is the single quote (') in child's_game. As you can see it puts the word inside quotes '...' so when it finds the quote in child's_game it thinks it is the end of the word and the rest is error.
How can i solve this problem?
You can url-encode the ' symbols with %27. See http://www.w3schools.com/tags/ref_urlencode.asp and try it in the "Try it yourself" section.
Edit: (moved correct guess from comments to the answer itself)
Or is it just, that the SQL-Server on the server side gets it wrong? Like it builds a select * from wn_synset where word = 'child's game' and there's the error? Then you'll have to look up how you escape single quotes for your database -- probably it's by using two single quotes (''), so perhaps try to send child''s game instead of child's game.
There is no problem, or in other words, your URL is not a URL. If it were a URL, ther wouldn't be a '. Of course, you can have this ' in your URL, so to speak. But it needs to be escaped in accordance with the rules for URLs. You may want to look at URLEncoder and Uri.

Resources