How To Make A Tinder Bot That Acts Like You

Today, we’re going to automate everything about Tinder with a bot using Python, Dialogflow, Twilio, and the Tinder API!

Our bot will automate likes on Tinder and have conversations with our matches, talking like a normal human. Then, if the person asks to hangout, we’ll get a text message with their profile and be able to setup a date with them or decline the request.

Here’s a very crude flow diagram we’re going to be basing the project around:

  • Note: Thanks to my friend Jenny for letting me use her Tinder account for testing / development.

To start, we’re going to be getting familiar with the Tinder API.

After git cloning the API and running the config files (I recommend setup via SMS) to connect our Tinder account, we should test it!

from tinder_api_sms import *
print(get_recommendations());

Saving this in a file called test.py and running it will successfully dump us all the data about our “recommendation deck” on Tinder:

After we look through this data, we can isolate just what we want. In this case, I am parsing through and extracting the bio’s of our recommendations.

from tinder_api_sms import *
import pprint;
printer = pprint.PrettyPrinter(indent = 4);
recs = get_recommendations()["results"];
for person in recs:
    person_id = person["_id"];
    person_bio = person["bio"];
    print(person_bio);

But, we don’t want to just look at this data. We’re going to automate the liking, or swiping right, on Tinder. To do this, in our for loop, we just have to add:

like_person(person_id);

When we run this, we can see that we already start making matches:

So, we just have to run this every couple minutes or so, and automating the likes on Tinder is done! That’s alright, but this was the easy part.

To automate the conversations, we’re going to be using DialogFlow, which is Google’s machine learning platform.

We have to create a new agent, and give it some training phrases and sample responses using “Intents”.

The Intents are categories of dialog, so I added common ones such as talking about how am I are doing, what are my hobbies, talking about movies, etc. I also filled out the “Small Talk” portion of our model.

Then, add the intents to the fulfillment and deploy it!

When we test it on DialogFlow, such as asking our Tinder profile how it’s doing with “hyd”, it replies “good! hbu?” which is what Jenny would say!

To connect the DialogFlow to our Tinder account, I wrote this script:

import dialogflow
import os   
from google.api_core.exceptions import InvalidArgument
DIALOGFLOW_PROJECT_ID = '#'
DIALOGFLOW_LANGUAGE_CODE = 'en-US'
GOOGLE_APPLICATION_CREDENTIALS = 'C:\\Users\\natha\\Documents\\TinderAPI\\Tinder\\#.json'
credential_path = "C:\\Users\\natha\\Documents\\TinderAPI\\Tinder\\#.json"
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = credential_path
text_to_be_analyzed = "hyd" #this would be a message from Tinder
session_client = dialogflow.SessionsClient()
session = session_client.session_path(DIALOGFLOW_PROJECT_ID, SESSION_ID)
text_input = dialogflow.types.TextInput(text=text_to_be_analyzed, language_code=DIALOGFLOW_LANGUAGE_CODE)
query_input = dialogflow.types.QueryInput(text=text_input)
try:
    response = session_client.detect_intent(session=session, query_input=query_input)
except InvalidArgument:
    raise
print("Query text:", response.query_result.query_text)
print("Detected intent:", response.query_result.intent.display_name)
print("Detected intent confidence:", response.query_result.intent_detection_confidence)
print("Fulfillment text:", response.query_result.fulfillment_text)

So, now we have to pull the unread messages that people have sent Jenny on Tinder. To do this, we can run:

from tinder_api_sms import *;
from features import *;
import pprint
import datetime
import string
printer = pprint.PrettyPrinter(indent=4)
#recs = get_recommendations()["results"];
count = "50";
match_dict = all_matches(count);
date = str(datetime.datetime.now()).replace(" ", "");
#print(date);
self_dict = get_self();
selfId = self_dict['_id'];
matches = match_dict["data"]["matches"];
#find last message that we didnt send for each user
for user in matches:
 userId = user['_id'];
 if user['messages']:
  lastMessage = user['messages'][-1];
  if lastMessage['from'] != selfId:
   message = lastMessage['message'];
   printer.pprint(message);

This outputs the most recent messages that people have sent to Jenny:

So, now we just combine this data with DialogFlow, which will give us a reply based on our training models!

On Tinder so far, it kind of works:

But sometimes times it doesn’t really work:

This happened because our chatbot doesn’t know what he’s talking about, and I set the default response to laugh.

All we need to do now is add more Intents and let our chatbot talk to more people, as it‘ll automatically grow smarter with each conversation it has.

As we let that run, we’re going to implement the “last” part, which is integrating SMS. Again, the idea is that if the person asks to hangout after talking for a while, we’ll get a text message with their profile and be able to setup a date with them or decline the request.

To do this, we’re going to be using Twilio, an API for dealing with SMS. Here’s a test script that will send us a text message:

from twilio.rest import Client
# Your Account Sid and Auth Token from twilio.com/console
account_sid = ''
auth_token = ''
client = Client(account_sid, auth_token)
message = client.messages \
                .create(
                     body="Text Message",
                     from_='SETUP ON TWILIO',
                     to='YOUR OWN PHONE NUMBER'
                 )
print(message.sid)

Here we can connect it to our Tinder Bot:

def twilioMsg(name, pic, message, id):
 message = client.messages \
                .create(
                     body = "After talking with \'you\' for a bit, " + name + " " + message + "\n \n if you might want to hangout, check out the interaction on tinder! \n \n if not, please reply with the ID of the person. \n \n ID: " + id,
                     from_='+14082157063',
                     media_url = pic,
                     to = '+14088911891'
                 )
print(message.sid)
printer = pprint.PrettyPrinter(indent=4)
self_dict = get_self();
selfId = self_dict['_id'];
def automated_replies():
 #recs = get_recommendations()["results"];
 count = "90";
 match_dict = all_matches(count);
matches = match_dict["data"]["matches"];
#find last message that we didnt send for each user
 for user in matches:
userId = user['_id'];
  if user['messages']:
   lastMessage = user['messages'][-1];
   if lastMessage['from'] != selfId:
    message = lastMessage['message'];
    reply = MLtext(userId,message);
    reply = reply.lower();
    print(reply)
    if "hangout with you" in reply:
     name = user['person']['name'];
     pic = user['person']['photos'][0]['processedFiles'][0]['url'];
     twilioMsg(name, pic, reply, userId);
elif reply:
     send_msg(userId, reply); 
 #s.enter(150, 1, automated_replies);

Then, to register our response from our phone that goes back to Twilio, we’re going to use webhooks. To implement this, we’ll use Flask and ngrok in this script:

from flask import Flask, request
from twilio import twiml
from twilio.twiml.messaging_response import Message, MessagingResponse
from tinder_api_sms import *;
from features import *;
import datetime
import string
import dialogflow
import os   
from google.api_core.exceptions import InvalidArgument
from twilio.rest import Client
account_sid = '#'
auth_token = '#'
client = Client(account_sid, auth_token)
app = Flask(__name__)
@app.route('/sms', methods=['POST'])
def sms():
    number = request.form['From']
    message_body = request.form['Body']
    send_msg(message_body, "my bad sorry, i can't hangout. i hope you have a terrific day tho");
resp = MessagingResponse()
    resp.message('Hello {}, you said: {}'.format(number, message_body))
    return str(message_body)
if __name__ == '__main__':
    app.run()

So yeah, now we’re pretty much done! We let the bot run a little bit and when someone asks to hangout, like:

We get a text message:

We just automated almost pretty much everything about Tinder! As some next steps, the ML chatbot could definitely be improved, and we can implement some ML facial analysis to swipe right based on some sort of objective attractiveness of each person, instead of swiping right on everyone.

But yeah, that’s pretty much it. You can check out all the code on my Github, and don’t hesitate hit me up if you have any questions or concerns!

Source: Medium

Happy learning!

6 Likes

too bad you would need to still talk to them in person

1 Like

*If this works, I 'am up for a project thanks * @PlayBoy83