# Is there a way to programmatically create a follow relationship between two users?

**URL:** <https://forum.social.plus/t/is-there-a-way-to-programmatically-create-a-follow-relationship-between-two-users/521>\
**Category:** Web\
**Created:** [September 4, 2022, 2:14am UTC](https://forum.social.plus/t/is-there-a-way-to-programmatically-create-a-follow-relationship-between-two-users/521 "2022-09-04T02:14:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![tahmeednabi](https://avatars.discourse-cdn.com/v4/letter/t/71e660/32.png) [@tahmeednabi](https://forum.social.plus/u/tahmeednabi)\
**Post date:** [September 4, 2022, 2:14am UTC](https://forum.social.plus/t/is-there-a-way-to-programmatically-create-a-follow-relationship-between-two-users/521/1 "2022-09-04T02:14:48Z")

</div>

I’m trying to make follow requests work more similar to the Facebook friends architecture, where after a request is accepted, the relationship is created bidirectionally, but I havent found a way to create follow relationships with the API. Is there some other way to achieve what I’m trying to do?

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [September 5, 2022, 8:56am UTC](https://forum.social.plus/t/is-there-a-way-to-programmatically-create-a-follow-relationship-between-two-users/521/2 "2022-09-05T08:56:25Z")

</div>

Hello @tahmeednabi our product already supports follow/unfollow feature, here’s our docs: [Follow / Unfollow - Amity Docs](https://docs.amity.co/social/web/follow-unfollow) , is this what you are looking for?

---

<div class="post-metadata">

**Author:** ![tahmeednabi](https://avatars.discourse-cdn.com/v4/letter/t/71e660/32.png) [@tahmeednabi](https://forum.social.plus/u/tahmeednabi)\
**Post date:** [September 5, 2022, 9:35am UTC](https://forum.social.plus/t/is-there-a-way-to-programmatically-create-a-follow-relationship-between-two-users/521/3 "2022-09-05T09:35:39Z")

</div>

Yes I’m using that feature, but trying to create follow requests between users server side, so that I can make it work like the facebook friends relationships. To be more clear:

**Default amity follow method:**  
User A requests to follow User B, User B can accept or reject. User B has to then follow User B back, which User A needs to also accept or reject.

**Method I’m looking for**  
User A requests to follow User B. User B can accept or reject. If accepted, User B automatically also follows User A and is automatically accepted.

To achieve this I wanted to see if there was some way to create that follow relationship given two user IDs by calling some sort of API.

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [September 5, 2022, 11:32am UTC](https://forum.social.plus/t/is-there-a-way-to-programmatically-create-a-follow-relationship-between-two-users/521/4 "2022-09-05T11:32:34Z")

</div>

In this case, we would recommend you to follow this flow:

> - After user A accepts a follow request from user B, then at the same time, call the follow function for user A to follow user B back (this will result as an auto-follow)
> - You can filter/observe this event on frontend

---

<div class="post-metadata">

**Author:** ![tahmeednabi](https://avatars.discourse-cdn.com/v4/letter/t/71e660/32.png) [@tahmeednabi](https://forum.social.plus/u/tahmeednabi)\
**Post date:** [September 6, 2022, 9:50am UTC](https://forum.social.plus/t/is-there-a-way-to-programmatically-create-a-follow-relationship-between-two-users/521/5 "2022-09-06T09:50:35Z")

</div>

Thanks for getting back to me so quick.

I think I’ve implemented the system as you’ve described, however I’m not observing the “auto-follow” behaviour you’re describing. I’m using the typescript SDK to run a query to accept the request from a user and follow them back at the same time, as shown in code below:

```auto
const query1 = createQuery(acceptFollower, userId);
await runQuery(query1);
const query2 = createQuery(follow, userId);
return runQuery(query2);

```

However, as I said the auto-follow isnt working, and instead the user needs to accept the follow request themselves. Let me know If I’ve done something wrong. Thanks!

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [September 7, 2022, 6:50am UTC](https://forum.social.plus/t/is-there-a-way-to-programmatically-create-a-follow-relationship-between-two-users/521/6 "2022-09-07T06:50:11Z")

</div>

Hi @tahmeednabi after discussing with the team, we would recommend you to use Without Request process instead, please see the docs here [https://docs.amity.co/social/typescript-react-native/follow-unfollow#user-connection-method-concept](https://docs.amity.co/social/typescript-react-native/follow-unfollow#user-connection-method-concept)

Please let us know if this can achieve what you want to do?

---

<div class="post-metadata">

**Author:** ![tahmeednabi](https://avatars.discourse-cdn.com/v4/letter/t/71e660/32.png) [@tahmeednabi](https://forum.social.plus/u/tahmeednabi)\
**Post date:** [September 7, 2022, 7:09am UTC](https://forum.social.plus/t/is-there-a-way-to-programmatically-create-a-follow-relationship-between-two-users/521/7 "2022-09-07T07:09:27Z")

</div>

In that case, if User A follows User B, wouldn’t posts by User B be visible to User A (in their social feed), automatically, without their approval?

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [September 7, 2022, 7:32am UTC](https://forum.social.plus/t/is-there-a-way-to-programmatically-create-a-follow-relationship-between-two-users/521/8 "2022-09-07T07:32:46Z")

</div>

Yes, if user A follow user B, user B’s posts will automatically be visible to user A
