Configuring the Context

Define the shape of the data that your application will provide.

The Context tab of the Rehance dashboard allows you to specify the shape of the data that your application will pass to Rehance to process requests. The Context should contain all of the data that would reasonably be needed to construct calls to the Actions you have defined. If you haven't yet defined any Actions, we recommend you do that first.

How Context Is Structured

When you pass live data to Rehance for processing, the context will be passed as an object where each field is an array of objects that share the same schema. For example, if your application is a content management system for a blog, you might pass a context that looks like this:

{
  "users": [
    {
      "email": "johndoe@example.com",
      "permission": "admin"
    }
  ],
  "documents": [
    {
      "id": 1,
      "title": "My First Blog Post",
      "body": "This is the body of the blog post.",
      "publishedAt": "2019-01-01T00:00:00.000Z",
      "tags": "tutorial,blog"
    },
    {
      "id": 2,
      "title": "My Second Blog Post",
      "body": "This is the body of the second blog post.",
      "publishedAt": "2019-01-02T00:00:00.000Z",
      "tags": "blog"
    }
  ]
}

Note that each field in the context is an array of objects, where the objects in each array share the same schema. This consistency is important, because it allows Rehance to understand the data and make intelligent decisions about how to process it.

Creating a Context Item

A Context Item is a single field type in the context. For example, in the context above, the users field is a Context Item, and the documents field is another Context Item. Each Context Item has a list of fields, and each field has a name and a type. Using our example above, each user has two fields: email and permission.

You can create Context Items in the Context tab of the Rehance dashboard. Set the name of the Context Item, and then add fields to it. As with Action parameters, the type of each field must be either String, Number, or Date.

Editing or Deleting a Context Item

You can make changes to any Context Item in the Context tab of the Rehance dashboard. Just be sure to click the Save Changes button when you're done.

Optimizing For Accuracy

We do not recommend overfilling the context with data that is not needed by your Actions. Doing this will merely increase the amount of data that Rehance needs to process, and increase the risk of mistakes. Only include data that is needed by your Actions and your users will see better results.