HTTP

Sym lets you make arbitrary HTTP requests from Handlers.

Sometimes, Sym's built-in Integrations just don't cut it. We will eventually open up an Integration SDK to members of the community, but in the meantime you can use the HTTP Integration! By making arbitrary HTTP requests from your Handlers, you can query internal data stores, trigger side effects in third-party APIs, and more.

This Integration requires no setup.

Using HTTP in your Flows

This section is for Sym Implementers!

If your PagerDuty Integration has not yet been set up, please point your Integrator to Setup PagerDuty.

πŸ‘

SDK Docs

The HTTP Integration is defined at sym.sdk.integrations.dangerous.http.

🚧

This is a dangerous Integration

It's easy to shoot yourself in the foot! With great power comes great responsibility.

Example Usage

Delegating routing to an external service

from sym.sdk.annotations import reducer
from sym.sdk.user import User
from sym.sdk.integrations.dangerous import http

@reducer
def get_approvers(evt):
    body = {"target": evt.target}
    resp = http.get("https://gatekeeper.healthy-health.co", body)
    users = [User(email) for email in resp["emails"]]
    return slack.group(users)

Fetching external state

from sym.sdk.annotations import reducer
from sym.sdk.integrations.dangerous import http

@reducer
def get_approvers(evt):
    email = evt.user.email
    resp = http.get(f"https://people.healthy-health.co?email={email}")
    if resp["is_manager"]:
      # Self-approval:
      return slack.user(evt.user)

Triggering a side-effect

from sym.sdk.annotations import hook
from sym.sdk.integrations.dangerous import http

@hook
def on_request(evt):
    body = {"user": evt.user.email, "message": "requested access"}
    http.post(f"https://audit.healthy-health.co", body)

What’s Next
Did this page help you?