> ## Documentation Index
> Fetch the complete documentation index at: https://watermelon.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Shopify template

The Shopify Custom Action connects your Agent to your Shopify store so it can retrieve product, order, or fulfillment information and use it when answering customer questions.

This setup includes:

* A predefined OpenAPI schema for Shopify
* API key authentication
* The required Shopify store BaseURL
* A health check configuration

After setting up the Action, you can validate it, activate it, and test it in the Playground. You can also adjust the schema later if you want to add or change Shopify endpoints.

## Set up the action

1. Go to **Actions** in Watermelon.
2. In the **Actions catalog**, click **Custom action**.
3. Click **Create new Action**.
4. Fill in the fields below.

### General details

**Action name**<br />`Shopify order status`

**Description**<br />`This action lets you get status information from your orders and use it in your chatbot when customers ask for it.`

**BaseURL**<br />`[YOUR SHOPIFY STORE URL]`

Enter the URL of the Shopify store you want to connect.

### Authentication

For **Authorization Header**, select **API key**.

For **Auth Type**, select **Bearer**.

**Token**<br />Enter your Shopify access token.

### Extra headers

Add the following extra header:

**Header name**<br />`X-Shopify-Access-Token`

**Header value**<br />`bearer`

### Health check

**Health check URL**<br />`https://www.yourdomain.com/health_check`

Replace this URL with the health check endpoint you want Watermelon to use.

**Instruction**

> You should respond with the following message or a similar variation: Sorry, something went wrong on our end. Can I assist you with anything else? Please let me know how I can help.

### Schema

Paste the Shopify schema into the **Schema** field:

```text theme={null}
openapi: 3.0.0
info:
  title: Shopify API
  version: 1.0.0
  description: API endpoints for retrieving products and orders from Shopify.

servers:
  - url: https://your-development-store.myshopify.com/admin/api/2024-07
    description: Shopify Development Store API

paths:
  /products/{product_id}.json:
    get:
      summary: Get a Single Product
      description: Retrieves details for a specific product using its product ID.
      parameters:
        - in: path
          name: product_id
          required: true
          schema:
            type: integer
          description: The ID of the product to retrieve.
        - in: header
          name: X-Shopify-Access-Token
          required: true
          schema:
            type: string
          description: Shopify access token for authentication.
      responses:
        '200':
          description: Successful response with product details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  product:
                    type: object
                    description: Product details
                    properties:
                      id:
                        type: integer
                      title:
                        type: string
                      body_html:
                        type: string
                      vendor:
                        type: string
                      product_type:
                        type: string
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      variants:
                        type: array
                        items:
                          type: object
                      options:
                        type: array
                        items:
                          type: object
                      images:
                        type: array
                        items:
                          type: object
        '401':
          description: Unauthorized, invalid access token.
        '404':
          description: Product not found.

  /orders.json:
    get:
      summary: Get a Single Order
      description: Retrieves details for a specific order using its order ID, including specified fields.
      parameters:
        - in: query
          name: name
          required: true
          schema:
            type: string
          description: The ID of the order to retrieve.example ORD16707
        - in: query
          name: fields
          required: false
          schema:
            type: string
          description: Comma-separated list of fields to include in the response. E.g., "id,line_items,name,total_price"
        - in: header
          name: X-Shopify-Access-Token
          required: true
          schema:
            type: string
          description: Shopify access token for authentication.
      responses:
        '200':
          description: Successful response with order details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  order:
                    type: object
                    description: Order details
                    properties:
                      id:
                        type: integer
                      name:
                        type: string
                      total_price:
                        type: string
                      line_items:
                        type: array
                        items:
                          type: object
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
        '401':
          description: Unauthorized, invalid access token.
        '404':
          description: Order not found.
```

Click **Validate**. When the schema is valid, Watermelon should show the available actions, including:

* **Get a Single Product** — `GET /products/{product_id}.json`
* **Get a Single Order** — `GET /orders.json`

### Example in Watermelon

<Frame>
  <img src="https://mintcdn.com/watermelon/U1o80ZmdmQTd06X6/images/Shopify-action-template-1.png?fit=max&auto=format&n=U1o80ZmdmQTd06X6&q=85&s=ea9106512e426ae88653e928f999999c" alt="Shopify Action Template 1" width="2878" height="1530" data-path="images/Shopify-action-template-1.png" />
</Frame>

When everything is configured correctly, click **Save** and then **Activate**.

Finally, test the Action in the **Playground** to make sure your Agent can retrieve the expected Shopify data.

#### Editing an Action Template

After setting up an Action, you can adjust it to your use case. For example, you can add endpoints to the schema, change parameters, or update the name and description.

Be careful when changing authentication settings or existing endpoints, as this can prevent the Action from connecting to the API.

## Troubleshooting

| Issue                                        | Likely cause                            | What to check                                             |
| :------------------------------------------- | :-------------------------------------- | :-------------------------------------------------------- |
| **Validation failed**                        | Invalid OpenAPI schema                  | Check the schema for missing or unsupported fields.       |
| **401 Unauthorized**                         | Incorrect credentials                   | Check your API key, token, username, or password.         |
| **404 Not Found**                            | Incorrect endpoint                      | Check the BaseURL and endpoint path.                      |
| **Action does not return the expected data** | Schema or parameter mismatch            | Check the endpoint parameters and API response structure. |
| **Health check fails**                       | Health check endpoint cannot be reached | Check the Health check URL and authentication.            |
