Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Background Information

...

The API write-back can be customized by configuring the REST API Call bot block

...

. Customizing the API write-back

...

and creating an API REST block enables MSPbots to establish a seamless integration with your systems and allows us to retrieve relevant data so we can create reports that will help you monitor your performance, receive alerts, and perform necessary actions programmatically.

This article is a guide on how to configure the REST API Call bot block. It will use the Monitoring [Opened Tickets Today - Template] for_test

...

 bot as an example

...

.

What‘s on this page:

Table of Contents
maxLevel2

Prerequisites

...

  1. A bot of the trigger type has been created.
  2. A widget or dataset has been created to filter integration data according to your needs.
  3. The API documentation for the corresponding integration has been found, and APIs that meet your requirements have been identified.

Required Permissions

...

To follow this guide, you need admin-level permissions to perform the operations.

To set up the bot block

...

...

  1. Go to Bots on the MSPbots menu. 
    MSPbots botsImage Added
  2. Open the bot that where you want need to add the a REST API Call block to, and switch . Let's use the bot Monitoring [Opened Tickets Today - Template] for_test as an example.
    my botImage Added
  3. When the selected bot opens, go to the Design tab. If another window opens, close it.
  4. Click Image Removed and then click Add a Block.
    Image Removed
  5. Click the blue box to select a block.
    Image Removed
  6. Enter REST API Call into the search bar, and then click on REST API Call to add the REST API Call block.
    Image Removed
  7. Click Image Removed and then click Edit to make your settings.
    Image Removed
  8. Enter the url address.
    Image Removed
  9. (Optional)Select an integration.
    • If the RESTful API you want to configure is from an integration integrated with MSPbots, please select that integration.
    • Otherwise, please do not configure this parameter.
      Image Removed
  10.  
    bot designImage Added
  11. In the trigger block, configure the widget or dataset that you have already created as a data source according to your needs. For detailed configuration information of the trigger block, please refer to 2. Set up the bot trigger.
    Image Added
  12. Hover over the horizontal line between the blocks. Click Image Added, select Add a Block, and select the new block. 
    add a blockImage Added
  13. Type REST API Call in the search bar and click REST API Call.
    rest api callImage Added
  14. Next, hover over the ellipsis Image Added for the REST API Call block and select Edit.
    edit blockImage Added
  15. When the REST API Call window opens, enter the url address of the API that will receive requests you want to call, for example,https://mspbotstest.halopsa.com/api/Tickets.
    restful apiImage Added
  16. (Optional) Select an integration.
    If you are configuring a REST API from an existing integration with MSPbots, select that software from the integration list, such as halo. Otherwise, do not configure this parameter and proceed with the next step.
    select integrationImage Added
  17. Select the HTTP method used when calling the API. The commonly used methods when using this block are post and delete. If you want to learn examples of these two methods, please refer to Examples of commonly used HTTP Methods when using the REST API Call block.
    • get - Retrieves
    Select the appropriate method.
    • get: Use to retrieve information from the database without modifying or adding data. Results The results are consistent regardless of how many operations are performed.
    • post: Use to submit Submits data and add adds operations to the server.
    • put: Use to modify Modifies the existing data on the server, . This is similar to POST but focused on modifying rather than except that it modifies instead of adding.
    • delete: Use to remove Removes a specific resource , like deleting and deletes a record in a database.
    • options: A pre-check request made by the browser Before using any of these methods, you can check the browser request to ensure the server accepts the request before sending get, post, put, or delete requests.
      Image Removed
    Set up the headers.
  18. Click Add.
    Image Removed
  19. Please
    • will accept it.
      http methodImage Added
  20. Next, set up the headers and input the relevant key
  21. -value pair.
    Image Removed
    If you need to remove it, click on Delete.
  22. and value. Headers are additional information included in the API call, which may include authentication tokens and content types. 
    Info

    As our Bot already supports authentication information by default, you don't need to add any extra authentication information to REST API Call block.


    header key_valueImage Added
    Click Add to add more keys and values.
    add key-valueImage Added

    To remove a pair of key and value, click Delete


  23. Set up the params.
    there are usually two methods used Select either the URL query and request body method to pass parameters to the server-side: URL query parameters and request body.
    1. query

    1. URL query parameters
    are a way of passing parameters through the URL. In the URL, query parameters usually start with a "?" symbol and are separated by "&" symbols.
    For example:https://www.example.com/path/to/resource?param1=value1&param2=value2
    1. refer to additional parameters or information passed to the server through key-value pairs attached to the URL. Query parameters are commonly used for filtering, sorting, pagination, or passing other optional parameters. They are placed after the question mark symbol (?) in the URL and key-value pairs are separated by an equals sign (=), while multiple query parameters are connected with an ampersand (&). By utilizing URL query parameters, we can pass additional parameters in the API call and customize the results requested.
      query methodImage Added
    2. body
      The request body is the HTTP request data that is included in a POST or PUT request. It is only configured when the method is POST or PUT. This data can be in different
    Image Removedbody:
    The request body is an HTTP request part that contains data, which is usually part of a POST or PUT request. This data can be in various
    1. formats such as JSON, XML, or form data. These parameters are usually used for submitting forms, uploading files, or sending other types of data.
      request bodyImage Added
  24. none
    Image Removed
    1. The params available for the request body method are noneform-data

    Image RemovedX-WWW
    1. x-www-form-urlencoded

    Image Removed
  25. json
    Image Removed
  26. xml
    Image Removed
  27. If there are any other blocks, such as an Alert block, after the REST API Call block, click Next to configure the remaining blocks and then click Finish when you're finished.
    Image Removed
    Image Removed
    If there are no more blocks after the REST API Call block, click on Finish to complete your settings.
    Image Removed
    1. , JSON, and XML
      request body methodsImage Added
  28. Click Next to configure any remaining blocks, and click Finish when done.
  29. Click Save to keep your settings.

Anchor
Examples
Examples
Examples of commonly used HTTP Methods when using the REST API Call block

...

post - Create tickets to the Halo app with the filtered data that meets the criteria.

*For more detailed information, please refer to:How to Create or Modify Halo Tickets using a Rest API-based Bot.

Parameter Field 

Description

url

Fill in the interface address for creating or modifying tickets in Halo: https://{host}/api/Tickets, for example: https://mspbotstest.halopsa.com/api/Tickets.

Integration

Halo

method

post

headers

Can be left empty.

params




  1. Click body.
  2. Select json
  3. Input parameter fields in the JSON body, using the following columns as an example to create tickets.
    Code Block
    [
        {
            "actioncode":0,
            "dateoccurred":"2023-12-15T14:35:55.618Z",
            "summary":"{job_title}",
            "details":"{user_name}",
            "status_id":"2",
            "tickettype_id":"{update_source}"
        }
    ]

    • About the example:
      • The "actioncode", "dateoccurred", "summary", "details", "status_id", "tickettype_id" are from the official API documentation of Halo, https://halo.haloservicedesk.com/apidoc/resources/tickets. These fields are generally obtained from the official API documentation of the integration.

      • The {job_title}, {user_name}, {update_source} are from the data you added in the widget or dataset in the Trigger block. Please note that the format of the field must be {Field}.

Image Added

delete - Delete tickets in the Halo app that meet the filtering criteria.



url

Please fill in the interface address to delete tickets in Halo: https://{host}/api/Tickets, for example: https://mspbotstest.halopsa.com/api/Tickets/{id}.

IntegrationHalo
methoddelete
headers

Can be left empty.

params
  1. Click body.
  2. Select json
  3. Input parameter fields in the JSON body, using the following columns as an example.
    Code Block
    [
        {
             "id":"{ticket_id}"
             "reason":"{delete_reason}"
        }
    ]

    • About the example:
      • The "id", "reason" are from the official API documentation of Halo, https://halo.haloservicedesk.com/apidoc/resources/tickets. These fields are generally obtained from the official API documentation of the integration.

      • The {ticket_id}, {delete_reason} are from the data you added in the widget or dataset in the Trigger block. Please note that the format of the field must be {Field}.

Image Added

Related topics

...

Content by Label
showLabelsfalse
max5
showSpacefalse
excludeCurrenttrue
cqllabel = "bot_block"