---
title: Using the Swimlane Python Chatbot
slug: using-the-swimlane-python-chatbot
docTags: 
createdAt: 2025-08-11T11:13:46.000Z
---

When configuring a **Script** native action, you’ll notice an icon in the lower-right corner of your browser window. Selecting the Script native action makes the **Swimlane Hero AI Python Chatbot** available to assist you with Python scripting.

Think of it as your Python scripting assistant. It can help you generate Python code for transformation logic, filtering, extraction, or any other function you need within the Script action.

::Image[]{src="https://api.archbee.com/api/optimize/511c8QBH-VHiwWnyzIwUb/FUErsrOp91LM7_UPRZMpJ_swimlane-python-heroai-1.png" size="70" width="3216" height="1738" darkWidth="800" darkHeight="432" position="center" alt="Swimlane Python Chatbot Icon" showCaption="false"}

## Getting Started with the Python Chatbot

Click the chatbot icon to open a new chat. The first time you ask a question, the chatbot will prompt you to acknowledge that your organization has accepted the Swimlane Terms and Conditions. You can click **Swimlane Terms and Conditions** to review them. Once you click **Acknowledge**, the chatbot will be ready to assist you.

Now you can begin formulating Python scripts!

### Capabilities of the Python Chatbot

The goal of the Swimlane Python Chatbot is to help you craft Python scripts that operate on JSON objects from the Script action inputs. The chatbot can generate fully interoperable Python scripts that align with the conventions used in Swimlane. It will also help you refine your script as needed.

## Example Scenario: Python Chatbot Query

In this example, Amir wants to generate Python code to filter, extract, or transform an input JSON object.

1. Amir opens the Swimlane Python Chatbot and types, "Filter emails with `malicious` in a subject key" and clicks **Submit your question**.
   The chatbot notices that Amir has not yet defined the Script action’s inputs and prompts him to define a JSON object.

::Image[]{src="https://api.archbee.com/api/optimize/511c8QBH-VHiwWnyzIwUb/S-2Jm4ZnuO5vbmrnEdsSx_nojsonobjectdefined.png" size="22" width="770" height="1284" darkWidth="800" darkHeight="1333" position="center" alt="Chatbot prompts JSON object" indent="2" showCaption="false"}

2. Amir sets up a JSON object for emails: `{"subject": string, "body": string}`, and then asks the chatbot the same question: "Filter emails with `malicious` in a subject key" and clicks **Submit your question**.
   The chatbot responds with a Python script that picks up the JSON schema from the Script action inputs and passes them as context to Hero AI.

::Image[]{src="https://api.archbee.com/api/optimize/511c8QBH-VHiwWnyzIwUb/wOcH6rP3MzH5cVb7tkZjU_chatbot-add-loop.png" size="74" width="1769" height="731" darkWidth="800" darkHeight="330" position="center" alt="Chatbot response with script" indent="2" showCaption="false"}

3. Amir reviews the script and refines it further by asking, "Additionally, filter the emails by body containing the word `spam`."

::Image[]{src="https://api.archbee.com/api/optimize/511c8QBH-VHiwWnyzIwUb/ryFOaHwMYHxqWjP8nkNdl_chatbot-spam-add.png" size="36" width="460" height="711" darkWidth="800" darkHeight="1236" position="center" alt="Refining the script with spam filter" indent="2" showCaption="false"}

4. Amir then remembers that his email object also includes a malicious score. He updates the email object and asks the chatbot, "Instead of filtering the body, filter emails by malicious score higher than 95%."

::Image[]{src="https://api.archbee.com/api/optimize/511c8QBH-VHiwWnyzIwUb/tdOo4-0VzW1ep6jgPGJZc_chatbot-score-redefined.png" size="70" width="1769" height="734" darkWidth="800" darkHeight="331" position="center" alt="Script refined for score filtering" indent="2" showCaption="false"}

As you can see, the chatbot is interactive and allows Amir to refine his script as he progresses.

## Final Script Generated by Swimlane Python Chatbot

:::BlockQuote
\# Iterate over each email in the 'emails' array filtered\_emails = \[] for email in action\_inputs\['emails']:
\# Check if the subject contains the word 'malicious' if 'subject' in email and 'malicious' in email\['subject']:
\# Check if the 'score' key exists and if its value is greater than 0.95 if 'score' in email and email\['score'] > 0.95: filtered\_emails.append(email)
\# Create a new dictionary with the filtered emails action\_outputs = \{'emails': filtered\_emails}
:::

:::hint{type="warning"}
&#x20;Swimlane recommends breaking down complex transformation logic into simple steps and asking the chatbot to generate scripts sequentially for each step.
:::
