# Create a profile api with Microsoft Flow and Sharepoint
Log in to  https://flow.microsoft.com (opens new window) with your Office 365 account
Click on âCreateâ
- Select then âInstant Flowâ
- Select the trigger âWhen an HTTP request is receivedâ
- Add the following Body JSON Schema in âRequest Body JSON Schemaâ.
{
"type": "object",
"properties": {
"userId": {
"type": "string"
},
"upn": {
"type": "string"
},
"aadId": {
"type": "string"
},
"email": {
"type": "string"
},
"channel": {
"type": "string"
},
"displayName": {
"type": "string"
}
}
}
This corresponds to the information of the user, sent by the chatbot when it will have to determinate the profile.
Click on âShow advanced optionsâ and select âPOSTâ method.
The user can talk to the chatbot
- Msteams (Teams)
- Directline (Skype for Business)
- Webchat (Webchat)
You will find this channel code in the JSON channel property above
Depending on the channel, the following information is filled in:
Skype for Business (directline)
- Email ( it also can the SIP address of the user if it differs from its email address)
- UserId: a unique Id for the user
- Display Name : The display name of the user in the AD
Teams
- Upn
- aadId: the AZURE AD Id of the user who talks to the chatbot
- UserId : a unique Id of the user teams
- Displau Name : the display name of the user in the AD
Webchat
- Email (which corresponds to the property sent in the UserId of the webchat configuration)
- UserId (which corresponds to the property sent in the UserId of the webchat configuration)
- Display Name (which corresponds to the UserName property in the webchat configuration)
â ď¸
There is no need to make a distinction between channels if you only have one configured or if your email, upn and sip addresses are the same.
Here you are a sample of a SharePoint list:
This SharePoint list is very simple. It contains the user ID in the "Title" column and the assigned profile in the "profile" column.
- Click on âNew stepâ
- In the section âSharepointâ select âGet itemsâ
- Configure it by adding the address of the SharePoint site and the list that will be used as a basis to retrieve the profiles
- Click on âShow advanced optionsâ
- Add the filter request Title eq âemailâ by choosing the email property from the request pop-up
- Indicate âTop countâ = 1
Add a new step
Search the âRequestâ
- Add the âStatus Codeâ = 200 and in the Body add the following JSON Code:
{
"user": {
"userId": "",
"profile": ""
}
}
Replace the empty results with the data from the SharePoint request
- Replace UserId with the value received in input
- Replace Profile with the Sharepoint value:
Expression = first(body('Get_items')?['value'])?['profile']
15- Change the name of your Flow (at the top left: for example, "Profile retrieval"). Click on save
# Use Postman to test your API
Postman is a great tool for API Testing. It is available for free download on: www.getpostman.com (opens new window)
- Click on â+NEWâ then on âRequestâ (then Cancel).
Select POST
Copy and paste the API previously created
In âHeadersâ select KEY: Content type and VALUE: application/json
In âBodyâ select ârawâ and enter for example:
{
"email": "bob.alternant@witivio.com",
"userId": "bob.alternant@witivio.com",
"channel": "webchat"
}
Send
RĂŠsultat : {
"user": {
"userId": "bob.alternant@witivio.com",
"profile": "alternant"
}
}
Click on âSendâ
Here is an example of answer:
Once the API has been tested, you can return to the Witivio platform in the âProfileâ tab and continue the configuration of the new profile. The following framework therefore allows you to configure the conditions of the profiles
- URL to query : API URL created previously
- JSON PATH : The JSON PATH query allows to verify the results sent by the API.
Equals(âsomethingâ,âresultâ)
. Here, for example, it could be: equals(â\$.user.profileâ,âtraineeâ)
.
The $.user.profil
corresponds to the JSON PATH query of the answer of the API.
See more on: https://jsonpath.com (opens new window)
If needed, it is possible to multiple the API calls to determine a profile. To this, you can add or delete a new condition. Both conditions have to be filled in to determine the profile of the user.
â Overview Profile Overview Settings â