Skip to main content

Remote Quick Command Example

Example: Create and execute a Remote Quick Command for Translation

This guide walks you through creating and executing a Remote Quick Command to translate text from English to Spanish using the StackSpot AI platform.

Step 1. Create the Remote Quick Command

  1. Log in to your StackSpot AI Account;
  2. Navigate to the ‘Contents > Quick Command’ section on the left-hand side of the menu;
  3. Click ‘Create Quick Command’ and select the ‘Remote’ option;
  4. Click 'Start' and fill out the Quick Command information:
  • Name: Translate English to Spanish
  • Command [The URL name]: translate-english-to-spanish
  • Description: Translates English texts to Spanish
  1. Click 'Start', then choose the Prompt option:
  • Prompt name: translate-en-es
  • Insert your prompt: "Translate the following text from English to Spanish: {{input_data}}"
  • If you have one, select a Knowledge Source relevant to language translation.
  1. Click 'End' to fill in the final output data Quick Command.

  2. On 'Quick Command Utilization', click input_data and \{\{translate-en-es.answer}} options. Click 'Finish'.

Step 2. Generate Access Token

  1. In the Access Token section, click the 'Generate client key' button;
  2. A new tab will open. Click ’Generate Tokens’;
  3. Copy the provided curl example and save it. You will need it to authenticate your API requests in the step 3.

For more details, check the StackSpot EDP documentation.

Step 3. Execute the Quick Command via API

Ensure you have Postman installed or another API client. This example works on Postman.

To execute the Quick Command, make a POST/GET request to the StackSpot API endpoint. Follow these steps:

  1. Open Postman. Click 'Import' and paste the curl example you copied earlier.
    • A new tab will open with the POST URL similar to:
  POST https://idm.stackspot.com/stackspot/oidc/oauth/token
  • Click send and copy the token from the response.
  1. In the headers section of a new tab, add:

    • Key: Authorization
    • Value: Bearer your_token
  2. Now, on the POST tab, add the StackSpot ‘Create Execution’‘ URL. See the example below:

POST https://genai-code-buddy-api.stackspot.com/v1/quick-commands/create-execution/translate-english-to-spanish

You can maintain the same conversation across multiple executions by including a query parameter conversation_id with the same ULID for all executions.

Example:

POST https://genai-code-buddy-api.stackspot.com/v1/quick-commands/create-execution/translate-english-to-spanish?conversation_id=01J03MBAJ17FV25JKDE3NCQ8WH
  1. Add the request body, which in this case is a prompt to translate to Spanish:
{

"input_data": "Hi, how are you? This is an example of how to create Remote Quick Command."

}
  1. It will return a value. Copy and save it.

  2. Open another tab in Postman. Copy the Callback on the StackSpot website and paste it into this new tab.

You must paste the Access Token in the header again.

  1. Replace the {{execution_id}} in the URL with the value returned from the POST request:

GET https://genai-code-buddy-api.stackspot.com/v1/quick-commands/callback/{execution_id}

See the example:

GET https://genai-code-buddy-api.stackspot.com/v1/quick-commands/callback/01HZ828C3K4E2093EYBABG014K
  1. The response will provide the translated text in Spanish for the input you added. Ensure the processing completes successfully by verifying that the execution_percentage field equals 1.0 (100%) and the status is COMPLETED.

Continue checking at intervals until the response indicates 100% completion.

You will find the service's outcome in the result field.

{
"execution_id": "01HZ828C3K4E2093EYBABG014K",
"quick_command_slug": "translate-english-to-spanish",
"conversation_id": "01HZ828C3KXNTD8CQAWV056ZVG",
"progress": {
"start": "2024-05-31T19:33:03.731642+00:00",
"end": "2024-05-31T19:33:09.141119+00:00",
"duration": 5,
"execution_percentage": 1.0,
"status": "COMPLETED"
},
"steps": [
{
"step_name": "translate-english-to-spanish",
"execution_order": 0,
"type": "LLM",
"step_result": {
"answer": "Hola, ¿cómo estás? Este es un ejemplo de cómo crear un Comando Rápido Remoto.",
"sources": []
}
}
],
"result": " Hi, how are you? This is an example of how to create a Remote Quick Command. Hola, ¿cómo estás? Este es un ejemplo de cómo crear un Comando Rápido Remoto. The Quick Command was successfully executed."
}