Advanced Command Example

Create powerful commands with parameters, API integrations, and conditional logic using Command Studio

Prerequisites: Make sure you have completed the Simple Command Example first. This guide builds upon those basics.

Weather Command Example

We'll create a weather command that fetches real-time weather data from an external API. This demonstrates parameters, API calls, error handling, and dynamic responses.

/weather
Get current weather information for any city
Usage: /weather city:"London"
Response: "London: 18°C, Partly Cloudy"

Step 1: Create New Command

Open Command Studio
Navigate to your dashboard → Command Studio → Click "New Command"
Set Basic Information
Fill in the command details:
Name: weather
Description: Get current weather for a city
Trigger Type: Slash Command

Step 2: Add Parameters

Configure Parameters
In the Command Studio, click "Add Parameter" and configure:
Parameter Name Type Required Description
city String Yes Name of the city to get weather for
Parameter Types: You can use String, Number, Boolean, or User types. Each parameter becomes available as a variable in your command logic.

Step 3: Build the Flow

Add HTTP Request Action
Drag the "HTTP Request" action from the actions panel into your flow. Configure it:
Method: GET
URL: https://api.weatherapi.com/v1/current.json
Query Parameters:
- key: YOUR_API_KEY
- q: {city}
- aqi: no
API Key Security: Never expose your API keys in client-side code. Use environment variables or secure configuration in Command Studio.

Step 4: Add Conditional Logic

Add Condition Node
Drag a "Condition" node and connect it after the HTTP request. Set the condition:
Condition: {http_response.status} equals 200
If True: Continue to success message
If False: Show error message

Step 5: Add Response Actions

Success Response
Add a "Send Message" action for the success case:
Message: {city}: {http_response.data.current.temp_c}°C, {http_response.data.current.condition.text}
Error Response
Add another "Send Message" action for the error case:
Message: Sorry, I couldn't get weather data for {city}. Please check the city name and try again.

Step 6: Test and Deploy

Test Your Command
Use the Command Studio preview panel to test with different cities:
Test Cases:
- /weather city:"London"
- /weather city:"New York"
- /weather city:"Invalid City"
Pro Tip: Use the debug panel to see the exact API response and troubleshoot any issues.

Advanced Features

Error Handling

Rate Limiting

Data Processing

Best Practices

Troubleshooting

Common Issues:
Next Steps: Try creating commands with multiple parameters, database integration, or complex conditional logic!