# How TextWork begins a conversation

A conversation starts when someone reaches a script you have already set up. There are three ways that happens: they text a join code to your company number, a webhook arrives from SmartRecruiters or Zillow, or they use something you embedded on your own site (a chat widget, a booking widget, or a form).

The conversation is saved on your company. Texts show up on the contact who sent or received them. A chat widget saves the thread on a contact named Website visitor.

## Join codes

A join code is a short phrase someone texts to your company number. TextWork matches the words, creates them as a contact if they are new, and starts the script you attached. There is no `JOIN` prefix. A phrase like `apply` or `clean green building` is the whole code. Spaces and hyphens are the same code.

Create one under Company Settings, on the Team tab, in the Join Codes card.

1. Open Company Settings and choose Team.
2. Create a join code. Under Report types, check at least one. The first one checked in the list is the script that starts when they text the code. Every report type you check is granted to that person, including a script that is set to be shared only by join code.
3. Leave the phrase blank to generate one from your word list, or type your own. You can also set a maximum number of uses.
4. Copy the share line. It reads like `Text apply to (your number) to get started.` Put that on a flyer, a job post, a QR code, or your site.

A new number does not have a name on file yet, so the script should ask. Someone who already exists is greeted and the script starts again.

A number TextWork does not know, that texts something other than a join code, gets one reply: "This is TextWork. Reply with your join code to get started." That prompt goes out at most once a day. After that the number stays quiet until they send a real code.

## Webhooks

SmartRecruiters and Zillow both start a text. You pick the script in Company Settings, under Integrations. TextWork only texts the person when the event includes a phone number. No phone means the event is saved and skipped, and no conversation starts.

### SmartRecruiters

When someone applies, SmartRecruiters notifies TextWork with an `application.created` event. TextWork looks up the candidate and, if they have a phone number, texts them and runs the script you chose.

1. In SmartRecruiters, open [custom applications](https://www.smartrecruiters.com/settings/administration/app-management/custom-applications). Choose New Credential, then API Key, and name it TextWork.
2. In TextWork, open Company Settings, then Integrations, then SmartRecruiters.
3. Paste the API key, choose the script, and connect. TextWork registers the webhook and turns it on. The key needs permission to manage webhooks.
4. Make phone number a required field on the application. A candidate with no phone is skipped.

### Zillow

Zillow Rentals delivers a lead to a webhook URL you send them. If the lead includes a phone number, TextWork texts them and runs the script you chose.

1. Open Company Settings, then Integrations, then Zillow.
2. Choose the script and activate. TextWork shows a webhook URL and a security token.
3. Email both to [rentalfeeds@zillow.com](mailto:rentalfeeds@zillow.com). Ask them to deliver leads to that URL, and to send the token as a static security header.
4. A lead with no phone number is skipped.

## Website widgets and forms

Widgets are created in Company Settings and pasted onto your site. A chat widget talks to the visitor in the browser. A form widget collects their details and then texts them. A booking widget puts a meeting page on the site and does not start a text.

### Chat widget

A chat widget runs on the page, in the browser, using the script you pin to it. The visitor is saved on your company as a contact named Website visitor. TextWork does not text their phone.

1. Open Company Settings, then Widgets, and create a chat widget. Set the greeting and choose the script.
2. Open the Deploy tab, copy the embed, and paste it before the closing `</body>` tag.

```html
<script src="https://textwork.co/widget.js" data-widget="YOUR_PUBLIC_KEY" async></script>
```

On Deploy, Allowed sites is one domain per line. Leave it empty to allow any site. textwork.co is always allowed, so the preview in the dashboard works.

### Booking widget

A booking widget embeds one of your meeting pages. The visitor picks a time on the card. It does not start a text conversation.

Create it under Company Settings, then Widgets, choose Booking, and point it at a meeting page. Paste the embed where the card should appear.

```html
<script src="https://textwork.co/widget.js" data-widget="YOUR_PUBLIC_KEY" data-inline async></script>
```

Add `data-target="#id"` to render the card inside a specific element. The card stays at most 36rem wide and grows with its content.

### Form widget

A form widget collects answers on your site and then starts a script by text. It does not ask the visitor to pick a time. The form needs a phone field. Within a few seconds of a valid submit, TextWork texts that number and runs the script you attached. The other answers are passed to the script as context. If that phone already belongs to a contact at your company, that contact is reused.

1. Open Company Settings, then Widgets, and create a form widget. Pick the script that should text them.
2. Open Edit form to change the fields, the button, and the consent line.
3. Open the Deploy tab, copy the embed, and paste it where the card should appear.

```html
<script src="https://textwork.co/widget.js" data-widget="YOUR_PUBLIC_KEY" data-inline async></script>
```

Add `data-target="#id"` to render the card inside a specific element. The card stays at most 36rem wide and grows with its content.
