This shortcode is no longer actively supported. If you need to make HTTP requests, take a look at the HTTP Requests page.

Shortcode: ^httpPost()

Makes an HTTP POST request to the supplied URL with the JSON payload specified. If no successMessage is specified, this shortcode does not modify the bot's message except on an error.

^httpPost(url, payload[, successMessage[, errorMessage]])

Parameter Sample Value Description
url "" Required. The URL to make a POST request
payload "{\"feedback\": {\"score\": 3}}" Required. JSON payload to send to the URL as the POST body. Must be surrounded by quotes, and each quote backslash-escaped therein.
successMessage "Thanks for the feedback!" Optional. Replaces the entirety of the `httpPost(...)` shortcode if the request is successful.
errorMessage "There was an error processing your feedback." Optional. If the request times out, receives a non-200, or otherwise fails, show this message to the user.

Example Usage

+ provide feedback
- On a scale of 0 to 10, how would you rate our service?
+ (0|1|2|3|4|5|6|7|8|9|10)
- ^httpPost("", "{\"feedback\":{\"score\": \"<star>\"}}", "Thanks for the feedback!", "There was an error processing your feedback.")


The payload parameter is surrounded by quotes, which means you have to backslash-escape the quotes within. The following won't work:

- ^httpPost("", "{"feedback":{"score": "<star>"}}")

and only the following will:

- ^httpPost("", "{\"feedback\":{\"score\": \"<star>\"}}")

If you're someone who's developer-minded (hey, if you're reading about JSON payloads here, you might be!), one trick we like using at Dexter is taking advantage of JavaScript macros to help us compose these payloads and avoid all the escaping.

Here's something we find ourselves doing often: