Twitter API get webhooks for my account [PHP] - api

Do you know if it is possible to set up webhooks when there is activity on MY twitter account with API ?
For example :
notification when I receive a like on my tweet
notification when I receive a new subscriber on my account.
Etc ...
Thank you.

Yes. Once you have created a webhook, and subscribe to the webhook using your own account, you will receive the follow and reply events. Per the Account Activity API documentation, I've highlighted the two relevant bullet points:
You will receive all related activities below for each user subscription on your webhook registration:
Activity types Tweets (by user)
Tweet deletes (by user) #mentions (of
user)
Replies (to or from user)
Retweets (by user or of user)
Quote Tweets (by user or of user)
Retweets of Quoted Tweets (by user or of
user)
Likes (by user or of user)
Follows (by user or of user)
Unfollows (by user)
Blocks (by user)
Unblocks (by user)
Mutes (by user)
Unmutes (by user)
Direct Messages sent (by user)
Direct Messages received (by user)
Typing indicators (to user)
Read receipts (to user)
Subscription revokes (by user)
Note that you have to manually subscribe your own account to your own registered webhook using the API - this does not happen automatically. You also need to handle each received API event (the webhook will receive all types of event).

Related

How to see the list of channels user invited to

We have a specific workflow for invite/reject/ban channels for users.
1) I need to retrieve the list of channels user invited to, so that he can select some now and accept/reject it or do it later
2) When a user rejected invite - we need another query to be able to show such channel to a user, so that he can accept it.
3) Push notification preferences, so that users can decide to receive or not push notification when he/she invited to a new channel.
I've checked docs https://getstream.io/chat/docs/#channel_invites, but the only covers how to send invites, and accept/reject. Nothing about how to display the list. And here https://getstream.io/chat/docs/#query_channels no pre-defined invites key for such cases.
As far as I can see, there is only one option so far: add a custom field for every invited person with. But it doesn't seem to be the right way to handle it
When you use the query channels API endpoint we do not return channels with pending invitations.
You can query channels based on their invite status:
Channels the user rejected:
const invites = client.queryChannels({
invite: 'rejected',
});
Channels with a pending invitation:
const invites = client.queryChannels({
invite: 'pending',
});
Note: You can also combine the invite field in your query as you would normally do for any other channel field.

Sending NotificationMessage by email to subscribed users

Does Moqui have a built-in mechanism to send notification message on a topic by email to the subscribed users?
Or should I implement a cusom NotificationMessageListener?
As of the last release of Moqui (2.1.1) and in the current GitHub code this is supported. The NotificationTopic entity has a emailTemplateId where you can specify the EmailTemplate to use for notifications on that topic. There is a simple OOTB EmailTemplate for notifications with emailTemplateId "NOTIFICATION" (defined in the MoquiInstallData.xml file).
The other side of this is the per-user configuration of whether to receive email for notifications on a given topic. The is stored in the emailNotifications field of the NotificationTopicUser entity. This can be set by users in the My Account app on the Notifications screens, or in the System app on the User Account screen.

Yodlee get_accounts sometimes returns zero result / empty response

Here is the scenario:
User logins to the bank successfully (via Fastlink)
Right after user logs in, I get user's provider_accounts (via /providerAccounts API)
Then when I call to get the accounts, (via /accounts) I sometimes get empty response (zero accounts found?)
When I try later (seconds or minutes after) I get some accounts information back.
Is this because Yodlee is still trying to gather account information when I'm making /accounts api call?
This is because the accounts are still being added/linked.
Using the requestId and providerAccountId provided by FastLink callback, you need to poll continuously to know the refresh status of the account linking process and once it's done, you can call the get accounts.
Read more about the refresh status in the "Add/Update Account Process Status" section.
Yodlee makes things easier now with webhooks. Read more here:
Using Webhooks with the Yodlee Core API
TL/DR: You need to wait for the add/link completion before retrieving the accounts.

Identify unique user in Dialogflow V1

So I am testing out Dialogflow and one of the first questions I have is: how does my bot know who it is talking to? I need to identify a user and keep that information for as long as I can. The basic scenario being:
User starts his/her first conversation.
Chatbot send a fulfillment request to the server trying to match a user within its own database.
The user is found, the information (as a JWT or some other token) is sent back to Dialogflow and stored there for further communication. In reality, this part would involve asking for user email, sending a verification code to that email and then verifying the user with the code.
User then starts chatting with a bot and all fulfillment requests get the unique token stored for this very user, so that my REST API knows which user is being served with the response.
Couldn't find anything about it in the docs (maybe I am looking in the wrong places).
There will be several integrations, like Messenger, Viber, Telegram. I dunno, maybe those APIs add some unique information on the user?...
Thanks for the help!
Sorry, I know it's been a while, but maybe this will help someone else.
The right solution here is a user id, not a session id. A user id is provided by the chat platform (Facebook, Slack etc) and is consistent across sessions for the same user.
To get the user id, go to the Fulfillment tab, enable the editor and use a function like so:
let r = request.body.originalDetectIntentRequest
//this makes sure that you're on an integration
if (r["source"]){
return r.payload.data.sender.id;
}
To tie together ids from different platforms, you probably have to have some kind of log-in process every time you encounter a new id on a platform.
Pop,
Sessions are built in already into DialogFlow requests to your fulfilment service, if you check the payload you will find a sessionId, it remains the same for the same client until it expires.
However if you want to identify the user from any of the clients that you can connect to DialogFlow like Messenger then from the same request payload to you you will notice that there is an object named originalRequest that is only available when requests are coming from those clients.
You can personalize those users response eg using their FB firstname in a message to them.

Viber REST API, how to find Unique Viber user id?

Resource URL https://chatapi.viber.com/pa/send_message
General send message parameters
I am trying to send message to viber from Postman. I don't know how to find Unique Viber user id, that parameter is required.
I am getting this error:
{"status":999,"status_message":"Bad receiver ID","message_token":5126721184521938239}
Danny Dainton mentioned the docs on how you can get data including unique ID about your own account not about somebody else!
You'll receive callbacks containing user unique ID to your webhook if a user subscribes to your public account, and ONLY THEN you'll be able to send message to that user.
As per viber docs:
The send_message API allows accounts to send messages to Viber users who subscribe to the account. Sending a message to a user will be possible only after the user has subscribed to the Public Account by pressing the subscribe button or by sending a message, or by sending a message to a bot (see subscribed callback for additional information).
and VERY IMPORTANT
Before an account can send messages to a user, the user will need to
subscribe to the account. Subscribing can take place in one of two
ways:
User sends message to the account (both Public Accounts and bots)
when a user sends its first message to a account the user will be
automatically subscribed to the account. Sending the first message
will not trigger a subscribe callback, only a message callback (see
receive message from user section). Subscribed event is sent to the
Public Account (Public Accounts only)
user clicks a subscribe button
which triggers the subscribe callback as described below.
Simple, just call the Get Account Info API, whose resource URL is https://chatapi.viber.com/pa/get_account_info
You will find the a list of all subscribers in the response along with their user IDs. Please note that these user IDs are unique per user per public account.
Correction: It seems like the Get Account Info API does not return all subscribers, it just returned for me my user ID (the admin of the public account). Based on this, there is no way to get the user IDs of your subscribers other than from the callbacks for new subscribers, messages, ...etc.
Normally you should collect Viber IDs from all callbacks and store in DB for future use. But if you missed that step you can collect Viber IDs of online subscribed users by periodic call to get_online endpoint and then use get_user_details endpoint to get more info about unknown ones.