> For the complete documentation index, see [llms.txt](https://docs.discordbotfactory.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.discordbotfactory.com/tutorials/auto-assign-roles.md).

# Auto Assign Roles

In this tutorial, you'll learn how to Auto Assign Roles to users when a trigger is executed, for example when a user joins a server.

### Creating the Trigger

Open the Node Companion and drag a When a member joins a server node onto the canvas.

<figure><img src="https://2205442932-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp603l6izRqmZfqN60GqQ%2Fuploads%2FsP7cY9l0RDESvSf33pRv%2Fimage.png?alt=media&amp;token=a2beef67-f072-4014-a43a-ccb1fa067f8b" alt=""><figcaption></figcaption></figure>

### Creating the Action

Back in the node companion, drag in an Add role to a user node and connect it to the trigger node.

<figure><img src="https://2205442932-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp603l6izRqmZfqN60GqQ%2Fuploads%2FXX9b2dgHfJ9w3okKzU2n%2Fimage.png?alt=media&amp;token=dbe24f43-3f62-417e-83e6-a994dbb25aab" alt=""><figcaption></figcaption></figure>

Double click the Add role node to edit its properties. You'll need to input either the ID or name of the role to give the user here. Click save.

<figure><img src="https://2205442932-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp603l6izRqmZfqN60GqQ%2Fuploads%2FibB5vmXzLD9wDpI2BzrZ%2Fimage.png?alt=media&amp;token=4e34a094-847f-4dad-a178-26dfce6aef84" alt=""><figcaption></figcaption></figure>

### Testing it out

Head to Discord and you'll notice that when a member joins they're automatically given the role you selected in the Add role node.
