Hello, Everyone
I am helping as a junior software developer in the psychological clinic office. There are 5 working doctors in the clinic. There are too many direct messages to the doctors on Twitter. They want the office assistant to answer these messages.

I want to make an application. Doctors will log in with Twitter. It will create rules for direct messages according to certain criteria.

Can the assistant answer via the app without logging into the doctor’s twitter account?

I want to do this application. Which API functions can I use? Please write your ideas.

I added the Login with a Twitter feature to the application. I want to collect the doctors who log in to the application under the clinic. The assistant can reply to messages on behalf of the doctors.

Question 1. How can I keep the sensitive account information of doctors? You can see their accounts under the clinic.

Thank you so much.
Happy code.

1 Like

One already existing solution could be tweetdeck teams: https://help.twitter.com/en/using-twitter/tweetdeck-teams this way assistants can read & respond to DMs on behalf of doctors.

If you really want to code your own, you may want to look at the Account Activity API:

To enable twitter accounts to log into your app - you will have to implement https://developer.twitter.com/en/docs/authentication/guides/log-in-with-twitter

After those are working it should be straight forward to figure out what assistant accounts should have access to post on the doctor’s behalf by your own app logic.

The information you will keep are access tokens and access token secrets - treating these as if they were passwords https://developer.twitter.com/en/docs/authentication/guides/authentication-best-practices

Thank you Igor.
Tweetdeck doesn’t solve my problem.
How can I get a list of users logged in with the Twitter API?

You cannot - when you implement Login with twitter, your application code should keep records of the tokens you generate for different accounts (and tie them to twitter accounts that should or should not have access). These tokens do not expire - but they also won’t appear again the exact same, so it’s important to keep them safe.

Coordinating which user login can post on behalf on which “doctor” will all have to be done by your app. Every call made to the twitter API can be made on behalf of a user (using the appropriate access token that belongs to a user), so it’ll be up to you to implement that.

Thank you. You share great ideas.

I save the Twitter user_id = 12345678 of the user who is logged in with the application. The user authorizes my application.

How can I list Direct Messages to a user? I reviewed the Twitter API. direct_messages / events / list? user_id is not returning the messages of the user authorizing the application. The API brings the user messages by default.

How can I reply to the message on behalf of the user?

The user can then revoke access the application. How can I control it?

I save the Twitter user_id = 12345678 of the user who is logged in with the application. The user authorizes my application.

Yep - this is the way to do it - save their access token and access token secret returned by twitter after they authorize your application.

direct_messages / events / list? user_id is not returning the messages of the user authorizing the application.

When authenticating and issuing that request, you need to use the access token that belongs to the user that you want to check DMs for - so the access token looks like 12345678-sadfgasgwedrywt34ty435dg or something - the first part of it before the - is the user id, in case that makes it easier to identify.

The same goes for posting tweets , DMs on behalf of someone else https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/sending-and-receiving/api-reference/new-event - you’ll use your Application keys and Their access tokens.

The user can then revoke access the application. How can I control it?

This is entirely up to the user - so if they no longer want your app to have access they can revoke it, you cannot prevent this. They will be able to authorize your app again, generating a different access token. To check if the user has revoked your app - you can use https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/get-account-verify_credentials

Hope that helps!

Thank you very much. I didn’t reply due to the covid.
Login success the user, I want this user’s access token.
Post request with user’s oauth_token and oauth_verifier but the response (http status 401) “This feature is temporarily unavailable”. Post method, no auth (reference https://developer.twitter.com/en/docs/authentication/api-reference/access_token)

For example;
https://api.twitter.com/oauth/access_token?oauth_token=xxxxx&oauth_verifier=yyyy

Is the app enabled for login? Should say “3-legged OAuth is enabled” on your app settings in developer.twitter.com

What language / library are you using? Are there 401 or other errors for other calls?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.