|
1 | 1 | ## Integrate Phone Calls and SMS with OpenAI
|
2 | 2 |
|
| 3 | +Full workflow here [https://developer.vonage.com/en/blog/integrate-phone-calls-and-sms-with-openai](https://developer.vonage.com/en/blog/integrate-phone-calls-and-sms-with-openai) |
| 4 | + |
3 | 5 | We've already developed a starter Vonage Voice application to receive a call, catch your response, and send it to a 3rd party (OpenAI).
|
4 | 6 | Users can deploy the App using Github Codespaces.
|
5 | 7 | Fork [this repository](https://github.com/Vonage-Community/tutorial-voice-messages-node-openai-integration). Open it in Codespaces by clicking "Create codespace on main"
|
6 | 8 |
|
7 | 9 | 
|
8 | 10 |
|
| 11 | +## Create a new Vonage app |
| 12 | +In the left menu [here](https://dashboard.nexmo.com/), click API Settings, left menu item. |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | +Copy and paste in the `.env` file API key and API Secret |
| 17 | + |
| 18 | +``` |
| 19 | +API_KEY=b********** |
| 20 | +API_SECRET=****************** |
| 21 | +``` |
| 22 | + |
| 23 | +**OpenAI API** |
| 24 | + |
| 25 | +After [registering](https://beta.openai.com/signup) and confirming your phone number, you need to generate your [API key](https://beta.openai.com/account/api-keys). |
| 26 | + |
| 27 | +With this API key, we can move forward. |
| 28 | + |
| 29 | +Paste it to your `.env` file |
| 30 | + |
| 31 | +``` |
| 32 | +API_KEY=b********** |
| 33 | +API_SECRET=****************** |
| 34 | +OPENAI_API_KEY=sk-************************************** |
| 35 | +``` |
| 36 | + |
| 37 | +## Deploy Our App in Codespace |
| 38 | + |
| 39 | +Open GitHub Codespace in your fork. |
| 40 | + |
| 41 | +In the Codespace terminal, run the following command to install our Node packages: |
| 42 | + |
| 43 | +``` |
| 44 | +npm install |
| 45 | +``` |
| 46 | + |
| 47 | +Run the following command in the terminal to receive the GitHub Codespace URL for webhooks |
| 48 | + |
| 49 | +``` |
| 50 | +echo "https://${CODESPACE_NAME}-3000.preview.app.github.dev/webhooks/asr" |
| 51 | +``` |
| 52 | + |
| 53 | +Copy and paste the output in `EVENT_URL=` in the `.env` file |
| 54 | + |
| 55 | +``` |
| 56 | +API_KEY=b********** |
| 57 | +API_SECRET=****************** |
| 58 | +OPENAI_API_KEY=sk-************************************** |
| 59 | +EVENT_URL=https://******************************************-3000.preview.app.github.dev/webhooks/asr |
| 60 | +``` |
| 61 | + |
| 62 | +Update App settings using [Dashboard](https://dashboard.nexmo.com/). Go to Application in the left menu. Choose a related app and click the 'Edit' button |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | +Run the App |
| 67 | + |
| 68 | +```bash |
| 69 | +node index.js |
| 70 | +``` |
| 71 | + |
| 72 | +In the terminal, open the `Port` tab. Click on `Private` in the `Visibility` column, and change it to `Public`. |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | +Everything is ready |
| 77 | + |
| 78 | +* Try this out by calling the number that is linked with the app `**732**56**` |
| 79 | +* Tell the bot your tip |
| 80 | +* Wait for the content in the corresponding messenger |
| 81 | +* Monitor the console |
| 82 | + |
| 83 | + |
| 84 | + |
0 commit comments