Skip to content

Commit cfb495f

Browse files
authored
App env vars (#70)
* commit * app api spec * spellcheck
1 parent 805ea21 commit cfb495f

File tree

4 files changed

+133
-1
lines changed

4 files changed

+133
-1
lines changed

fern/apis/platform/platform.yaml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1679,6 +1679,9 @@ paths:
16791679
type: string
16801680
speech_recognizer_language:
16811681
type: string
1682+
env_vars:
1683+
type: object
1684+
description: Object containing the Application Environment Variables as key/value to be sent with the call_hook payload
16821685
required:
16831686
- name
16841687
- account_sid
@@ -2283,7 +2286,7 @@ paths:
22832286
description: Client deleted
22842287
'404':
22852288
description: ClientSid not found
2286-
2289+
22872290
/Lcrs:
22882291
post:
22892292
tags:
@@ -3945,6 +3948,32 @@ paths:
39453948
- message
39463949
'404':
39473950
description: service provider not found
3951+
/AppEnv:
3952+
get:
3953+
summary: Get App Env Schema
3954+
operationId: getAppEnvSchema
3955+
tags:
3956+
- Applications
3957+
parameters:
3958+
- name: url
3959+
in: query
3960+
required: true
3961+
schema:
3962+
type: string
3963+
responses:
3964+
'200':
3965+
description: App Env Schema
3966+
content:
3967+
application/json:
3968+
schema:
3969+
type: object
3970+
'204':
3971+
description: No App Env Schema was found at the url
3972+
'400':
3973+
description: The App Env Schma that was returned was invalid
3974+
3975+
3976+
39483977
components:
39493978
securitySchemes:
39503979
bearerAuth:
@@ -4193,6 +4222,9 @@ components:
41934222
type: string
41944223
speech_recognizer_language:
41954224
type: string
4225+
env_vars:
4226+
type: object
4227+
description: Object containing the Application Environment Variables as key/value to be sent with the call_hook payload
41964228
required:
41974229
- name
41984230
- account_sid

fern/apis/webhooks/webhooks.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,10 @@ components:
320320
sip:
321321
description: The SIP request for the call
322322
$ref: '#/components/schemas/sipRequest'
323+
env_vars:
324+
description: Application Environment Variables configured for the applicaiton
325+
type: object
326+
323327
sipRequest:
324328
required:
325329
- raw

fern/docs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ navigation:
106106
path: ./docs/pages/features/securing-webhooks.mdx
107107
- page: API Rate Limits
108108
path: ./docs/pages/features/api-rate-limits.mdx
109+
- page: Application Environment Variables
110+
path: ./docs/pages/features/app-env-vars.mdx
109111
- tab: verbs
110112
layout:
111113
- section: Verbs
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
title: Application Environment Variables
3+
hidden: false
4+
---
5+
6+
## Background
7+
Application Environment Variables (app-env vars) are a feature in Jambonz that allows you to pass custom values to your application in the call webhook.
8+
This allows for you to have one instance of your application running but pass in specific customisation parameters with the call, it also allows us to offer the [Hosted Applications]
9+
with users supplying their own parameters to the application.
10+
11+
12+
The parameters are discovered by jambonz when you setup the call webhook and then the WebUI will create additional fields based on the schema that is returned.
13+
14+
The values for the parameters are then entered during application setup and stored encrypted in the database.
15+
16+
When a call is routed to the application these parameters are sent in the calling webhook.
17+
18+
## Discovery
19+
Whenever a user creates a new calling webhook in the jambonz webUI (either webhook or websocket) jambons will make an HTTP OPTIONS request to that endpoint,
20+
If the application offers App-Env Vars it should respond with a JSON schema defining these parameters.
21+
22+
If the application does not respond with a valid JSON schema or does not handle the OPTIONS request then Jambonz will silently ignore the error and the application configuration can continue as normal.
23+
24+
## Schema
25+
The schema is a JSON object, with each parameter name as a key and then an object containing the attributes of that parameter.
26+
For example the below schema would define a parameter of `NAME` as a `string` type that is not required, and has a description
27+
28+
```JSON
29+
{
30+
"NAME": {
31+
"description": "Your Name",
32+
"type": "string",
33+
"required": true,
34+
"default": "Bob",
35+
"obscure": false,
36+
"uiHint": "input"
37+
}
38+
39+
}
40+
```
41+
42+
A schema can contain multiple parameters, but each one must have a unique name.
43+
44+
### Attributes
45+
The following attributes can be defined for a parameter in the schema
46+
47+
<ParamField path="description" type="string" required={true}>
48+
A description of the parameter, this will be visible to the user when then mouseover the ? icon next to the parameter in the UI
49+
</ParamField>
50+
51+
<ParamField path="type" type="string" required={true}>
52+
One of:
53+
- `string`
54+
- `boolean`
55+
- `number`
56+
The type of parameter, this is how the parameter will be sent in the callHook so a number would be sent as `5` whereas a string would be sent as `"5"`
57+
</ParamField>
58+
59+
<ParamField path="required" type="boolean" required={false}>
60+
If set to True then the parameter must be defined in order for the application to be created
61+
</ParamField>
62+
63+
<ParamField path="default" type="string|number|boolean" required={false}>
64+
A default value to pre-fill for the parameter
65+
</ParamField>
66+
67+
<ParamField path="enum" type="array" required={false}>
68+
An array of values, if set then the UI will show a dropdown asking the user to select a value.
69+
</ParamField>
70+
71+
<ParamField path="obscure" type="boolean" required={false}>
72+
If set then the value will be obscured in the UI, useful for passwords and API keys.
73+
</ParamField>
74+
75+
<ParamField path="uiHint" type="string" required={false}>
76+
One of:
77+
- `input`
78+
- `textarea`
79+
- `filepicker`
80+
When type is set to string the default is a simple one line text box, `textarea` allows for a larger multiline input
81+
and `filepicker` will allow the user to upload a text file directly into the textarea. All values are still stored and passed as a string.
82+
</ParamField>
83+
84+
## Call Hook
85+
86+
Once an application has been created with its app-env vars defined and stored when a call is made either inbound or outbound these values
87+
will be added to the callHook as a new object under the `env-vars` key.
88+
They are only sent on the initial callHook not on any subsequent hooks or on the call Status hook.
89+
90+
## API
91+
92+
App Env Vars may also be created, read and modified on an application via the [REST API](/reference/rest-platform-management/applications/create-application#request.body.env_vars)
93+
94+
You can also invoke the OPTIONS request to fetch a scheme from an endpoint using the [API](http://127.0.0.1:3002/reference/rest-platform-management/applications/get-app-env-schema)

0 commit comments

Comments
 (0)