Any UBI command consists of the following fields. Some are required, others are optional.
name
(required) - name of the the command in UBI.short_description
(required) - description of command when<commands>
is executed.error_message
(required) - response UBI gives when command failed.success_message
(required) - response that gives when command is successful. must contain{}
to be valid.{}
is used as a string substution (i,e, "Your horoscope is {}", where{}
will be replaced by the response of the API.number_of_parameters
(required) - the number of parameters (does not include API key) your function can accept. Currently 0 ("bloomberg") or 1 ("bible john316")api_url
(required) - the url of the API. Use string substitution to replace urlapi_key_query_param
(optional) query parameter used for API key (some APIs do not require this)api_key
(optional) api key (some APIs do not require this)can_use_in_group_chat
(not currently used)active
(if True, shows up in the list)response_parse_instructions
(required) response parse instructions, see below.
The response parse instruction parameter is how you tell UBI how to parse your JSON output.
- If your API endpoint returns text only, just leave this parameter unset (nothing to parse)
- We do not support XML responses
- We do not support multiple embedded list support (yet)
- parameters are separated by period
.
[]
tells ubi to return multiple response (see example 4, or any of the news API integrations)
- JSON:
{ 'verse': 'this is the bible verse' }
- Parse Instruction:
verse
- SMS Reponse: 'this is the bible verse'
- JSON:
[{ 'verse': 'this an embedded bible verse' }]
- Parse Instruction:
0.verse
- SMS Reponse: 'this an embedded bible verse'
- JSON:
This is a text response
- Parse Instruction: Leave the parameter null
- SMS Reponse:
This is a text response
- JSON:
{ 'articles' : [{ 'verse': 'v1' }, { 'verse': 'v2' }, { 'verse': 'v3' }, ]
- Parse Instruction:
articles.[].verse
- SMS Reponse:
* v1
* v2
* v3
The following is a list of example API integrations
The following API key uses:
- 1 query parameter,
- no API key / auth is required
[Example API] (http://labs.bible.org/api/?passage=John%203:16&type=json)
- Name: bible1
- Short Description: bible1
- Error Message: Sorry, this API Failed
- Success Message: {}
- Number of Parameters: 1
- API URL: http://labs.bible.org/api/?passage={}&type=json
- API Query Parameter: Not set
- API Key: Not set
- Response parse instructions: 0.text
[Example API] (http://labs.bible.org/api/?passage=random)
The following API key uses:
-
no API query parameter (provides random output)
-
no API key / auth is required
-
Name:
-
Short Description: bible
-
Error Message: Sorry, an error occurred. Please try again later.
-
Success Message: {}
-
Number of Parameters: 0
-
API Query Parameter: Not set
-
API Key: Not set
-
Response parse instructions: Not set
[Example API] (https://newsapi.org/v1/articles?source=techcrunch&sortBy=top)
The following API key uses:
-
one query parameter
-
requires a valid API key
-
accepts two different parameters: top or latest
-
Name: techcrunch
-
Short Description: techcrunch <top | latest>
-
Error Message: Sorry, an error occurred.
-
Success Message: {}
-
Number of Parameters: 1
-
API URL: https://newsapi.org/v1/articles?source=techcrunch&sortBy={}
-
API Query apiKey
-
API Key: xxxxxxxxx
-
Response parse instructions: articles.[].title