Skip to main content

How to Create Services

In this tutorial, we'll walk you through the process of creating a web service using Xircuits, leveraging the Flask component library. This guide is tailored for beginners and aims to assist you in deploying your very own web service on the platform.

Quick Start Option

For a quicker start, you can use the Simple Service project template which comes with a pre-configured workflow ready for deployment.

Step 1: Open a New Xircuits File

Start by opening the Xircuits interface within the Xpress AI Agent Studio. If this is your first time using Xircuits, it's a good idea to check out the Getting Started section in the Xircuits guide.

Step 2: Utilize the Flask Library

The Flask component library is essential for creating chatbots. To get started, we suggest using the provided example workflow. Right-click the Flask library in the component sidebar and select Show Example

Opening an Example

Step 3: Copy the Workflow File to the Base Directory

To ensure your new chatbot is recognized by the platform, the workflow file must reside in the base working directory. You can manually move the file or use the right-click context menu Copy to Root Directory option.

Moving Workflow to Base Working Directory

Step 4: Customize Your Workflow

Now that you have the example workflow, it's time to make it your own. Customize it by dragging and dropping components, connecting them, and adjusting their properties to shape your chatbot's behavior and responses.

Editing Workflow in Xircuits

Step 5: Deploy Your Service

After setting up your service workflow, head back to the platform's main dashboard. Your new Xircuits file should be visible by now. Go to the Services page, select your Xircuits file, and proceed with the deployment instructions to launch your service.

Deploying Your Service

Step 6: Interact with Your Service

Now that your service is live, you can interact with it using its URL endpoints. Upon deployment, you'll be given a custom endpoint URL for your service. You can test these endpoints using curl commands or through your preferred API testing tool.

If you ran the Flask example, here are some commands to interact with the provided endpoints, replacing <your_custom_endpoint> with your custom endpoint URL:

  • To perform a simple GET request:

    curl http://<your_custom_endpoint>/hello/world
  • To send a JSON payload with a POST request:

    curl --header "Content-Type: application/json" \
    --request POST \
    --data '{"hello": "world"}' \
    http://<your_custom_endpoint>/hello/world
  • To perform a PUT request:

    curl --request PUT http://<your_custom_endpoint>/here/is/something
  • To stream data from the server:

    curl http://<your_custom_endpoint>/stream

Testing Service Endpoint

These examples are just starting points. As you become more familiar with Flask and the components within Xircuits, you'll be able to create a wide range of endpoints to serve various purposes in your applications.

This marks the completion of your service creation journey! Keep in mind, this is just the start. As you delve deeper into Xircuits and explore its diverse components, you'll gain the ability to craft more intricate and tailored services to fit a variety of needs.