Send conditional text prompt to OpenAI from function call

Recipe ToolsDatabaseMarketingArtificial Intelligence

What it does

When someone makes a function call, this automation checks if the text prompt contains employee and profile keywords. If both are present, it queries MySQL and sends enriched data to OpenAI, then posts the result in Workplace.

Who it's for

Operations teams who need to route function calls to OpenAI with conditional employee data from MySQL.

How teams use this

Enrich employee queries with database context

When a function call asks about an employee profile, this automation pulls the matching record from MySQL and sends it to OpenAI for a richer response. The team gets more accurate answers without manual lookups.

Route non-employee prompts directly to OpenAI

If the text prompt does not mention both employee and profile, the automation skips the database query and sends the prompt straight to OpenAI. This keeps the flow fast for general requests.

Add department filtering to employee lookups

Extend the MySQL query to filter Employee_Information by department so only relevant records are sent to OpenAI. Include a department parameter in the function call to narrow results.

Post results to a dedicated Slack channel

Retarget the automation to send OpenAI responses to a Slack channel instead of Workplace. The logic and data flow stay the same, only the notification destination changes.

How it works

  1. Receive the function call. A function call arrives in real-time with a text prompt that may reference employee or profile information.
  2. Query employee data when keywords match. If the text prompt contains both employee and profile, select rows from the Employee_Information table in MySQL to enrich the request with matching records.
  3. Send prompt to OpenAI with context. Complete a text prompt using OpenAI, either with the employee data from MySQL or with the original prompt alone, depending on the keyword check result.
  4. Post the result in Workplace. Post the OpenAI response as a simple message in Workplace so the team sees the outcome of the function call and enriched query.