image: ./preview.webp # From Small Biz to Smart Biz with AI Deploy an AI-powered voice agent with server logic to a phone number The companion developer guide to the LIVEWire event Wednesday May 8th, 2024 11:00am PT / 2:00pm ET⚡️ LIVEWire Developer Docs
This demo guides you through installing and setting up the WireStarter Docker container, configuring it with SWSH (the SignalWire Interactive Shell), and connecting a SWML Script to a Python application running a local server to handle logic. The server is Flask and it’s exposed to the SWML Script via an ngrok tunnel. **At the end of the demo, youll be able to call your SignalWire phone number and speak with an AI agent that communicates back and forth with your new server to make decisions.** ### 📖 Definitions - [**WireStarter:**](/tools/wirestarter/) A Docker container that simplifies the setup of SignalWire SDKs and development environments. - [**SWSH (SignalWire interactive SHell):**](/tools/swsh/) A command line utility built in to WireStarter that interfaces with SignalWire APIs. - [**SWML (SignalWire Markup Language):**](/swml) A hybrid markup and scripting language for writing RELAY applications (realtime interacative communication applications using Websockets) using simple statements in YAML or JSON. - [**SWML Script:**](https://my.signalwire.com?page=relay-bins) A cloud execution solution for hosting and running SWML in bins on your SignalWire Dashboard. - [**Flask:**](https://flask.palletsprojects.com/en/3.0.x/) A Python web application framework for Python, used here for our server. - [**ngrok:**](https://ngrok.com) A tunneling service used here to create a secure tunnel from our local Flask server to the SWML Script. ### 🏗️ Application Structure mermaid sequenceDiagram participant User participant SignalWire Cloud participant SWML Script (incl. AI Agent) participant ngrok Tunnel participant Flask Server participant Python App User->>SignalWire Cloud: Initiate phone call SignalWire Cloud->>SWML Script (incl. AI Agent): Handle call flow SWML Script (incl. AI Agent)->>ngrok Tunnel: API call to Websocket ngrok Tunnel->>Flask Server: Receive API call Flask Server->>Python App: Execute logic Python App->>Flask Server: Return response Flask Server->>ngrok Tunnel: Expose response ngrok Tunnel->>SWML Script (incl. AI Agent): Receive response SWML Script (incl. AI Agent)->>SignalWire Cloud: Handle call flow based on server response SignalWire Cloud->>User: Conversational responses ### 📋 Prerequisites
Return to the integrated terminal in the running WireStarter Docker Container. Enter exit once to exit SWSH. Navigate to the root of the container using cd /. Then, run the following command to create a folder named livewire within workdir in the container: bash mkdir /workdir/livewire Return to your system terminal, and navigate to your Downloads folder. Copy the container ID from the Containers view in Docker Desktop. ![Container ID in Docker Desktop.](./docker-desktop-container-id.webp) Finally, run the following command **in your system terminal** to copy app.py into /workdir/livewire/ within the WireStarter container. Replace [container-id] with the WireStarter container ID from Docker Desktop. bash docker cp app.py [container-id]:/workdir/livewire/ ## **4. 🚀 Run and test the application** 1. **Run app.py** Return to the Docker integrated terminal. From the root of the container filesystem, run the Python application using the below command: bash python3 /workdir/livewire/app.py Alternatively, you can navigate to /workdir/livewire/ and run python3 app.py. 2. **Dial the phone number** We did it! The application should now be ready to test. Using your cell phone or softphone, dial the phone number you assigned to the SWML Script back in Step 2. Vicky will answer. 3. **Test the server logic** Our demo Python app is set up with very minimal logic - thats where your creativity comes in! To make sure the SWML Script is correctly contacting our server, ask Vicky what day is it? or whats up, brother? If Vicky responds, special teams, special plays, special players, you know the demo is working. Congratulations! ## 🧰 Troubleshooting - **Vicky says something isnt available and nothing shows up in the Docker integrated terminal logs** This occurs when the SWML Script is unable to reach the websocket. This often occurs when the NGROK url is incorrect, so first, check it for typos. If you have stopped and restarted the WireStarter container, youll need to update the web_hook_url in the SWML Script with the new NGROK Tunnel URL, as this regenerated on container restart. - **The Python app sends 404 responses (seen in the Docker logs) when Vicky contacts the Python app** This occurs when the NGROK tunnel URL is correctly set in the SWML script, but it is missing the /swaig path. ##### Made with ❤️ by SignalWires DevEx team {#devex} *Have feedback on this site? Drop us a line at devex@signalwire.com or say hi on the [Community Slack](https://signalwire-community.slack.com/).*
Smart Biz LIVEWire Developer Docs
Before getting started, please make sure you have the following prerequisites. - Sign up for a free [SignalWire Space](https://id.signalwire.com/onboarding) - Install [Docker Desktop](https://www.docker.com/products/docker-desktop/) - Buy a [SignalWire Phone Number](/guides/buying-a-phone-number/) - Create a free [ngrok account](https://ngrok.com/) Everything else you need is built into WireStarter.
:::tip Extra Credit Ask SignalWire staff for a promo code to elevate your account out of Trial status and add extra credit to your account. :::