Create logic to get real-time prediction
This logic app consist with three parts Recurrence, Search tweets and For each modules.
The last For each module consist with multiple modules.
- Add Recurrence module and configure it like following
- Add Twitter Search and type key word to search
- Add For each module as the next action
- Select Twitter body
- Add Condition action fron Control module
- Select TweetLanguageCode for the condition and type
en
for the value
Click 'Add an action' inside True
We will leave False empty
parameter name | value |
---|---|
content | @{items('For_each')} |
Copy following json schema
{
"properties": {
"CreatedAt": {
"type": "string"
},
"CreatedAtIso": {
"type": "string"
},
"Favorited": {
"type": "boolean"
},
"MediaUrls": {
"type": "array"
},
"OriginalTweet": {},
"RetweetCount": {
"type": "integer"
},
"TweetId": {
"type": "string"
},
"TweetInReplyToUserId": {
"type": "string"
},
"TweetLanguageCode": {
"type": "string"
},
"TweetText": {
"type": "string"
},
"TweetedBy": {
"type": "string"
},
"UserDetails": {},
"UserMentions": {}
},
"type": "object"
}
Copy next JSON text to Input parameter
[
{
"id": "@{body('Parse_JSON')?['TweetId']}",
"text": "@{replace(string(body('Parse_JSON')?['TweetText']), '\"', '')}"
}
]
Add HTTP module
parameter name | value |
---|---|
Method | POST |
URI | Copy from Azure Databricks Notebook 4, cell 34th, scoring_uri |
Headers | Authorization |
Headers | Content-Type |
Headers-Authorization | Bearer Copy from Azure Databricks Notebook 4, cell 34th, api_key |
Headers-Content-Type | application/json |
Body | @base64(outputs('Compose')) |
- Add Parse JSON module
parameter name | value |
---|---|
content | json(body('HTTP')) |
{
"items": {
"type": "string"
},
"type": "array"
}
- Add For each module
@body('Parse_JSON_2')
- Add Parse JSON module
parameter name | value |
---|---|
content | @{items('For_each')} |
- And then copy and pate following JSON schema to logic app
{
"properties": {
"id": {
"type": "string"
},
"prediction": {
"maximum": 1,
"minimum": 0,
"type": "number"
},
"text": {
"type": "string"
}
},
"type": "object"
}
- Add Compose module and, copy and paste following JSON to the module
{
"body": @{items('For_each')},
"id": @{guid()},
"prediction": @{float(body('Parse_JSON_3')?['prediction'])},
"tweetid": "@{body('Parse_JSON_3')?['id']}"
}
- Add Parse JSON module and, copy and past following JSON to the module
{
"properties": {
"body": {
"properties": {},
"type": "object"
},
"id": {
"type": "string"
},
"prediction": {
"type": "number"
},
"tweetid": {
"type": "string"
}
},
"type": "object"
}
- Add Create or Update document from CosmosDB module
- Add Parition Key value parameter
parameter name | value |
---|---|
Database ID | socialmedia |
Collection ID | |
Document | @{outputs('Compose_2')} |
Parition key value | "@{body('Parse_JSON_4')?['id']}" |