openai_assistant()
Ask a configured OpenAI Assistant a question through an OpenAI integration. Use this when you've set up an Assistant with its own instructions, knowledge, or tools in OpenAI.
Syntax
openai_assistant(connection, assistantId, question)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
connection |
string | yes | Name of the OpenAI integration connection. |
assistantId |
string | yes | The OpenAI Assistant id (e.g. asst_...). |
question |
string | yes | The question to ask. |
Returns
The assistant's response as a string.
Example
$answer = openai_assistant("OpenAI", "asst_abc123",
"What's our refund policy for orders over 30 days?");
record_comment("tickets", $record["_meta"]["id"], $answer);
Example output
"Orders over 30 days old are eligible for store credit only, not a cash refund."
Notes
- Create the Assistant in your OpenAI account and copy its id.
- For a one-off prompt without a configured Assistant, use openai_gpt().
See also: openai_gpt(), Integrations