Triggering Temporal Workflows

  • Goal: Trigger an existing Temporal workflow from within Retool

  • Details: I am using Temporal Cloud to run workflows I defined using Temporal's Golang SDK. These are triggered by hitting a gRPC service, which then calls the corresponding SDK function to kick off the workflow. I am looking into using retool to trigger these workflows instead, since there seems to be an integration available. The problem I have now is that gRPC has built-in timeouts, and with long workflows this can become a problem.

The only documentation I can seem to find related to integrating Temporal is about using Temporal to run Retool-defined workflows, which is not what I want. I just want something that can trigger a workflow (just like the Temporal SDK does) from within the Retool UI.

Question: Does anyone have any advice for how I proceed, or could point me to some relevant documentation?

Thank you so much!

Hello @bliss303!

Great question :sweat_smile: Since Retool users a "built in" temporal instance for handling requests to trigger and run Retool workflows, I believe that all of our docs are related to managing this setup for Retool users setting up self hosted instanced.

From your question, it sounds like you want a Retool workflow to make a request to your Temporal Cloud instance to trigger a temporal workflow.

With the current set of events being:

Your web app(via Temporal's Goland SDK) -> gRPC service -> SDK function -> Temporal workflow is triggered

And the flow of events you are looking into is:

Retool workflow(via Temporal Python SDK) -> Temporal workflow is triggered

Let me know if that is correct!

Retool currently is not able to run Golang unfortunately, which is why I suggest using the Temporal Python SDK inside a Retool workflow code block.

I am not super familiar with Temporal, but as long as your Temporal instance has an API that can be 'hit' and triggered by a Query in Retool, you should be able to call a Query to hit this endpoint the same way you can call a REST API to make a POST or GET request to a backend server that lives elsewhere.

I would point you to Temporal's docs to see about how once of their servers can best be interfaced with. I am not very familiar on this but the main question is, where is the Temporal instance/server that you are looking to trigger workflows on living, and what ways can it receive requests from Retool app Queries.

Hope this helps :crossed_fingers:

Here were the results from a google search I did for "how to trigger a temporal workflow with python" :sweat_smile:

To trigger a Temporal workflow with Python, you can use the Temporal Python SDK. Here's a basic example:

  1. Install the SDK:
pip install temporalio
  1. Define your workflow:
from temporalio import workflow@workflow.defnclass MyWorkflow:    @workflow.run    async def run(self, name: str) -> str:        return f"Hello, {name}!"
  1. Create a client and start the workflow:
from temporalio import clientasync def main():    # Create client    client = await client.connect("localhost:7233", namespace="default")    # Start workflow    handle = await client.start_workflow(        MyWorkflow.run,         "Temporal",         id="my-workflow-id",         task_queue="my-task-queue"    )    # Wait for result    result = await handle.result()    print(f"Result: {result}")if __name__ == "__main__":    import asyncio    asyncio.run(main())

Explanation:

  • Workflow Definition:

The @workflow.defn decorator marks the class as a Temporal workflow. The @workflow.run decorator marks the method that will be executed as the main workflow function.

  • Client Connection:

The client.connect function establishes a connection to the Temporal server.

  • Starting the Workflow:

The client.start_workflow method starts a new workflow execution. You provide the workflow class, arguments to the workflow, a unique workflow ID, and the task queue to use.

  • Getting the Result:

The handle.result() method waits for the workflow to complete and returns the result.

Important Considerations:

  • Task Queue:

You need to run a Temporal worker that is listening on the specified task queue to execute the workflow.

  • Namespace:

Ensure the namespace you use in your client matches the one where your worker is running.

  • Error Handling:

You should add error handling to your code to gracefully handle failures.

  • Activities:

If your workflow needs to perform external operations, you can define activities and call them from your workflow.

Hi @bliss303,

Just wanted to circle back and check if you had made progress in integrating an external Temporal service with your Retool app.