Build a Farewell App Using Vonage AI Studio and Notion as a Database
Published on December 19, 2023

Recreating S7E22 of The Office (Vonage Edition)

Was anyone else not okay after season 7 episode 22 of The Office?

SPOILER ALERT!

"Goodbye, Michael" was originally supposed to be about Michael Scott getting fired from Dunder Mifflin for a business mistake (Boring!). Instead, the writers decided to rip out our hearts with this extremely sweet episode where Michael ends up leaving the company to move to Colorado to be with his fiancée.

Before leaving, he gives each of his employees a special going-away gift. While I didn't do anything remotely as epic when I left my past company, I built an app that allowed my former coworkers to send their names to a virtual phone number and receive a personalized message I had written for each of them. It was a thoughtful way to say farewell and let them know how much I appreciated their help that summer.

I'd love to show you how you can recreate this project using Vonage AI Studio, and Notion. Let's dive in and get started!

Prerequisites

  • a Vonage Developer account

  • a Notion account to create our database

    Vonage API Account

    To complete this tutorial, you will need a Vonage API account. If you don’t have one already, you can sign up today and start building with free credit. Once you have an account, you can find your API Key and API Secret at the top of the Vonage API Dashboard.

Set up Vonage AI Studio

Once that's done, go to your API Dashboard and, on the left-hand side find BUILD & MANAGE > AI Studio > Go to AI Studio > Create Agent. You can select any agent type, but for our example we're going to build it with WhatsApp.

Fill in all the required details:

  • Region: Where will your Agent be typically used - The USA or in Europe

  • Agent Name: Give your Agent a unique name that is meaningful to you.

  • Language: Select the language of your Agent.

  • Time Zone: Choose the time zone where your Agent will operate.

For templates, we are going to Start from Scratch.

For event, this will be an Inbound Call because we are the ones texting our agent.

Create a Database Using Notion

As best practice, we will store the actual names of coworkers, messages, and recipient emails in a database - for this sample, we'll be using Notion!

  1. Go to Notion.

  2. Click the (+) button to add a page.

  3. On the new page under DATABASE, click 'Table'.

  4. Enter the different items you need in each column and their corresponding properties. We have columns titled Coworker, Message, and Email.

Screenshot of a Notion table titled 'Goodbye, Michael' with three columns labeled 'Coworker,' 'Message,' and 'Email.' There are entries for three coworkers: Dwight, Kevin, and Darryl. Dwight's message is a humorous, self-praising speech; Kevin's is a short, reflective statement; and Darryl's message mentions giving the only copy of 'Somehow I Manage,' unfinished. Each entry includes a corresponding email address at dundermifflin.com.Database in Notion

Define the Conversational Flow

Now comes the fun part! With Vonage AI Studio's easy-to-use interface, you can design your chatbot's conversational flow. It's a drag-and-drop setup, meaning you don't need coding skills to get going. You can add different dialog nodes and define responses.

Our flow should look like this:

A flowchart of a conversational interface process. It starts with 'START,' then moves to a 'ASK NAME' step, which is a text input with a note 'Unexpected Input Type.' Next is 'Webhook 1' showing a '2XX' status but marked as 'Failed.' The flow then splits; one path goes to 'SEND EMAIL' with a variable '$RETURNED_EMAIL,' and the other path leads to 'END CONVERSA...' indicating the end of the conversation. The overall layout suggests a sequential process with a conditional branch for sending an email or ending the conversation.Conversation Flow

NODES > Conversation > Collect Input The virtual agent will prompt a question to the user.

  • Node name: ASK NAME.

  • Prompt: "Well, I'm moving to Colorado to start my new life with Holly." Reply with your name to receive your personalized message.

  • Retry Prompt: Let's try again. Reply with your name.

  • Expected Input: Text

NODES > Integrations > Webhook

  • Method: POST

  • Request URL: https://api.notion.com/v1/databases/<database_id>/query_ To find a database ID, navigate to the database URL in your Notion workspace. The ID is the string of characters in the URL that is between the slash following the workspace name (if applicable) and the question mark. The ID is a 32-character alphanumeric string._

  • Headers (HTTP Header : Value)

    • Authorization : Bearer $NOTION*ACCESS_TOKEN

    • Notion-Version : 2022-06-28

    • Content-Type : application/json* To find your $NOTION_ACCESS_TOKEN, go through the Authorization process for an internal integration on Notion._ -Response Mapping Response type: JSON Object path: After filling out the above information in our webhook node, make sure the webhook is working by clicking the 'Test request' button in the top right. Under Response, you'll see that it returns all the data from our Notion table. Using the response, define the object path and map it to a parameter.

Screenshot of a 'Response Mapping' section from an application interface with a drop-down menu selecting 'JSON' as the response type. There are three object paths listed with corresponding parameters. The first is 'results[0].properties.Message.rich_text[0].text.content' mapped to a parameter '$RETURNED_MESSAGE'. The second is 'results[0].properties.Email.email' mapped to '$RETURNED_EMAIL'. The third is 'results[0].properties.Coworker.title[0].plain_text' mapped to '$RETURNED_COWORKER'. The layout is a structured table indicating how JSON response elements correspond to internal parameters of the system.Response Mapping

Parameter: For every object path, create a parameter. Select @sys.any for the Entity of each one.

A screenshot showing the 'Custom Parameters' settings in the 'Webhook 1' configuration panel. There are four parameters listed: 'INPUT,' 'RETURNED_COWORK...,' 'RETURNED_EMAIL,' and 'RETURNED_MESSAGE.' Each has an associated entity designated as '@sys.any' and a field for entering a value. The list suggests placeholders for user input and returned data from the system, awaiting specific values to be entered or retrieved during operation.Parameters

NODES > Action > Send Email

  • To: $RETURNED_EMAIL

  • Subject: Goodbye from Michael Scott

  • Body: $RETURNED_MESSAGE

NODES > Actions > End Conversation

Run the App

At the top of Vonage AI Studio, click "Tester" then "Start chat". Type a name from your database.

A screenshot of a chat interface in testing mode, labeled 'Tester' and 'Chat'. The conversation starts with an agent's message timed at 3:47 PM stating, 'Well, I'm moving to Colorado to start my new life with Holly.' prompting a reply with the user's name for a personalized message. The user responds with 'Darryl' at the same timestamp. Subsequent system messages indicate 'Webhook was executed successfully' and 'Email sent successfully,' followed by 'Conversation Ended.' The interface is designed to simulate a user interaction with an automated chatbot agent.Test Darryl

You should then get an email with its corresponding content!

A screenshot of an email interface with the subject 'Goodbye from Michael Scott' in the inbox. The sender is 'dont-reply@ai.vonage.com'. The body of the email reads, 'I would like to give you the only copy of "Somehow I Manage", unfinished. If there's anybody here who can finish it, it's you.' Below the message, there are options to 'Reply' or 'Forward' the email.Email Received

Building Your Own 'Good Old Days

Saying goodbye doesn't have to be ordinary. With a touch of creativity and the usage of Vonage AI Studio and Notion as a database, you can make farewells heartfelt and unforgettable. So, go ahead and spread some joy with personalized messages that will make them smile one last time.

In The Office finale, Andy Bernard says, "I wish there was a way to know you're in the good old days before you've actually left them." I would say we're in the good old days now with the technology and tools we can use to build cool iconic apps like this. Feel free to join our "office" of developers on Slack and follow us on X, formerly known as Twitter. If you end up building a similar application, please share it and tag me - I'd love to hear about your season finale.

Diana PhamDeveloper Advocate

Diana is a developer advocate at Vonage. She likes eating fresh oysters.

Ready to start building?

Experience seamless connectivity, real-time messaging, and crystal-clear voice and video calls-all at your fingertips.

Subscribe to Our Developer Newsletter

Subscribe to our monthly newsletter to receive our latest updates on tutorials, releases, and events. No spam.