{"id":19099418,"url":"https://github.com/TheCodeTraveler/TextMood_TwilioBlog","last_synced_at":"2025-09-08T04:31:39.551Z","repository":{"id":68231193,"uuid":"141362130","full_name":"TheCodeTraveler/TextMood_TwilioBlog","owner":"TheCodeTraveler","description":"Source code for Twilio Blog Post","archived":false,"fork":false,"pushed_at":"2020-10-22T22:22:34.000Z","size":44,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-07T04:39:12.927Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TheCodeTraveler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-18T00:57:53.000Z","updated_at":"2020-10-22T22:22:36.000Z","dependencies_parsed_at":"2023-02-21T06:16:08.872Z","dependency_job_id":null,"html_url":"https://github.com/TheCodeTraveler/TextMood_TwilioBlog","commit_stats":null,"previous_names":["thecodetraveler/textmood_twilioblog","brminnick/textmood_twilioblog"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TheCodeTraveler/TextMood_TwilioBlog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheCodeTraveler%2FTextMood_TwilioBlog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheCodeTraveler%2FTextMood_TwilioBlog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheCodeTraveler%2FTextMood_TwilioBlog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheCodeTraveler%2FTextMood_TwilioBlog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheCodeTraveler","download_url":"https://codeload.github.com/TheCodeTraveler/TextMood_TwilioBlog/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheCodeTraveler%2FTextMood_TwilioBlog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274134642,"owners_count":25228198,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T03:50:01.192Z","updated_at":"2025-09-08T04:31:39.528Z","avatar_url":"https://github.com/TheCodeTraveler.png","language":"C#","readme":"# TextMood\n\n## Automatic Text Sentiment Analysis\n\nWith the power of [Twilio Webhooks](https://www.twilio.com/docs/glossary/what-is-a-webhook), we can forward all received text messages to an [Azure Function](https://azure.microsoft.com/services/functions?WT.mc_id=mobile-0000-bramin) to leverage the power of the [Sentiment Analysis API](https://azure.microsoft.com/services/cognitive-services/text-analytics?WT.mc_id=mobile-0000-bramin).\n\nThe completed solution can be found here: https://github.com/brminnick/TextMood\n\n![Architecture Diagram](https://user-images.githubusercontent.com/13558917/43020603-66513e1a-8c15-11e8-928f-878ce536fd86.png)\n\n### POST Request\n\n```json\n{\n  \"documents\": [\n    {\n      \"language\": \"en\",\n      \"id\": \"251c99d7-1f89-426a-a3ad-c6fa1b34f020\",\n      \"text\": \"I hope you find time to actually get your reports done today.\"\n    }\n  ]\n}\n```\n\n### Response\n\n```json\n{\n\"sentiment\": {\n  \"documents\": [\n    {\n      \"id\": \"251c99d7-1f89-426a-a3ad-c6fa1b34f020\",\n      \"score\": 0.776355504989624\n    }\n  ]\n}\n```\n\n### 1. Create a Sentiment Analysis API Key\n\nTo use the Sentiment Analysis API, we'll need to first create an API Key using the Azure Portal.\n\n1. Navigate to the [Azure Portal](https://portal.azure.com/?WT.mc_id=mobile-0000-bramin)\n    - If you are new to Azure, use [this sign-up link](https://azure.microsoft.com/free/ai?WT.mc_id=mobile-0000-bramin) to receive a free $200 credit\n\n2. On the Azure Portal, select **+ Create a Resource**\n3. In the **New** window, select **AI + Machine Learning**\n4. In the **Featured** frame, select **Text Analytics**\n5. In the **Create** window, make the following selections\n    - **Name**: TextMood\n    - **Subscription**: [Select your Azure subscription]\n    - **Location**: [Select the location closest to you]\n    - **Pricing Tier**: F0 (5K Transactions per 30 days)\n        - This is a free tier\n    - **Resource Group**: TextMood\n6. In the **Create** window, select **Create**\n7. On the Azure Portal, select the bell-shaped notification icon\n8. Stand by while the **Notifications** window says **Deployment in progress...**\n9. Once the deployment has finished, on the **Notifications** window, select **Go to resource**\n10. In the TextMood Resource page, select **Keys** and locate **KEY 1**\n    - We will use this API Key when we create our Azure Function\n\n11. In the TextMood Resource page, select **Overview** and locate the **Endpoint**\n    - We will use this Url when we create our Azure Function\n\n### 2. Create an Azure Function\n\n[Azure Functions](https://azure.microsoft.com/services/functions?WT.mc_id=mobile-0000-bramin) are a serverless offering in Azure. In these steps, we will use Azure Functions to create a POST API.\n\n1. Clone or download the [TextMood_TwilioBlog](https://github.com/brminnick/TextMood_TwilioBlog)\n    - To clone the repo using git, open a cmd prompt and enter the following command:\n        - `git clone https://github.com/brminnick/TextMood_TwilioBlog.git`\n    - To download the repo use the following steps:\n        - Click the link above to navigate to the GitHub repo in your browser\n        - Click Clone or Download\n        - Click Download Zip\n\n![Download Zip](https://user-images.githubusercontent.com/13558917/43021037-13dfed6e-8c17-11e8-946e-baf30502104b.png)\n\n2. After downloading/cloning the repo, locate `TextMood.sln`\n3. Launch `TextMood.sln` in Visual Studio \n4. In **CognitiveServicesConstants.cs**, for `TextSentimentAPIKey`, replace `Your API Key` with the Key from the TextAnalytics Cognitive Service resource created earlier\n5. In **CognitiveServicesConstants.cs**, for `_cognitiveServicesEndpoint`, replace `Your Cognitive Services Endpoint` with the Endpoint from the TextAnalytics Cognitive Service resource created earlier\n\n6. In the Visual Studio Solution Explorer, right-click the TextMood project\n7. In the right-click menu, select **Publish**\n\n![Right Click Publish](https://user-images.githubusercontent.com/13558917/43021578-fe004e56-8c18-11e8-97cc-3a79dd3fe2e5.png)\n\n8. In the Publish window, select **Function App**\n9. In the Publish window, select **Create New**\n10. In the Public window, select **Publish**\n\n![Publish Window](https://user-images.githubusercontent.com/13558917/43021579-fe1eaa7c-8c18-11e8-8545-4d5cb1a058ae.png)\n\n11. In the **Create App Service** window, enter an App Name\n    - **Note**: The app name needs to be unique because it will be used for the Function's url \n    - I recommend using TextMood[LastName]\n        - In this example, I am using TextMoodMinnick\n\n12. In the **Create App Service** window, select your subscription\n13. In the **Create App Service** window, next to **Resource Group** select **New...**\n\n![Create App Service](https://user-images.githubusercontent.com/13558917/43049737-ab7beb6e-8db1-11e8-8bd0-251194acfee5.png)\n\n14. In the **New resource group name** window, enter TextMood\n15. In the **New resource group name**, select **OK**\n\n![Create App Service Group](https://user-images.githubusercontent.com/13558917/43049736-ab6769e6-8db1-11e8-89c9-c18b9d1c2bcf.png)\n\n16. In the **Create App Service** window, next to **Hosting Plan**, select **New...**\n\n![New Hosting Plan](https://user-images.githubusercontent.com/13558917/43049735-ab51eabc-8db1-11e8-94eb-7853331fad33.png)\n\n17. In the **Configure Hosting Plan** window, enter a name for **App Service Plan**\n    - I recommend using TextMood[LastName]Plan\n        - In this example, I am using TextMoodMinnickPlan\n\n18. In the **Configure Hosting Plan** window, select a **Location**\n    - I recommend selecting the location closest to you\n\n19. In the **Configure Hosting Plan** window, for the **Size**, select **Consumption**\n20. In the **Configure Hosting Plan** window, select **OK**\n\n![Configure Hosting Plan](https://user-images.githubusercontent.com/13558917/43049734-ab3d2028-8db1-11e8-889f-0cf28cd1a1f0.png)\n\n21. In the **Create App Service** window, next to **Storage Account**, select **New...**\n\n![New Storage Account](https://user-images.githubusercontent.com/13558917/43049733-ab26f24e-8db1-11e8-8421-ea121903e6c2.png)\n\n22. In the **Storage Account** window, enter an **Account Name**\n    - I recommend using textmood[LastName]\n        - In this example, I am using textmoodminnick\n23. In the **Storage Account** window, for the **Account Type**, select **Standard - Locally Redundant**\n24. In the **Storage Account** window, select **OK**\n\n![New Storage Account](https://user-images.githubusercontent.com/13558917/43049732-ab104c9c-8db1-11e8-8ea7-182837384c78.png)\n\n25. In the **Create App Service** window, select **Create** \n\n![Create App Service](https://user-images.githubusercontent.com/13558917/43049731-aad2e488-8db1-11e8-8291-f8bf297ea281.png)\n\n26. Stand by while the Azure Function is created\n\n![Deploying App Service](https://user-images.githubusercontent.com/13558917/43049839-7b3710f8-8db3-11e8-9f79-ce24c77c90c1.png)\n\n27. In the Visual Studio Solution Explorer, right-click the TextMood project\n28. In the right-click menu, select **Publish**\n\n![Right Click Publish](https://user-images.githubusercontent.com/13558917/43021578-fe004e56-8c18-11e8-97cc-3a79dd3fe2e5.png)\n\n29. In the **Publish** window, select **Publish**\n\n![Azure Functions Publish](https://user-images.githubusercontent.com/13558917/43050274-eb039328-8dba-11e8-8c2f-eacf72d8c9f0.png)\n\n### 4. Copy Azure Functions Url\n\n1. Navigate to the [Azure Portal](https://portal.azure.com/?WT.mc_id=mobile-0000-bramin)\n2. On the Azure Portal, select **Resource Groups**\n3. In the **Resource Group** window, select **TextMood**\n\n![Resource Group TextMood](https://user-images.githubusercontent.com/13558917/43050243-4b24c692-8dba-11e8-8ab3-16656077a73f.png)\n\n4. In the TextMood Resource Group window, select **Overview**\n5. In the TextMood Overview window, select the Azure Function resource, **TextMood[LastName]**\n\n![Open Functions](https://user-images.githubusercontent.com/13558917/43050244-4b3a2802-8dba-11e8-9a90-4467470ac2fa.png)\n\n6. In the **Azure Functions** window, select **AnalyzeTextSentiment**\n7. In the **AnalyzeSentiment** window, select **Get Function Url**\n    - We will use this Url when we create our Twilio phone number\n\n![Get Function Url](https://user-images.githubusercontent.com/13558917/43050298-6d28cd46-8dbb-11e8-9442-b1dfa85ada24.png)\n\n### 5. Create Twilio Phone Number\n\n1. Log into your Twilio account and navigate to the [Manage Numbers](https://www.twilio.com/console/phone-numbers/incoming) page. \n\n2. Click the **+** sign to buy a new number\n    - Note you may skip this step if you have an existing Twilio Phone Number\n\n![Buy a new number](https://user-images.githubusercontent.com/13558917/43050486-3d85fd54-8dbe-11e8-82aa-4cd94737a05f.png)\n\n3. On the **Buy a Number** page, select a **Country**\n    - For this example, I am using United States\n\n4. On the **Buy a Number** page, tap the **Number** drop down and change it to **Location**\n5. On the **Buy a Number** page, enter a location name\n    - For this example, I am using San Francisco\n\n6. On the **Buy a Number** page, check **SMS**\n7. On the **Buy a Number** page, click **Search**\n\n![Buy a new number page](https://user-images.githubusercontent.com/13558917/43050472-20250a98-8dbe-11e8-88e9-d059dac13cca.png)\n\n8. On the search results page, locate the number you'd like to purchase and select **Buy**\n\n![Buy Number](https://user-images.githubusercontent.com/13558917/43050469-1fe11158-8dbe-11e8-982d-3f608ad066c7.png)\n\n9. In the confirmation window, select **Buy This Number**\n\n![Buy This Number](https://user-images.githubusercontent.com/13558917/43050470-1ff6197c-8dbe-11e8-8364-9cafe5f0b9ca.png)\n\n10. In the purchase confirmation window, select **Setup Number**\n\n![Setup Number](https://user-images.githubusercontent.com/13558917/43050471-200b6ff2-8dbe-11e8-8187-df1a964399f9.png)\n\n11. In the **Messaging** section, next to **A Message Comes In**, select **Webhook**\n12. In the **Messaging** section, next to **A Message Comes In**, enter the Azure Function Url that we created in the previous section\n13. In the **Messaging** section, next to **A Message Comes In**, select **HTTP POST**\n14. In the **Manage Numbers** window, select **Save**\n\n![Messaging](https://user-images.githubusercontent.com/13558917/43158699-2d545b7e-8f35-11e8-8e47-d120024aa948.png)\n\n### 6. Send a Text\n\n1. Open a text messaging app and send a text message to your Twilio phone number\n\n![Happy Text](https://user-images.githubusercontent.com/13558917/43050543-4ca5cbb0-8dbf-11e8-8c37-82752d265432.png)\n\n# Resources\n\n- [Azure Sentiment Analysis](https://azure.microsoft.com/services/cognitive-services/text-analytics?WT.mc_id=mobile-0000-bramin)\n- [Azure Functions](https://azure.microsoft.com/services/functions?WT.mc_id=mobile-0000-bramin)\n- [Twilio Webhooks](https://www.twilio.com/docs/glossary/what-is-a-webhook)\n- [Cognitive Services](https://azure.microsoft.com/services/cognitive-services?WT.mc_id=mobile-0000-bramin)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTheCodeTraveler%2FTextMood_TwilioBlog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTheCodeTraveler%2FTextMood_TwilioBlog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTheCodeTraveler%2FTextMood_TwilioBlog/lists"}