Alloy Launcher and Automator empowers you to build custom AI agents running directly on your iOS device, leveraging OpenAI and xAI chat actions as flexible building blocks. These AI agents can interact with your device using functions you define - either accessing local device features or reaching out to web services - all orchestrated through adaptable workflows.

Key Concepts

  • AI-powered Actions: Alloy lets you define functions (tools) that the AI can call to complete user requests, such as copying text to the clipboard or retrieving information.

  • Custom Workflows: Each function is tied to a workflow, making it easy to modify or extend capabilities without being limited to hardcoded behaviors.

  • Extensible Architecture: You can add, edit, or replace functions to fit your personal workflow, effectively creating AI agents tailored to your needs.

How to Add a Custom Function

Let's add a custom "greet" function that returns a predefined greeting message for ChatGPT to use when it greets you. 


Define the "greet" Function

  • Long-press the ChatGPT action and select Edit Functions.

  •  In the JSON list of function definitions, add a new entry for the "greet" function and save them:

json
{ "name": "greet", "description": "Returns greeting text" }

This describes a function called "greet" with a brief description. No arguments are required. 

Design a "greet" Workflow

  1. Long-tap the ChatGPT action and select Edit.

  2. Find and copy the “Share” workflow for convenience (swipe left and tap the Copy).

  3. Paste it using the Paste button on the bottom of the screen 

  4. Tap the "..." button, pick Options, and set the Workflow name to "greet".

  5. Go back to Workflow Designer

  6. Enter the Edit Mode 

  7. Move the "Add Chat Message" -> "Done" task to the top (for the sake of simplicity).

  8. Delete unneeded "IF" task.

  9. Edit the "Add Chat Message" -> "Done" task and set its text to:
    "Hello there! Nice to meet you again!".

  10. Navigate back to the Action and save it.

See It in Action

When you type "greet me" in the chat interface, the AI scans available functions for a match, finds your new "greet" function, and triggers the corresponding Workflow. The result is a personalized greeting - shown in your chat as output from your custom AI agent.



Behind the Scenes

When you type "greet me", ChatGPT processes your prompt by scanning its list of available functions to see if any can fulfill your request - either in full or in part. In this case, it identifies the newly added "greet" function as a suitable match. Next, ChatGPT invokes the "greet" Workflow by passing in:

  • conversation: The entire chat history so far, provided as an array of all messages exchanged.
  • arguments: A dictionary of named function arguments (empty for greet, since it requires none).

The greet Workflow is then executed. Its only task is to add a new chat message - "Hello there! Nice to meet you again!" - as the function’s result.


Finally, ChatGPT takes the output generated by the greet workflow and crafts a reply for you, delivering the custom greeting you designed directly into your chat.


Certainly! Here’s a more polished and visually organized version, with all details retained and clarified for easy reading:


Details

Defining a Function

When adding a function to your AI workflow, each function should include the following components:

  • name: the name of the function (e.g., "share").

  • description: a concise explanation of what the function does, which parameters it accepts, and what it returns (e.g., "Share passed text"). Make this clear and informative, as it helps both you and the AI understand its purpose.

  • parameters: these are listed under the properties object and define the expected inputs for your function:

    • each parameter (defined as a property):

    • name: The parameter’s name (e.g., "text").

    • type: The parameter’s data type (e.g., "string").

    • description: An explanation of what the parameter represents and how it will be used (e.g., "Text to be shared").

    • required: An array listing the names of parameters that must be provided.

Sample Function Definition:

json
{ "name": "share", "description": "Share passed text", "parameters": { "type": "object", "properties": { "text": { "type": "string", "description": "Text to be shared" } }, "required": ["text"] } }

Function Workflows Contract

When implementing a Function’s Workflow, it must adhere to a specific contract for its inputs and outputs:

Parameters:

  • conversation (ChatConversation):
    The entire current conversation, provided as an array of chat messages.
  • arguments (Map<String, String>):
    A dictionary containing the named arguments defined in your function.

Returns:

  • conversation (ChatConversation):
    The updated conversation array. In most cases, you’ll return the conversation as is, possibly appending new messages.

Tip:
The simplest way to create a new workflow is by duplicating an existing one, like the "share" workflow, and then modifying it as needed.

Designing Function Workflows

Each Function Workflow should:

  1. Validate Arguments:
    Check that all required arguments are present and valid. Note: Never assume the AI will always provide correct or complete arguments.

  2. Perform the Intended Action:
    Execute the primary function, such as sharing the provided arguments.text.

  3. Return Results via Chat Message:
    Use the "Add Chat Message" task to append the result to the conversation.

    • Outputs can be a Message, Image, or JSON.

    • If there’s nothing specific to return, you can simply send "Done".
    • If an error occurs, provide an error message (e.g., "Error: [description]").