# Initialize Actor

The **Initialize Actor** Action sets the values for the Journey's current [Actor](../concepts/actors). The Actor is an object that represents the current user's information.

![](https://3333962744-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbnBffrSN2FHLC5cM89AM%2Fuploads%2Fgit-blob-731dd8662222035f2efa9e1e954c381b76b1941b%2Fthe-initialize-actor-action-v183-0.png?alt=media)

When Initialize Actor is triggered, the `actor` variable is copied into Airkit's `actor_internal` variable for the current Journey. The main use of the `actor_internal` variable is so that a Chat Bot or Voice Bot knows which phone number to text or call.

The diagram below represents a Journey right before the Initialize Actor Action is called. The `actor` variable has been set using the [Set Variable Action](the-set-variable-action).

![organizing info](https://3333962744-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbnBffrSN2FHLC5cM89AM%2Fuploads%2Fgit-blob-9e1c8a4855680ecd7a017c0c1b941b02af772b3f%2Fthe-initialize-actor-action-v183-1.png?alt=media)

This next diagram represents what happens when the Initialize Actor Action is triggered. Whatever is stored in the `actor` variable gets copied to Airkit's internals. Note that it is not possible for your App to access the `actor_internal` variable directly.

![organizing info](https://3333962744-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbnBffrSN2FHLC5cM89AM%2Fuploads%2Fgit-blob-50988ee4cbe65e19f96ba5ec2e93d34e509f29a0%2Fthe-initialize-actor-action-v183-2.png?alt=media)

[Chat Bots](the-start-chat-bot-action), [Voice Bots](the-start-voice-bot-action), and [SMS Notifications](send-sms-notification-action) can only text or call the user once the `actor_internal` has been initialized with a phone number. [Email Notifications](send-email-notification-action) can only be sent once `actor_internal` has been initialized with an email address.

If there is an active Journey with an `actor_internal` whose phone number is the same as the `actor` when Initialize Actor is called, the Existing Session Behavior is triggered, as described below.

## Default Behavior

Note that by default, a new App will start with two Actions added to the **Session Start** Event (found in the [Connections Builder](../studio/studio/builder-bar/connections-builder) under **Session**): a **Set Variable** Action that copies `session.start` to your `actor` variable and the **Initialize Actor** Action. This is to easily allow for typical incoming phone and SMS behavior.

![](https://3333962744-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbnBffrSN2FHLC5cM89AM%2Fuploads%2Fgit-blob-a6983043c73e8ff36e185b765294af8ee764905e%2Fthe-initialize-actor-action-v183-3.png?alt=media)

When the user begins a Journey with an incoming call or text, the `session.start` variable is populated with the user's phone number. The App copies that value to `actor` then calls Initialize Actor, which Dialogue Bots (ie: Voice Bots and Chat Bots) to reply to the user immediate through the channel they used to begin their Journey.

If your App requires more complex behavior, such as collecting the user's phone number or email address in a Web Flow and using those to send outgoing calls, texts, or Email Notifications, it will be necessary to add a new **Initialize Actor** Action to the Web Flow once the `actor` variable has been set with the relevant information.

## Use Cases

* To initialize the Actor when a user texts a Chat Bot and starts a new Journey, so that the Chat Bot can reply
  * This is the Default Behavior as described above
* To collect the user's phone number in a Web Flow, then initialize the internal Actor to start a Voice Bot or Chat Bot with that user

## Properties

### Existing Session Behavior

If there is another active Journey with the same phone number in `actor_internal` when **Initialize Actor** is called, this property will determine how your App responds.

**Replace**

If there is an existing Journey with the same phone number, the latest text or call will take over that existing Journey.

This is most useful for a Chat Bot. When a user texts a Chat Bot, the Chat Bot should continue from the state of the running Chat Bot Journey. If a Chat Bot used the **Fail** behavior, each new text would start the Chat Bot over from the beginning.

**Fail**

If there is an existing Journey with the same phone number, the newer incoming call or text will be rejected.

This is most useful for a Voice Bot. If there is an active call with a user, and another call comes in with the same phone number (using Google Voice or similar), the second call should not be able to connect with the running Voice Bot Journey.

## Example

In this example, the Initialize Actor Action is triggered from an Event, which is capturing the informaion the user entered in a form. This way, the user and all their information saved in the  `actor` Variables will be set as the Actor of the Session.

![](https://3333962744-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbnBffrSN2FHLC5cM89AM%2Fuploads%2Fgit-blob-4d302ab139711247479b95ea43f4f3a5c4ba6e14%2Fthe-initialize-actor-action-v183-4.png?alt=media)
