Giter Site home page Giter Site logo

Comments (5)

glime-ai avatar glime-ai commented on June 16, 2024

To read JSON sent from another API to an Elsa Workflow V2 Dashboard HTTP Endpoint, you would typically use the HttpEndpoint activity to set up an endpoint that can receive HTTP requests. The JSON payload sent to this endpoint can then be accessed within the workflow.

Here's a basic example of how you might define a workflow that reads JSON from an incoming HTTP POST request:

  1. Add an HttpEndpoint activity to your workflow with the following settings:

    • Method: POST
    • Path: /your-endpoint-path (e.g., /api/data)
  2. Add a RunJavaScript or similar activity to process the incoming JSON. You can access the JSON payload using the input variable, which represents the incoming request content.

  3. Use expressions to access the JSON properties. For example, if the JSON payload is {"name": "Elsa", "age": 3}, you can access the name property with an expression like input.name.

Here's a sample JSON representation of such a workflow:

{
  "name": "ReceiveJsonWorkflow",
  "activities": [
    {
      "id": "http-endpoint",
      "type": "HttpEndpoint",
      "properties": {
        "Method": "POST",
        "Path": "/api/data"
      }
    },
    {
      "id": "process-json",
      "type": "RunJavaScript",
      "properties": {
        "Script": "return { name: input.name, age: input.age };"
      }
    }
  ],
  "connections": [
    {
      "sourceId": "http-endpoint",
      "targetId": "process-json"
    }
  ]
}

To execute this workflow, you would send a POST request to https://localhost:5001/workflows/api/data with a JSON payload.

Here's a sample curl command to send a JSON payload to the workflow endpoint:

curl --location --request POST 'https://localhost:5001/workflows/api/data' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "Elsa",
    "age": 3
}'

Please note that the actual endpoint URL and port may vary based on your Elsa Dashboard setup.

For more detailed examples and documentation, you can refer to the Elsa Workflow documentation and samples provided in the context section, specifically the HTTP Backend API and HTTP Post Users API samples.

from elsa-core.

Rathna314 avatar Rathna314 commented on June 16, 2024

Is "type": "RunJavaScript", available in Version 2.13 Dashboard. If not which activity should I use.

from elsa-core.

Rathna314 avatar Rathna314 commented on June 16, 2024

Can someone respond please. Is "type": "RunJavaScript", available in Version 2.13 Dashboard. If not which activity should I use. I am unable to see RunJavaScript in 2.13 version.

from elsa-core.

sfmskywalker avatar sfmskywalker commented on June 16, 2024

Yes, but it's not added to the system by default. To make it available, you need to call AddJavaScriptActivities on the elsa options builder.

from elsa-core.

sfmskywalker avatar sfmskywalker commented on June 16, 2024

This guide covers a similar scenario where it demonstrates reading a payload sent to an HTPT Endpoint activity.

from elsa-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.