# Requesting Feedback

In Part VI, we configured a follow-up Notification that was sent only conditionally, which ensured app users made an appointment. Now, we'll build out a flow that collects user feedback once the appointment they made is over.

## Configuring the Collect Feedback Web Flow

1. In **Web Flows** Builder, select the Collect Feedback Web Flow and rename the associated Web Page to “Collect Feedback”.
2. Add a **Label** asking the user how the appointment went.
3. Add a **Text Area Input Control**.
4. Add a **Button Control** and change its text to “Submit Feedback”.

![](https://2599974655-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIRF6etABDVMr59RdpyGw%2Fuploads%2Fgit-blob-d703f269bf9441d554161730d07e55abf81894a7%2Frequesting-feedback-v184-0.png?alt=media)

5. Inspect the "Submit" Button selected, and toggle over to the **Actions** tab. Add a \*\*Navigate to Web Page \*\*Action and select **Add Web Page**.

![](https://2599974655-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIRF6etABDVMr59RdpyGw%2Fuploads%2Fgit-blob-f66aa097ad6b992cd47fb8fda659dc70b808d438%2Frequesting-feedback-v184-1.png?alt=media)

6. Go to the new Web Page in the Tree and rename it to “Thank you”.
7. Add a Label to thank the user for their feedback. Personalize the message by including the `actor.first_name` variable:

```javascript
"Thank you for your feedback, {{actor.first_name}}!"
```

![](https://2599974655-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIRF6etABDVMr59RdpyGw%2Fuploads%2Fgit-blob-b116eb5a76ddcb4c01294983aaa639b460bfeed2%2Frequesting-feedback-v184-2.png?alt=media)

8. Save the app

## Creating the App Object to save users’ info

Let’s create an app object for the fields we want to store.

1. Go to **AirData** Builder and create a Feedback App Object with the following fields:
   * `feedback` Variable of Type Text
   * `phone` Variable of Type Phone. This attribute is the same one as the actor’s since it serves to identify the user.

<figure><img src="https://2599974655-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIRF6etABDVMr59RdpyGw%2Fuploads%2Fgit-blob-0f4a12318cb25596404ec056ca314a5e918455ed%2Frequesting-feedback-v184-3.png?alt=media" alt="" width="300"><figcaption></figcaption></figure>

2. Save the app.

## Creating the Data Flow to save feedback

In order to save the information into AirData, the next step is to create a Data Flow.

1. Go to **Connections** Builder and create a Data Flow from scratch. Rename it to “Save Feedback”.
2. In **Start**, add the following:
   * `phone` Variable of Type `Phone`
   * `feedback` Variable of Type `Text`

<figure><img src="https://2599974655-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIRF6etABDVMr59RdpyGw%2Fuploads%2Fgit-blob-2147438162e28dca41d1425a79bc8d539abb33a3%2Frequesting-feedback-v184-4.png?alt=media" alt="" width="300"><figcaption></figcaption></figure>

3. By clicking on the ‘+’ icon, add an AirData Request Data Operation.
   * In **App Object**, select the one we have just created
   * For **Type** select INSERT
   * In **Objects to Insert or Update**, enter the Keys one by one from the ‘+’ icon and match them with their corresponding Variables:

<figure><img src="https://2599974655-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIRF6etABDVMr59RdpyGw%2Fuploads%2Fgit-blob-78240b92dcd3de8c55ee785a8cb9d2d5e0eb7d0c%2Frequesting-feedback-v184-5.png?alt=media" alt="" width="400"><figcaption></figcaption></figure>

4. In **Run Results**, check that your Data Flow runs.
5. Save the app.

## Passing the Information to the Data Flow

1. Go back to **Web Flows** Builder. With the Submit Feedback Button selected, go to **Actions** and add a **Run Data Flow** Action.
2. Select the Save Feedback Data Flow and pass the following Variables:

* `actor.phone` for the phone input
* `text_area` for the feedback input as that was the auto generated variable we got when adding the Text Area Input control to the Web Flow.

![](https://2599974655-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIRF6etABDVMr59RdpyGw%2Fuploads%2Fgit-blob-f4fbf60a49c4d514dec1c15343bc29b97d4ff7b1%2Frequesting-feedback-v184-6.png?alt=media)

## Informing the user

Now we need to configure is a Notification inviting users to submit some feedback once their appointment is over.

1. In **Notifications** Builder, add another SMS Notification and rename it to “Ask for Feedback”.

<figure><img src="https://2599974655-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIRF6etABDVMr59RdpyGw%2Fuploads%2Fgit-blob-37d5f2cd73b23e5aa24aa65faee4e9276caf1318%2Frequesting-feedback-v184-7.png?alt=media" alt="" width="300"><figcaption></figcaption></figure>

2. Add a text inviting the user to submit some feedback. Personalize the message by entering `actor.first_name` in Custom Airscript Expression.
3. Click on the ‘+’ sign below the message and add a separate **Link to Journey** step to direct the user.

![](https://2599974655-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIRF6etABDVMr59RdpyGw%2Fuploads%2Fgit-blob-3f28ad9020d71fa6d4217f3edfc313cc07e96f1d%2Frequesting-feedback-v184-8.png?alt=media)

## Requesting Feedback after the appointment ends

1. In **Web Flows** Builder, go to the Scheduler Control in the Schedule Appointment Web Flow. In the **Actions** tab of the Inspector, add a **Start Timer** Action and complete it as follows:
   * Change the key to “request-feedback”
   * Set an execution of 5 minutes after the appointment by adding the following **Custom Expression**:

```javascript
ADD_TO_DATETIME(
  session.appointment.end_time,
  5,
  "m"
)
```

This uses the Airscript function [ADD\_TO\_DATETIME](../../airscript-expressions/datetime-functions/add_to_datetime) to return a DataTime indicating a time five minutes after the appointment ends.

![](https://files.readme.io/4928334-Screen_Shot_2023-02-07_at_1.19.26_PM.png)

* To remain TCPA compliant, under **Which Availability Schedule > Custom Expression**, add the following Availability Schedule Key:

```javascript
"TCPA-{{actor.region}}-{{actor.time_zone}}"
```

* In **If time is not available** select the **Use next available time** option.

<figure><img src="https://2599974655-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIRF6etABDVMr59RdpyGw%2Fuploads%2Fgit-blob-8b4ba625545ed667f4cebed4bfe768b54cd7be22%2Frequesting-feedback-v184-9.png?alt=media" alt="" width="300"><figcaption></figcaption></figure>

2. Beneath the **Start Timer** Action, nest a **Navigate to Web Flow** Action and select the "Collect Feedback" Web Flow.

<figure><img src="https://2599974655-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIRF6etABDVMr59RdpyGw%2Fuploads%2Fgit-blob-4fe020c89c3496cdaa111b980f9f11d2a27b8dc0%2Frequesting-feedback-v184-10.png?alt=media" alt="" width="300"><figcaption></figcaption></figure>

3. Nested underneath the **Start Timer** Action, add a **Send SMS** Action and select the Notification we just created, **Ask for Feedback**.

<figure><img src="https://2599974655-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIRF6etABDVMr59RdpyGw%2Fuploads%2Fgit-blob-2ffca23158fdf8a9af6da591a2c04843b1f35605%2Frequesting-feedback-v184-11.png?alt=media" alt="" width="300"><figcaption></figcaption></figure>

## Previewing the request-feedback timer

Let's go to **App Preview** to preview the finalized application.

1. After emulating selecting an appointment time, click on the **Timers** tab to see the timers that are available at that stage of the Journey.
2. Select the timer you want to test and, from **Actions**, click on **Activate Scheduled Trigger**. By doing so, the timer will be triggered regardless of the time it was set for.

<figure><img src="https://2599974655-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIRF6etABDVMr59RdpyGw%2Fuploads%2Fgit-blob-e7a51319547415762f7361d7e7d06216b6d0d119%2Frequesting-feedback-v184-12.png?alt=media" alt="" width="400"><figcaption></figcaption></figure>

3. Go back to the **Device** tab and click on the chat icon at the bottom to see the Notification's message.

Congratulations! You've now built out an application capable of scheduling appointments and sending a variety of TCPA-compliant messages.

## A note about publishing

There's one important element of sending SMS Notifications that went largely unaddressed throughout this tutorial: when outgoing text messages are sent, we've established that they're sent to the Actor, but **what number are they sent&#x20;**_**from**_**?** This question is primarily important in the context to of publishing your application; see [Publishing Your Application](../../building-apps/publishing/publish-and-manage-deployments) to learn more.

The [Console](../../console/console) provides the means to connect your Twilio numbers to your [Org](../../administration/airkit-organizations). Once connected to an Org, phone numbers will become available in [Settings](../../studio/studio/builder-bar/settings) when accessing your application in the Studio. Under the **Chat Bot** section, you can select an available number to manage the texts associated with your application. Once a phone number is configured, your outgoing SMS Notifications will be sent from the configured number.

For more on how to associate your phone numbers with Airkit apps, see [Connecting Your Twilio Numbers To Airkit](../../sms/connecting-twilio-numbers).
