# Recipes

> One action does one thing. To get something done you run a few, one after the other: the answer of one gives you what the next one needs.

## Find people and invite them

Search for the kind of person you want to meet, then send each one an invitation.

1. Search. Each person in the answer has a profileUrl.

   ```
   POST https://api.heyreagent.com/v1/actions/search_people

   {
     "keywords": "head of sales",
     "location": "Berlin"
   }
   ```

2. Send one invitation per person. Keep the invitationId from the answer if you may want to take it back.

   ```
   POST https://api.heyreagent.com/v1/actions/send_invitation

   {
     "note": "Hello, I would like to connect.",
     "profileUrl": "FROM_STEP_1"
   }
   ```
   `FROM_STEP_1` is `people[].profileUrl` from the answer of step 1. It goes in `profileUrl`.

## Take back an invitation nobody answered

See which invitations are still waiting, and withdraw one.

1. List the invitations you sent that are still unanswered.

   ```
   POST https://api.heyreagent.com/v1/actions/list_sent_invitations

   {}
   ```

2. Withdraw one. This cannot be undone.

   ```
   POST https://api.heyreagent.com/v1/actions/withdraw_invitation

   {
     "invitationId": "FROM_STEP_1"
   }
   ```
   `FROM_STEP_1` is `pendingInvitations[].invitationId` from the answer of step 1. It goes in `invitationId`.

## Read a conversation and reply

Open your inbox, read one conversation, and answer in it.

1. List your unread conversations. Each one has an id.

   ```
   POST https://api.heyreagent.com/v1/actions/list_chats

   {
     "unread": true
   }
   ```

2. Read the messages of one conversation.

   ```
   POST https://api.heyreagent.com/v1/actions/list_chat_messages

   {
     "chatId": "FROM_STEP_1"
   }
   ```
   `FROM_STEP_1` is `chats[].id` from the answer of step 1. It goes in `chatId`.

3. Reply in that same conversation.

   ```
   POST https://api.heyreagent.com/v1/actions/send_chat_message

   {
     "text": "Thanks for your message!",
     "chatId": "FROM_STEP_1"
   }
   ```
   `FROM_STEP_1` is `chats[].id` from the answer of step 1. It goes in `chatId`.

## Answer the invitations you received

See who wants to connect with you, and accept or decline.

1. List the invitations waiting for your answer.

   ```
   POST https://api.heyreagent.com/v1/actions/list_received_invitations

   {}
   ```

2. Accept (or use "decline").

   ```
   POST https://api.heyreagent.com/v1/actions/respond_to_invitation

   {
     "action": "accept",
     "invitationId": "FROM_STEP_1"
   }
   ```
   `FROM_STEP_1` is `invitations[].invitationId` from the answer of step 1. It goes in `invitationId`.

## Invite the people who reacted to a post

Turn the people who liked a post into new connections.

1. Paste the link of the post. The answer lists who reacted and who commented.

   ```
   POST https://api.heyreagent.com/v1/actions/get_post_engagers

   {
     "postUrl": "PASTE_POST_LINK_HERE"
   }
   ```

2. Send one invitation per person.

   ```
   POST https://api.heyreagent.com/v1/actions/send_invitation

   {
     "profileUrl": "FROM_STEP_1"
   }
   ```
   `FROM_STEP_1` is `reactors[].linkedinUrl` from the answer of step 1. It goes in `profileUrl`.

## Search with a LinkedIn filter (for example, a city)

LinkedIn filters take its own ids, not names. First look the id up, then search with it.

1. Look up the id of the place.

   ```
   POST https://api.heyreagent.com/v1/actions/lookup_search_ids

   {
     "type": "LOCATION",
     "keywords": "Berlin"
   }
   ```

2. Search with that id as the location filter.

   ```
   POST https://api.heyreagent.com/v1/actions/search_linkedin_people

   {
     "keywords": "head of sales",
     "location": [
       "FROM_STEP_1"
     ]
   }
   ```
   `FROM_STEP_1` is `matches[].id` from the answer of step 1. It goes in `location`.

3. Read one person from the results in full.

   ```
   POST https://api.heyreagent.com/v1/actions/get_profile_details

   {
     "person": "FROM_STEP_2"
   }
   ```
   `FROM_STEP_2` is `results[].publicProfileUrl` from the answer of step 2. It goes in `person`.

## Comment on someone's latest post

Find what a person posted, and leave a comment.

1. List the person's posts, newest first.

   ```
   POST https://api.heyreagent.com/v1/actions/list_posts_by_author

   {
     "author": "PASTE_PROFILE_LINK_HERE"
   }
   ```

2. Comment on one of them.

   ```
   POST https://api.heyreagent.com/v1/actions/comment_on_post

   {
     "text": "Great post!",
     "postUrl": "FROM_STEP_1"
   }
   ```
   `FROM_STEP_1` is `posts[].socialId` from the answer of step 1. It goes in `postUrl`.
