3
votes

I have created an Azure Logic app that searches for tweets containing ChinarTrading and then saves them in the SQL database. Below are the issues I am facing:

  • Twitter connector searches tweets only in the twitter account, which I used for authentication. If tweet with ChinarTrading is added from some other twitter account, it is not returned in search results.
  • Twitter connector returns the same tweets again, how to skip the old tweets.
  • In SQL connector, I am using the Insert operation, how can I add a condition like insert if not already existing (tweet text not found).
2

2 Answers

0
votes

Rather than using an Insert operation, use a Stored Procedure. In the stored procedure execute an IF EXISTS UPDATE ELSE INSERT.

IF EXISTS (SELECT * FROM Tweets WHERE [TweetId] = 'SomeId')
BEGIN
    --UPDATE HERE
END
ELSE
BEGIN
   -- INSERT HERE
END
0
votes

There is no direct way to add a condition like insert if not already existing. You can try to do so using the "Add Condition" from the deisgner.

So maybe you can use "SQL Azure- Get Rows" then add a "Condition" then based on the result of the condition you add the action "SQL Azure - Insert Row"

The Insert row API call POST: /datasets/default/tables/{table}/items , has only 2 parameters table and item (Row to insert into the specified table in SQL) while the Get Rows call allows you to query by ($skip, $top, $filter, $orderby)

As for tweets, there is no way at the moment to skip the old tweets as the API call takes only searchQuery and maxResults parameters as per the Twitter API documentation