> ## Documentation Index
> Fetch the complete documentation index at: https://docs.recaseai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Query about a payment

> Example workflow to search for payment details from a Supabase table, and summarize the results in English.

## Install Recase

Install Recase in your project by running the following command:

```zsh theme={null}
npx recaseai init
```

A `workflow.ts` file will be created in your project. This is where we'll write our workflow.

## Defining inputs

Inputs are the fields that are required to run your workflow. In this case, we'll need:

1. A payment ID
2. A query to answer about the payment

```js theme={null}
export default recase.workflow({
  id: "Query payment details",
  inputs: {
    paymentId: {
      name: "Payment ID",
      type: "string",
    },
    query: {
      name: "Query",
      type: "string",
    },
  }
});
```

## Building the workflow

Now we'll write our script to get the payment details from Supabase and answer the query.

```typescript theme={null}
import recase from "recaseai";
import { createClient } from "@supabase/supabase-js";

// Initialize Supabase client
const supabase = createClient(
  process.env.SUPABASE_URL || '',
  process.env.SUPABASE_KEY || ''
);

export default recase.workflow({
  //Workflow name and inputs as defined above
  id: "Query payment details",
  inputs: {
    paymentId: {
      name: "Payment ID",
      type: "string",
    },
    query: {
      name: "Query",
      type: "string",
    },
  },

  run: async ({ inputs }: any) => {

    // Query payment details from Supabase
    const { data: paymentData, error } = await supabase
      .from('payments')
      .select('*')
      .eq('payment_id', inputs.paymentId)
      .single();

    if (error) {
      throw new Error(`Failed to fetch payment: ${error.message}`);
    }

    // Use LLM to analyze payment data and answer query
    const answer = await recase.llm({
      message: `Given this payment information: ${JSON.stringify(paymentData)}
                Please answer this question: ${inputs.query}`,
      model: 'claude-3-5'
    });

    recase.log("Answer: ", answer);
  },
});
```

## Deploying

To deploy our workflow, we'll use the `recase deploy` command in your terminal.

```zsh theme={null}
npx recase deploy --file workflow.ts
```

You can create and deploy multiple workflow files in your project.

## Running your workflow

Workflows can be run via the [Recase UI](https://app.recaseai.com), via API or invoked via natural language on Slack. Here we'll connect to Slack and run the workflow from there.

<Steps>
  <Step title="Connect to Slack">
    Go to your Recase dashboard and click "Connect to Slack". Follow the prompts to authorize Recase in your workspace.
  </Step>

  <Step title="Run workflow with slash command">
    In any Slack channel, type `/rc` followed by your request. Recase will search for a matching workflow and execute it. For example:
    `/rc why was payment_239478239 declined?`
  </Step>

  <Step title="View workflow results">
    Recase will confirm the workflow has started. View the workflow logs in the [Recase Dashboard](https://app.recaseai.com), and the issue in Linear.
  </Step>
</Steps>

<Note>
  Questions? Chat to us about anything at [founders@recaseai.com](mailto:founders@recaseai.com) 😄
</Note>
