GhostWording / gw-config-apis

this repo contains static json that can live through apis with github management only
0 stars 7 forks source link

[sequences] provide bot apis to be used by apps #16

Closed rhwy closed 6 years ago

rhwy commented 6 years ago

In order to centralise the bots source of truth and avoid doing different implementations of the same thing, we want to have bot apis that can do the same actions that we have in bots but to be used by client apps.

TL;DR

Note for the following apis that:

User Properties

In order to do some specific actions and decisions on the bot engine, bot apis need to know the user profile properties. The idea is to call these apis from the clients (along with the usual SetUserProperty sent with events)

SET

I want to set a user property for a user using a Bot:

POST http://api.cvd.io/botapis/user/setproperty
 {
     "BotName" : "test", 
     "DeviceId" : "123", 
     "FacebookId" : "456", 
     "PropertyName": "greeting", 
     "PropertyValue" : "Hello" 
}

You’ll get in return either

GET

I want to get a user property for a user using a bot:

POST http://api.cvd.io/botapis/user/property
{ 
   "BotName" :"test", 
   "DeviceId" : "123", 
   "FacebookId" : "456", 
    "PropertyName" : "greeting" 
}

You’ll get in return either

GET ALL

I want to get all properties for a user using a Bot

POST http://api.cvd.io/botapis/user/properties
{ 
   "BotName" : "test", 
   "DeviceId" : "123", 
   "FacebookId" : "456"
}

You’ll get in return either

Fragments

By ID

I want to get a specific sequence Fragment by it’s ID:

POST http://api.cvd.io/botapis/sequences/fragment
{ 
   "BotName":"test", 
    "DeviceId" : "123", 
    "FacebookId": "456", 
    "ParentSequencePath":"HowAreYou",
    "FragmentId" : "funnySequence"
}

You’ll get in return either

Note:

By TAG

I want to get a random sequence Fragment by Tag(s):

POST http://api.cvd.io/botapis/sequences/fragment
{ 
   "BotName":"test", 
   "DeviceId": "123", 
   "FacebookId": "456", 
   "ParentSequencePath":"HowAreYou",
   "Tags" : ["funny","penguins"]
}

You’ll get in return either

Sequences

I want to get the next sequence:

POST http://api.cvd.io/botapi/sequences/next
{ 
   "BotName":"test", 
   "DeviceId": "123", 
   "FacebookId": "456", 
   "LastSequenceId":"BeyonceOrRihanna"
}

You’ll get in return either

Note:

andreasdieryck commented 6 years ago

Sounds great @rhwy.

I have one small remark regarding the Fragments call:

In your example, to get a fragment, you use the pair "FragmentId" : "funnySequence". Until now, we have used "FragmentPath" : "funnySequence" to refer to a Fragment in the sequence. Could we homogenise this one way or another?

@Frederikos does it sound good to you too?

rhwy commented 6 years ago

you're right, for me the FragmentPath is a more generic thing that we should use. if you refer the root of the sequence you'll have fragmentPath = fragmentId, but in case we need to refer a specific element within a sequence (a children element node/leaf in the sequence tree) you can access it by it's path which is a composition of the ids of all elements in the path (ex= funnySequence/ShowMeThePenguins/Yes). I'll update the apis/doc in that way

rhwy commented 6 years ago

also, we have ParentSequenceIdmaybbe it should be interesting to use ParentSequencePath instead? one important feature it can bring us is knowing exactly where in the original sequence was the call to fragments. it allows us to see the impact if we arrive on the fragment by one path or another (if we link to the same fragment after a question for exemple) or if we decide to test the impact of adding one question before another or anything in that way.

what do you think?

andreasdieryck commented 6 years ago

Makes more sense that way indeed. @Frederikos is it all clear to you as well?