REQUEST / RESPONSE

  • Expected response from your servers
  • Responses with other commands
  • Concept of content-renderer
  • Renderers (link here to a page on renderers)

Request JSON

Continuing on the example DNA for /time_in

When we type /time_in United States of America

The request JSON will contain the following:

TODO: add proper context in request

{
    "context": {"keys": "values"},
    "pathway": "in_country",
    "required": {
        "country": "United States of America"
    }
}

and this will be sent to your endpoint url: https://myserver.com/time_in/country

Context contains many common parameters about the incoming message itself like the author who wrote this, channel on which it was written, etc. Your command may or may not use these keys from context, depending on what you are doing.

Expected Response

Vanilla response 1:

{
    "context": {"keys": "values"},
    "output": "3:31 PM",
}

Note: You are supposed to send back the context as it is. Any tampering with the context will disqualify your response.

Let's say you want to send the output in red color (for no reason!) Response 2:

{
    "context": {"keys": "values"},
    "output": "/red 3:31 PM",
}

Just like /red you can actually use any other public command in the response and our framework will compute it (recursively)

Suppose you want to send more things, you can send a list in output instead of string. Response 3:

{
    "context": {"keys": "values"},
    "output": [
        "/grey Time in Washington, DC, USA",
        "/red 3:31 PM",
    ]
}

User will see the response in two lines (stacked vertically).

I know, you can smell the power now. But wait, there's more (much more (much much more :P))

results matching ""

    No results matching ""