Custom Variables

For power-users, custom variables make your conversation dynamic and allow you to ingest outside data.

Setting Custom Variables in Modules

Within any module initial response or error response, you may include the following tag to set a custom variable:
[customVar KEY=VALUE], where KEY is the name of the variable and VALUE is its contents. Custom variables are key-value pairs.

Later in the flow, you could include [[KEY]] and it would print VALUE.

Setting Prior Responses to Custom Vars

You can set custom vars with values from prior modules
(see: http://docs.motion.ai/docs/referencing-prior-responses).

For example:

[customVar testVariable=[responseTo module=12345 fallback=foobar]]

This will set a user's most recent response to module 12345 to a custom variable named testVariable which can be referenced later in the conversation by using the tag [[testVariable]] in your bot response!

Utilizing Custom Variables via Webhooks

As detailed in the Webhook documentation, we will make a POST request to your server for every message your bot sends or receives. We await your server's response before sending a message, in case you wish to include custom variables.

To ingest custom variables, respond to our webhook request with a JSON object. In the example below, the variable firstname will get ingested with a value of David

{ "firstname": "David" }

Once you've setup your webhook and are responding with valid JSON containing your variables, you can invoke them within your bot's modules by wrapping the desired variable key name (in this case, firstname) in double brackets, like this:

Your bot will replace [[firstname]] with the value (in this case, David), before rendering the response to your end-user.

Pretty cool, huh? Now if you want to get really fancy, you can combine the use of custom variables with Connections... Take the example below for example, where users would be directed to welcome (ID: 436) only if the custom variable contained David

Webhook Required

To use custom variables, you must have a valid webhook configured. See here for more details.

Custom Variables

For power-users, custom variables make your conversation dynamic and allow you to ingest outside data.