Initialize Actor
Last updated
Last updated
The Initialize Actor Action sets the values for the Journey's current Actor. The Actor is an object that represents the current user's information.
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.
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.
A Chat Bot and Voice Bot can only text or call the user once the actor_internal
has been initialized with a phone number.
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.
Note that by default, a new App will start with two Actions added to its Journey Start Event: a Set Variable Action that copies session.start
to your actor
variable and the Initialize Actor Action. This is to easily allow for typical Chat Bot and Voice Bot behavior.
When the user texts a number to launch a Chat Bot, the session.start
variable is populated with the user's phone number. The App copies that value to actor
then calls Initialize Actor, which allows a Chat Bot to send a text back to the user.
If your App requires more complex behavior, such as collecting the user's phone number in a Web Flow and starting a Chat Bot with that number, it will be necessary to add a new Initialize Actor Action to the Web Flow once the actor
variable's phone number has been set.
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
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
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.