Inbound API
The Inbound API message source allows you to receive messages via local or public HTTP POST or GET requests. Each request creates a new message that triggers your automation. You can also use this source type when you want to manually run automations without relying on any external system.
Local API URL
Messages can be posted to ThinkAutomation via a local API URL. Each message source has a unique local API URL. You can use this endpoint to post messages within your local network.
Info
See Also: Using The Local API
Public API URL
Messages can also be posted to ThinkAutomation via a public API URL. The Web API provides a secure web public endpoint allowing messages to be posted to ThinkAutomation from your own or 3rd party webhooks. Each message source has a unique public API URL. The public Web API Gateway acts as a secure tunnel between web resources and your on-premises or self-hosted ThinkAutomation instance. This allows your ThinkAutomation Server to receive public HTTP requests without being publicly accessible itself.
Info
See Also: Using The Web API
Create Extracted Fields
If you will be receiving Json via HTTP POST or GET requests you can quickly create the required Extract Field actions. Click the Create Fields button and paste a sample of the Json you will be receiving. The required Extract Field actions will then be created in your automation.
Advanced Settings
These settings are optional.
Security
Allowed Methods
By default the API message source will accept both HTTP POST and GET requests. You can limit to POST or GET only.
Require Authentication
By default, callers to the API endpoint do not need to supply any authentication. You can require the caller to provide authentication as an API Key, a Bearer Key or Basic Authentication.
For API Key authentication you specify the header name and value. The caller must add the required header to their requests.
For Bearer Key authentication the caller must add an 'Auth' header with the value Bearer: {value}.
For Basic Authentication the caller must add an 'Auth' header with the value Basic: {base64encoded username:password}.
Any request with invalid authentication will be refused with a 401 Unauthorized response.
Allowed Origins
Specify the website URLs that are permitted to send requests to the public API endpoint. These domains will be used to validate the Origin header of incoming requests. Leave this field blank if you want to allow requests from any domain.
Enter full URLs (e.g., https://www.example.com). Multiple entries may be separated by commas.
If the Reject If Origin Header Is Blank option is enabled, requests will be rejected when no Origin header is sent. This is an additional security control to prevent automated or same-site submissions that do not supply origin information.
Disable Public
You can explicitly disable the message source from receiving public API requests by enabling this option. Any requests to the Public API endpoint will then receive a 404 response.
Friendly Path
By default the URL path for the message source will be /addmessage followed by ?taid={uniquekey}. You can change this to a more friendly path, such as /mycompany/customers/add. The path must be unique. ThinkAutomation will check that the path is valid and unique before saving.
Posting From Your Own Web Forms
The inbound API message source can accept HTTP POST requests from your own web forms. Simply set the form action to the public API URL. For example:
<html>
<body>
<form action="https://api.thinkautomation.com/addmessage?taid=5f7b421a6e1f408c38488397179ab14c6e1f405c7cbf955cd9%2fwxO9qltjQwt0pU7d4GRErBl5njQP%2f" method="post">
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname"><br><br>
<label for="lname">Last name:</label>
<input type="text" id="lname" name="lname"><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
You can add a &redirect={URL} parameter to the API URL query string if you want the server to respond with a 303 Redirect once the message has been accepted.
When the form is posted to ThinkAutomation a new message will be sent to your automation in Json format. For example:
{
"fname": "Alice",
"lname": "Bamber"
}
The RemoteHost, User-Agent & Origin headers will also be added to the ThinkAutomation message headers. The RemoteHost can be accessed using the built-in variable %Msg_FromIp%. You can access these values in your automation using the Set Variable action with the Extract Header Value operation.
You can then use Extract Field actions to extract the data from the message and perform any other automation actions. If your ThinkAutomation Server is not active when a web form is submitted it will be queued by the ThinkAutomation API for up to 48 hours.
Tip
For additional security, ensure the Allowed Origins entry on the message source API properties contains the URL for the site containing the forms you will be posting to ThinkAutomation. This will ensure that form posts will only be accepted from your own website.
Returning Automation Results
By default inbound API requests will respond with a 202 accepted status as soon as the message has been queued (unless a &redirect parameter is specified). You can optionally wait for the automation to complete and return its results by adding &wait=true or &results=true query string parameter to the URL.
If &wait=true is used, the API will return Json with the results of the automation in the MessageResultDetail object of the Json response along with a 200 OK status. The response will include the automation return value:
{
"Success": true,
"Cached": false,
"ErrorMessage": "",
"MessageResultDetail": {
"MessageStoreId": "691c4184c937df003248c029",
"MessageSourceId": "639055d190ca1b46bce7dec4",
"IncomingUid": "691c4184c937df02336b8c2f",
"AutomationId": "639055db90ca1b46bce7dec5",
"AutomationSuccess": true,
"AutomationError": "",
"AutomationReturnValue": "Hello world",
"AutomationReturnValueContentType": "text/plain",
"FileName": "",
"AutomationLog": null,
"ExecutionTime": 5
}
}
The MessageResultDetail.AutomationReturnValue will contain the value returned from your automation. The AutomationLog will only be returned when the local URL is called. It will be null when called via the public URL.
Returning The Return Value Only
If the &results=true parameter is used, then only the automation return value content (or an error message) will be returned along with a 200 OK status. Depending on the content of the automation return value, the result will be served as plain text (text/plain), HTML (text/html) or Json (application/json). If the return value contains Markdown text it will be converted to HTML first. If the return value is already HTML it will be returned as HTML. If the return value is Json it will be returned as Json.
Returning Files
If the &results=true parameter is used and the automation return value is a single local file path (or a variable containing a file path) then the file content will be read and returned. You can return whole html pages, images, PDF files etc. The response Content-Type will be set according to the file extension.
Providing A Link To The Automation Results
If your automation is long running, or you want to provide a static link to the automation results that a user can access later, you can use the %Msg_ResultsUrl% variable. Your automation could include this variable in an outgoing email. A user can click the link to view the automation results at a later date. The %Msg_ResultsUrl% URL is unique for each processed message and contains a secure hash. The link will work for as long as the message is stored in the message store.
Inbound HTTP GET Requests
The inbound API URL also accepts HTTP GET requests. You can specify the message content as part of the URL. Whenever the URL is requested a new ThinkAutomation message will be created and processed.
The body, subject, from & to addresses can be specified on the query string:
https://api.thinkautomation.com/addmessage?taid=5f7b421a6e1f408c38488397179ab14c6e1f405c7cbf955cd9%2fwxO9qltjQwt0pU7d4GRErBl5njQP%2f
&from=alice%40test.com
&subject=unsubscribe
&body=testmessage
The body, subject, from and to query string parameters are optional.
You can add a &redirect={URL} parameter to the API URL query string if you want the server to respond with a 303 Redirect once the message has been accepted.
Passing Field/Value Pairs
You can also pass specific field values using x-fieldname=value. In this case the message passed to ThinkAutomation will be in Json format with each field value (excluding the 'x-').
For example:
https://api.thinkautomation.com/addmessage?taid=5f7b421a6e1f408c38488397179ab14c6e1f405c7cbf955cd9%2fwxO9qltjQwt0pU7d4GRErBl5njQP%2f
&from=alice%40test.com
&subject=unsubscribe
&x-name=Alice+Bamber
&x-email=alice%40test.com
The message body which would be sent to ThinkAutomation as:
{
"name": "Alice Bamber",
"email": "alice@test.com"
}
If you do not want to use field=value pairs you can pass the raw body text using the &body= query string parameter. The ThinkAutomation message body will be set to the contents of the body parameter with no conversion.
The RemoteHost, User-Agent & Origin headers will also be added to the ThinkAutomation message headers. You can access these values in your automation using the Set Variable action with the Extract Header Value operation.
You can then use Extract Field actions to extract the data from the message and perform any other automation actions. For public API requests, if your ThinkAutomation Server is not active when a request is made it will be queued by the ThinkAutomation Gateway for up to 48 hours (or until your ThinkAutomation server is started).
Testing
Click the Test button in the Local API URL or Public API URL boxes to create test POST or GET requests against the local or public endpoints.
On the Send Test API Message form, select HTTP POST or HTTP GET from the Method list.
You can either set the Body Text (enter Json here if you will be sending Json), or you can set Form Fields to specify name, value pairs.
Enable the Wait For Automation Response option to wait for the automation to complete. If this option is enabled, you can select Return Value Only or Json from the Return As selector.
Click Send to send the request. Your automation will then execute and the API response will be displayed.
Tip
You can also use Postman or other tools to send test requests.
Info