Overview and setup

In this guide, we'll walk you through using your first Voiceflow API with a simple Python interface to chat with your agent. You can also find a video version of the same guide below.

This guide will primarily be taught in Python is easy to get started with, and the lessons learned here should be applicable to any programming language.

There will still be JavaScript NodeJS equivalents in a second tab on all the code examples, and you can find examples in more languages on our API Examples GitHub repo. This guide is based off the Python example from there, but goes a bit more in depth with more APIs.

You'll learn:

  • How to get your Voiceflow Project API key
  • Using the Dialog Manager API (DM API)
    • How to send requests to Voiceflow APIs
    • How to start a conversation
    • How to parse the output traces
    • How to send user replies
    • How to deal with other traces (button, end, and more)
  • Using the Transcripts and other APIs
    • Saving your user transcript

We encourage you to follow along step by step, but if you ever get lost or would jump ahead to the finished code (for both Python and JavaScript), you can find it here. Whenever you see 👉, that means that there's a step to take in the guide. Speaking of which…

👉 Make sure you've installed Python, and create a new empty file called VoiceflowAPIGuide.py. Since we'll be using web requests to interact with Voiceflow APIs, make sure to import the requests library. If you're following along in JavaScript (using NodeJS), make sure to install axios with npm install axios.

import requests
const axios = require('axios');

👉 Import this Voiceflow project into your workspace. You can click a download button in the top right. It's the template we'll be using for this project, and since this guide is focused on using the APIs, it's a pretty basic project.


👉 Once you've imported the project, run a test from inside Voiceflow by clicking the run button in the top right. Make any changes you want to, and then click Publish in the top right. This puts out a version of your Voiceflow agent that we can work with. There's no need to give it a name. If you forget to publish, your agent won't work and the returned JSON will just be [].

📘

Next up: How to get your Voiceflow Project API key