Using the Make API call step in an AI agent for messaging (Legacy)

This article describes functionality available only to customers who had any drafted or published AI agents as of February 2, 2025. For information about equivalent functionality on AI agents - Advanced, see Integrating other platforms with AI agents - Advanced.
The Make API call step allows you to configure an API call out to another system, such as an internal CRM or ERP, or to push conversation details to an external endpoint, like Amazon Event Bridge or Google Analytics.

In this article, we’ll walk you through the procedures involved in including and configuring the step in an AI agent for messaging.

For an overview of the Make API call step and its configuration rules, see Understanding AI agent step types: Make API call.

This article includes the following sections:

Adding a Make API call step to your AI agent

Adding API details

Saving variables from the API response

About the step branches

Adding a Make API call step to your AI agent

Adding the Make API call step to your AI agent includes a number of distinct tasks.

The procedures below assume you have already created an AI agent for messaging, and are adding this step to that AI agent.
Note: If the system being called doesn't respond within 10 seconds, the call will time out.

To add a Make API call step

In Admin Center, click AI in the sidebar, then select AI agents > AI agents.

Click the name of the AI agent you want to edit.

Click the Answers tab, then create a new answer or open an existing answer.

In bot builder, click the Add step icon where you want to insert the step, either at the end of a branch, or between two existing steps.

In the Configuration panel, click Make API call.

Enter descriptive information for the step.

Name: A name for the call that makes it easy for your team to identify.

Description (optional): A short description of the action taken by the call.

This information will not be visible to customers.

Continue with the procedure described in Adding API details.

Adding API details

Use the API details section to configure the HTTP call you want to make including the HTTP request method, location of the external resource, and adding headers if needed. The steps below are a continuation of the procedure in the previous section.

The API calls you configure here originate from Zendesk public IP addresses. To help ensure these calls work as expected, make sure you configure your firewall settings as needed. For more information, see Configuring your firewall for use with Zendesk.

To add the API details

In the Configuration panel, click API details.

Select a Request method:

GET retrieves an external resource from the API service. This is the most commonly used method.

POST sends data to create a resource in an external system. If the resource already exists, the data sent modifies the resource.

PUT sends data to update a resource.

PATCH sends data to update a resource at an external site. It is used to apply partial modifications to the resource.

DELETE removes the resource at the external location.

Enter an Endpoint URL.
The endpoint URL is the location of the external resource you are connecting to. The endpoint URL supports the https://protocol. You can include variables in the URL's path or query string values. For more information, see Passing variables in an API call.

Optionally, select a connection to authenticate the API call.
Note: You must create a connection before using it in the Make API call step.

If needed, enter the key and value for an optional header.
Important: Don't use headers for authentication. Use API connections instead.
Make API call steps that include authentication-related headers, such as authorization or x-api-key, automatically fail. If a Make API call step fails, the conversation follows the step's API call failed branch.

Click Make API Call to test the API call.
If variables are added to the step's URL or header, you can include optional test data to your external service to check if the API call is working as expected. Note this will make an HTTP request to the configured endpoint URL.

Passing variables in an API call

When you enter an Endpoint URL for an API call, you can include variables in the URL's path or query string values. This lets you pass data from the conversation to the external system.

For example, a messaging AI agent can prompt a customer to provide an order number using an Ask for details step. The AI agent can then use a Make API call step get the shipping status for the order from your online store.

You can't use variables in the domain or subdomain of an endpoint URL. The following table includes examples of valid and invalid Endpoint URL values.

Valid Endpoint URL | Invalid Endpoint URL

https://myshopify.com/admin/api/orders/order_number.json
Retrieve an order by specifying the order ID from Shopify.

https://domain.com/api/search?input=value

Variables can’t be added to domain/subdomain

https://maps.googleapis.com/maps/api/place?input=city_name

Retrieve a location by keyword searches from Google’s places API.

https://example.com/api/search?key=value

Variables can’t be added to query string key

If a variable is invalid or empty, the AI agent skips the variable during a conversation.

Note: Variable values are not auto-translated. Keep this in mind if you use automatic translation in your messaging conversations.

Saving variables from the API response

After configuring details and testing the API call, you can save values from the API call's JSON response as variables. You can save up to 12 variables in a Make API call step. Only the first 280 characters of a variable's value are saved.

To create a variable from the Response data

In the Configuration panel, click Make API call.

Expand the accordion and identify the data from external system that you want to turn into a variable.

Tip: Switch to the Response body tab to view the raw response that has came back from the external system.

Click Save.

Give the new variable a name.
Variable names must include only lowercase letters, numbers, and underscores.

Passing array variables in an API call

You can pass array variables using Make API call and providing a URL to the external system. The external system must have an API endpoint. An API endpoint is a URL where the API receives requests and sends responses, allowing two systems to interact. Responses are rendered in the JavaScript Object Notation (JSON) format, as shown in the following example.
{
"info": {
"count": 50,
"pages": 2,
"next": "https://mycompany.com/api/orders?page=2",
"prev": null
},
"results": [
{
"id": 1052,
"name": "Alexander Cummings",
“address”: “123 MyStreet”,
"Item": "belt",
"price": "15.00",
"image": "https://mycompany.com/api/orders/avatar/1.jpeg",
…

Only the first items in the array variable are displayed in Admin Center to help visualize what data is returned. For example, in the above JSON output, id, name, address, item, price, and imageare all displayed. This data is typically passed to a carousel, however the carousel can display only up to 10 items.
Note: Only the first 280 characters of a property value appear in the response.

Nested JSON arrays can also be saved as array variables. For example, given the following JSON output, lastnameand firstnamecan be saved as separate array variables.
"name":
{
"lastname": "Cummings”,
"firstname": “Alexander"
},

You cannot edit the array or array values within the carousel configuration in Admin Center. If you need to change any data, you must delete the array in Admin Center and create a new one.

If the returned variable is null, the item is not displayed in the carousel. For example, in the following scenario, suppose the value of the variable {{customer.order}} is empty. For card 1, the card will be rendered with a partial title of "Order number". For card 2, the resulting title is empty so card 2 will not be rendered.
Card 1
Title: Order number {{customer.order}}
Description: Here's your order {{product.description}}

Card 2
Title: {{customer.order}}
Description: Here's your order {{product.description}}

Example

In this example, an array variable is created using an API endpoint that returns an array of orders. The orders array is specified by the "results" property in the following API response snippet.

{
"info": {
"count": 5,
"pages": 1
},
"results": [
{
"createdAt": "July 10, 2023",
"name": "Connie Stokes",
"Shippingaddress": "123 Street, City, State",
"order": {
"Status": "Ordered",
"Image": "https://images.pexels.com/photos/1484808/pexels-photo-1484808.jpeg"
},
"Quantity": 1,
"Price": 45,
"Item": "Shirt",
"id": "1"
},
…

This example uses Make API call to create the array variable and then uses a dynamic carousel to display the results to an end user.

To create the array

In the Configuration panel, click Make API call.

Enter orders for the name.

In the Configuration panel, click API details.

Click the Request method dropdown and select GET.

Enter the URL for the Endpoint URL.

For Authentication, select your authentication method.
For more information, see Creating connections to integrate with external services.

Click Make API call.

Click Save next to results.

From the Value dropdown, select Order and then Image.
Use the default variable name (image).

Click Add item and repeat the step above to create items for Order Status and Item.
You can add up to 12 items (or key-value pairs).

Click Save.

To create the dynamic carousel

In bot builder, click Add step under API call successful and select Add carousel.

In the Configuration panel, click Convert to dynamic message.

In the Array dropdown, click results. This is the array that you created above.

For title, click the plus sign and select results.item.
You can enter up to 128 characters for the title and description.

For Button link, click the plus sign and select results.image.

For Button text, click the plus sign and select results.status.

For Image link, click the plus sign and select results.image.

Click Done.

Here's an example dynamic carousel.

About the step branches

The Make API call step is a branching step. Adding this step splits the AI agent responses depending on whether the API request was successfully executed.

The AI agent will move down the failure branch in the following cases:

The API returns a 400 or 500 response code.

One of the saved variables is missing or has a null value.

The AI agent will move down the success branch in all other cases.

If you use the Make API call step, you acknowledge that the external system that you connect with is a Non-Zendesk Service (as defined in the Zendesk Customer Agreement). Zendesk does not operate or control the Non-Zendesk Services enabled through the use of the bot builder extensions feature and Zendesk is not responsible for the legal or regulatory compliance obligations of you or the Non-Zendesk Services.